diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 5bea2b8a3..e9efbee0d 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -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) diff --git a/src/Lexer.h b/src/Lexer.h index 5f21ce73e..18857ea61 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -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;