From b06ac68248df49edaa8a94a54e302d3a07b54694 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 26 May 2014 20:58:10 -0400 Subject: [PATCH] Lexer - When a Lexer::typeIdentifier is found, it can be compared to a list of other tokens, with the possibility of changing the type. This applies to tokens that are longer than the four-character lookahead in the Lexer. With this change, the Lexer can now identify all operators supported by Eval, and therefore the Lexer can be used on all Eval input expressions. This is because all the evaluator needs to know is the distinction between operators and operands. --- src/Context.cpp | 4 ++-- src/Lexer.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index 80041dc43..4560b2cbb 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -172,7 +172,7 @@ int Context::initialize (int argc, const char** argv) for (col = columns.begin (); col != columns.end (); ++col) parser.entity ("attribute", col->first); - // Entities: Pseudo-attributes. + // Entities: Pseudo-attributes. Hard-coded. parser.entity ("pseudo", "limit"); // Entities: Modifiers. @@ -191,7 +191,7 @@ int Context::initialize (int argc, const char** argv) parser.findCommand (); // parser.findUUIDList (); // Before findIdSequence parser.findIdSequence (); // - parser.injectDefaults (); // rc.default.command + parser.injectDefaults (); // rc.default.command // Static initialization to decouple code. staticInitialization (); diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 10c23a07c..b696bb6a8 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -225,6 +225,15 @@ bool Lexer::token (std::string& token, Type& type) } else { + // typeIdentifier is a catch-all type. Anything word-like becomes an + // identifier. At this point in the processing, an identifier is found, + // and can be matched against a list of potential upgrades. + if (token == "_hastag_" || + token == "_notag_" || + token == "_neg_" || + token == "_pos_") + type = typeOperator; + return true; } break;