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;
|
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
|
// Lexer::Type::separator
|
||||||
// --
|
// --
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ public:
|
|||||||
bool isDuration (std::string&, Lexer::Type&);
|
bool isDuration (std::string&, Lexer::Type&);
|
||||||
bool isUUID (std::string&, Lexer::Type&);
|
bool isUUID (std::string&, Lexer::Type&);
|
||||||
bool isNumber (std::string&, Lexer::Type&);
|
bool isNumber (std::string&, Lexer::Type&);
|
||||||
|
bool isInteger (std::string&, Lexer::Type&);
|
||||||
bool isHexNumber (std::string&, Lexer::Type&);
|
bool isHexNumber (std::string&, Lexer::Type&);
|
||||||
bool isSeparator (std::string&, Lexer::Type&);
|
bool isSeparator (std::string&, Lexer::Type&);
|
||||||
bool isURL (std::string&, Lexer::Type&);
|
bool isURL (std::string&, Lexer::Type&);
|
||||||
|
|||||||
Reference in New Issue
Block a user