mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 00:57:19 +02:00
Lexer: Implemented ::isInteger to help parsing.
This commit is contained in:
parent
37e31e8e0b
commit
c769891b76
2 changed files with 23 additions and 0 deletions
|
@ -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&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue