Lexer: Implemented ::isInteger to help parsing.
This commit is contained in:
@@ -603,6 +603,28 @@ bool Lexer::isNumber (std::string& token, Lexer::Type& type)
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Lexer::Type::number
|
||||
// \d+
|
||||
bool Lexer::isInteger (std::string& token, Lexer::Type& type)
|
||||
{
|
||||
std::size_t marker = _cursor;
|
||||
|
||||
if (isDigit (_text[marker]))
|
||||
{
|
||||
++marker;
|
||||
while (isDigit (_text[marker]))
|
||||
utf8_next_char (_text, marker);
|
||||
|
||||
token = _text.substr (_cursor, marker - _cursor);
|
||||
type = Lexer::Type::number;
|
||||
_cursor = marker;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Lexer::Type::separator
|
||||
// --
|
||||
|
||||
Reference in New Issue
Block a user