mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Implemented ::lexFilterArgs
- Now spots filter elements that need to be Lexed.
This commit is contained in:
parent
c2c53fa668
commit
694323a8f1
2 changed files with 39 additions and 0 deletions
38
src/CLI2.cpp
38
src/CLI2.cpp
|
@ -650,6 +650,7 @@ void CLI2::prepareFilter (bool applyContext)
|
|||
context.debug (dump ("CLI2::prepareFilter categorize"));
|
||||
|
||||
// Remove all the syntactic sugar for FILTERs.
|
||||
lexFilterArgs ();
|
||||
findIDs ();
|
||||
findUUIDs ();
|
||||
insertIDExpr ();
|
||||
|
@ -1523,6 +1524,43 @@ void CLI2::insertIDExpr ()
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// FILTER Lexer::Type::word args will become part of an expression, and so they
|
||||
// need to be Lexed.
|
||||
void CLI2::lexFilterArgs ()
|
||||
{
|
||||
bool changes = false;
|
||||
std::vector <A2> reconstructed;
|
||||
for (auto& a : _args)
|
||||
{
|
||||
if (a._lextype == Lexer::Type::word &&
|
||||
a.hasTag ("FILTER"))
|
||||
{
|
||||
changes = true;
|
||||
|
||||
std::string lexeme;
|
||||
Lexer::Type type;
|
||||
Lexer lex (a.attribute ("raw"));
|
||||
while (lex.token (lexeme, type))
|
||||
{
|
||||
A2 extra (lexeme, type);
|
||||
extra.tag ("FILTER");
|
||||
reconstructed.push_back (extra);
|
||||
}
|
||||
}
|
||||
else
|
||||
reconstructed.push_back (a);
|
||||
}
|
||||
|
||||
if (changes)
|
||||
{
|
||||
_args = reconstructed;
|
||||
|
||||
if (context.config.getInteger ("debug.parser") >= 3)
|
||||
context.debug (dump ("CLI2::prepareFilter lexFilterArgs"));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// FILTER, Lexer::Type::word args are treated as search terms.
|
||||
//
|
||||
|
|
|
@ -101,6 +101,7 @@ private:
|
|||
void findIDs ();
|
||||
void findUUIDs ();
|
||||
void insertIDExpr ();
|
||||
void lexFilterArgs ();
|
||||
void desugarFilterPlainArgs ();
|
||||
void insertJunctions ();
|
||||
void defaultCommand ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue