mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
A3t
- Implemented the stubbed outline of ::findMissingOperators, for injecting 'and' or 'or' into filter expressions, where needed.
This commit is contained in:
parent
10d08ad4f9
commit
195fa20a48
2 changed files with 37 additions and 0 deletions
36
src/A3t.cpp
36
src/A3t.cpp
|
@ -149,6 +149,7 @@ Tree* A3t::parse ()
|
|||
findModifications ();
|
||||
|
||||
findPlainArgs ();
|
||||
findMissingOperators ();
|
||||
|
||||
validate ();
|
||||
|
||||
|
@ -1361,6 +1362,41 @@ void A3t::findPlainArgs ()
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void A3t::findMissingOperators ()
|
||||
{
|
||||
std::vector <Tree*>::iterator prev = _tree->_branches.begin ();
|
||||
std::vector <Tree*>::iterator i;
|
||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||
{
|
||||
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
|
||||
{
|
||||
// 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>
|
||||
//
|
||||
if (i != prev &&
|
||||
(((*prev)->hasTag ("FILTER") && ! (*prev)->hasTag ("OP")) || (*prev)->attribute ("raw") == ")") &&
|
||||
(! (*i)->hasTag ("OP") || (*i)->attribute ("raw") == "("))
|
||||
{
|
||||
std::cout << "# missingOperator '"
|
||||
<< (*prev)->attribute ("raw")
|
||||
<< " "
|
||||
<< (*i)->attribute ("raw")
|
||||
<< "' --> '"
|
||||
<< (*prev)->attribute ("raw")
|
||||
<< " and "
|
||||
<< (*i)->attribute ("raw")
|
||||
<< "'\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Validate the parse tree.
|
||||
void A3t::validate ()
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
void findFilter ();
|
||||
void findModifications ();
|
||||
void findPlainArgs ();
|
||||
void findMissingOperators ();
|
||||
void validate ();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue