Lexer: Implemented ::isLiteral, to help with parsing
This commit is contained in:
@@ -1077,6 +1077,21 @@ bool Lexer::isWord (std::string& token, Lexer::Type& type)
|
|||||||
return false;
|
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
|
// Static
|
||||||
std::string Lexer::typeToString (Lexer::Type type)
|
std::string Lexer::typeToString (Lexer::Type type)
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public:
|
|||||||
bool isDOM (std::string&, Lexer::Type&);
|
bool isDOM (std::string&, Lexer::Type&);
|
||||||
bool isIdentifier (std::string&, Lexer::Type&);
|
bool isIdentifier (std::string&, Lexer::Type&);
|
||||||
bool isWord (std::string&, Lexer::Type&);
|
bool isWord (std::string&, Lexer::Type&);
|
||||||
|
bool isLiteral (const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _text;
|
std::string _text;
|
||||||
|
|||||||
Reference in New Issue
Block a user