Lexer: Implemented ::isInteger to help parsing.

This commit is contained in:
Paul Beckingham 2015-07-25 17:54:55 -04:00
parent 37e31e8e0b
commit c769891b76
2 changed files with 23 additions and 0 deletions

View file

@ -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
// --

View file

@ -91,6 +91,7 @@ public:
bool isDuration (std::string&, Lexer::Type&);
bool isUUID (std::string&, Lexer::Type&);
bool isNumber (std::string&, Lexer::Type&);
bool isInteger (std::string&, Lexer::Type&);
bool isHexNumber (std::string&, Lexer::Type&);
bool isSeparator (std::string&, Lexer::Type&);
bool isURL (std::string&, Lexer::Type&);