mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
CLI
- Implemented ::insertJunctions.
This commit is contained in:
parent
8cb287ec69
commit
e4a237fcd3
2 changed files with 68 additions and 1 deletions
68
src/CLI.cpp
68
src/CLI.cpp
|
@ -305,13 +305,14 @@ void CLI::analyze ()
|
|||
findOverrides ();
|
||||
categorize ();
|
||||
|
||||
// Remove all the syntactic sugar for FILTERs..
|
||||
// Remove all the syntactic sugar for FILTERs.
|
||||
desugarTags ();
|
||||
desugarAttributes ();
|
||||
desugarAttributeModifiers ();
|
||||
desugarPatterns ();
|
||||
desugarIDs ();
|
||||
desugarUUIDs ();
|
||||
insertJunctions ();
|
||||
|
||||
// Decompose the elements for MODIFICATIONs.
|
||||
decomposeModAttributes ();
|
||||
|
@ -1190,6 +1191,71 @@ void CLI::desugarUUIDs ()
|
|||
_args = reconstructed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Two consecutive FILTER, ID or UUID arguments:
|
||||
//
|
||||
// ID ID --> ID or ID
|
||||
// ID UUID --> ID or UUID
|
||||
// UUID ID --> UUID or ID
|
||||
// UUID UUID --> UUID or UUID
|
||||
//
|
||||
// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an
|
||||
// "and" operator inserted between them.
|
||||
//
|
||||
// ) <non-op> --> ) and <non-op>
|
||||
// <non-op> ( --> <non-op> <and> (
|
||||
// ) ( --> ) and (
|
||||
// <non-op> <non-op> --> <non-op> and <non-op>
|
||||
//
|
||||
void CLI::insertJunctions ()
|
||||
{
|
||||
std::vector <A> reconstructed;
|
||||
std::vector <A>::iterator prev = _args.begin ();
|
||||
std::vector <A>::iterator a;
|
||||
for (a = _args.begin (); a != _args.end (); ++a)
|
||||
{
|
||||
if (a->hasTag ("FILTER"))
|
||||
{
|
||||
// The prev iterator should be the first FILTER arg.
|
||||
if (prev == _args.begin ())
|
||||
prev = a;
|
||||
|
||||
// Insert OR between consecutive FILTER ID/UUID args.
|
||||
if (a != prev &&
|
||||
(prev->hasTag ("ID") || prev->hasTag ("UUID")) &&
|
||||
(a->hasTag ("ID") || a->hasTag ("UUID")))
|
||||
{
|
||||
A opOr ("argOp", "or");
|
||||
opOr.tag ("FILTER");
|
||||
opOr.tag ("OP");
|
||||
reconstructed.push_back (opOr);
|
||||
}
|
||||
|
||||
// Insert AND between terms.
|
||||
else if (a != prev)
|
||||
{
|
||||
if ((! prev->hasTag ("OP") && a->attribute ("raw") == "(") ||
|
||||
(! prev->hasTag ("OP") && ! a->hasTag ("OP")) ||
|
||||
(prev->attribute ("raw") == ")" && ! a->hasTag ("OP")) ||
|
||||
(prev->attribute ("raw") == ")" && a->attribute ("raw") == "("))
|
||||
{
|
||||
A opOr ("argOp", "and");
|
||||
opOr.tag ("FILTER");
|
||||
opOr.tag ("OP");
|
||||
reconstructed.push_back (opOr);
|
||||
}
|
||||
}
|
||||
|
||||
// Previous FILTER arg.
|
||||
prev = a;
|
||||
}
|
||||
|
||||
reconstructed.push_back (*a);
|
||||
}
|
||||
|
||||
_args = reconstructed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CLI::decomposeModAttributes ()
|
||||
{
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
void desugarPatterns ();
|
||||
void desugarIDs ();
|
||||
void desugarUUIDs ();
|
||||
void insertJunctions ();
|
||||
void decomposeModAttributes ();
|
||||
void decomposeModAttributeModifiers ();
|
||||
void decomposeModTags ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue