mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 00:57:19 +02:00
Lexer: Implemented ::isLiteral, to help with parsing
This commit is contained in:
parent
7354a8f13f
commit
9394b96202
2 changed files with 16 additions and 0 deletions
|
@ -1077,6 +1077,21 @@ bool Lexer::isWord (std::string& token, Lexer::Type& type)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Lexer::isLiteral (const std::string& literal)
|
||||
{
|
||||
if (_text.find (literal, _cursor) == 0 &&
|
||||
(isEOS () ||
|
||||
Lexer::isWhitespace (_text[_cursor + literal.length ()]) ||
|
||||
Lexer::isSingleCharOperator (_text[_cursor + literal.length ()])))
|
||||
{
|
||||
_cursor += literal.length ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Static
|
||||
std::string Lexer::typeToString (Lexer::Type type)
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
bool isDOM (std::string&, Lexer::Type&);
|
||||
bool isIdentifier (std::string&, Lexer::Type&);
|
||||
bool isWord (std::string&, Lexer::Type&);
|
||||
bool isLiteral (const std::string&);
|
||||
|
||||
private:
|
||||
std::string _text;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue