- Number digits followed by non-whitespace, non-operators are not numbers, ie
  "2nd" is not "2","nd".
This commit is contained in:
Paul Beckingham 2015-03-01 16:03:10 -05:00
parent abe8819f2f
commit 309b607672

View file

@ -554,6 +554,7 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type)
// \d+
// [ . \d+ ]
// [ e|E [ +|- ] \d+ [ . \d+ ] ]
// not followed by non-operator.
bool Lexer::isNumber (std::string& token, Lexer::Type& type)
{
std::size_t marker = _cursor;
@ -603,6 +604,12 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type)
}
}
// If there is an immediately consecutive character, that is not an operator, fail.
if (_eos > marker &&
! isWhitespace (_text[marker]) &&
! isSingleCharOperator (_text[marker]))
return false;
token = _text.substr (_cursor, marker - _cursor);
type = Lexer::Type::number;
_cursor = marker;