Lexer: Added standalone token support

- Added default ctor.
- Added ::token method for classifying whole tokens.
- Stubbed token classifier methods.
This commit is contained in:
Paul Beckingham 2015-07-04 11:38:09 -04:00
parent 4141215d4b
commit 3b99559216
2 changed files with 203 additions and 0 deletions

View file

@ -51,9 +51,11 @@ public:
dom, identifier, word,
date, duration };
Lexer ();
Lexer (const std::string&);
~Lexer ();
bool token (std::string&, Lexer::Type&);
Lexer::Type token (const std::string&);
static std::vector <std::pair <std::string, Lexer::Type>> tokens (const std::string&);
static std::vector <std::string> split (const std::string&);
static std::string typeToString (Lexer::Type);
@ -103,6 +105,31 @@ public:
bool isWord (std::string&, Lexer::Type&);
bool isContiguous (std::string&, Lexer::Type&);
// Token Classifiers.
/*
bool isString (const std::string&);
bool isDate (const std::string&);
bool isDuration (const std::string&);
bool isUUID (const std::string&);
bool isNumber (const std::string&);
bool isHexNumber (const std::string&);
bool isSeparator (const std::string&);
bool isURL (const std::string&);
bool isPair (const std::string&);
bool isSet (const std::string&);
*/
bool isTag (const std::string&);
/*
bool isPath (const std::string&);
bool isSubstitution (const std::string&);
bool isPattern (const std::string&);
bool isOperator (const std::string&);
bool isDOM (const std::string&);
bool isIdentifier (const std::string&);
bool isWord (const std::string&);
bool isContiguous (const std::string&);
*/
private:
std::string _text;
std::size_t _cursor;