Lexer: Implemented ::isLiteral, to help with parsing

This commit is contained in:
Paul Beckingham 2015-07-25 17:34:01 -04:00
parent 7354a8f13f
commit 9394b96202
2 changed files with 16 additions and 0 deletions

View file

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

View file

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