mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
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.
This commit is contained in:
parent
261f86c134
commit
b06ac68248
2 changed files with 11 additions and 2 deletions
|
@ -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 (); // <cmd>
|
||||
parser.findUUIDList (); // <uuid> Before findIdSequence
|
||||
parser.findIdSequence (); // <id>
|
||||
parser.injectDefaults (); // rc.default.command
|
||||
parser.injectDefaults (); // rc.default.command
|
||||
|
||||
// Static initialization to decouple code.
|
||||
staticInitialization ();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue