Lexer
- Number digits followed by non-whitespace, non-operators are not numbers, ie "2nd" is not "2","nd".
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user