mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 19:17:19 +02:00
A3t
- ::findMissingOperators now detects all locations where a logicl operator is needed.
This commit is contained in:
parent
c9a94f0205
commit
2f46c5de31
1 changed files with 48 additions and 20 deletions
68
src/A3t.cpp
68
src/A3t.cpp
|
@ -1367,6 +1367,14 @@ void A3t::findPlainArgs ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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 A3t::findMissingOperators ()
|
void A3t::findMissingOperators ()
|
||||||
{
|
{
|
||||||
std::vector <Tree*>::iterator prev = _tree->_branches.begin ();
|
std::vector <Tree*>::iterator prev = _tree->_branches.begin ();
|
||||||
|
@ -1375,27 +1383,47 @@ void A3t::findMissingOperators ()
|
||||||
{
|
{
|
||||||
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
|
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
|
||||||
{
|
{
|
||||||
// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need
|
if ((*i)->_branches.size ())
|
||||||
// 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 '"
|
std::vector <Tree*>::iterator sub;
|
||||||
<< (*prev)->attribute ("raw")
|
for (sub = (*i)->_branches.begin (); sub != (*i)->_branches.end (); ++sub)
|
||||||
<< " "
|
{
|
||||||
<< (*i)->attribute ("raw")
|
if (sub != prev &&
|
||||||
<< "' --> '"
|
(((*prev)->hasTag ("FILTER") && ! (*prev)->hasTag ("OP")) || (*prev)->attribute ("raw") == ")") &&
|
||||||
<< (*prev)->attribute ("raw")
|
(! (*sub)->hasTag ("OP") || (*sub)->attribute ("raw") == "("))
|
||||||
<< " and "
|
{
|
||||||
<< (*i)->attribute ("raw")
|
std::cout << "# missingOperator '"
|
||||||
<< "'\n";
|
<< (*prev)->attribute ("raw")
|
||||||
|
<< " "
|
||||||
|
<< (*sub)->attribute ("raw")
|
||||||
|
<< "' --> '"
|
||||||
|
<< (*prev)->attribute ("raw")
|
||||||
|
<< " and "
|
||||||
|
<< (*sub)->attribute ("raw")
|
||||||
|
<< "'\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = sub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue