- Implemented isTokenEnd, as a special case of isWordEnd, but considers
  consecutive punctuation to be a set of individual tokens.
This commit is contained in:
Paul Beckingham 2011-09-10 13:24:54 -04:00
parent 94bb98edac
commit 562fd8ce3c
2 changed files with 21 additions and 1 deletions

View file

@ -601,7 +601,7 @@ bool isWordStart (const std::string& input, std::string::size_type pos)
// Result for pos: ....y......y
bool isWordEnd (const std::string& input, std::string::size_type pos)
{
// Short circuit: no input means no word start.
// Short circuit: no input means no word end.
if (input.length () == 0)
return false;
@ -618,6 +618,25 @@ bool isWordEnd (const std::string& input, std::string::size_type pos)
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Input: hello, world
// Result for pos: ....y......y
//
// Input: (one) two
// Result for pos: y..yy...y
bool isTokenEnd (const std::string& input, std::string::size_type pos)
{
// Delegate.
if (isWordEnd (input, pos))
return true;
// Punctuation divides tokens.
if (pos < input.length () && isPunctuation (input[pos]))
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Override of ispunct, that considers #, $ and @ not to be punctuation.
//