mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Rewrote ::insertOr to only operate at the ORIGINAL node level, which is appropriate for this operation.
This commit is contained in:
parent
a471120e18
commit
a503a02663
1 changed files with 4 additions and 27 deletions
|
@ -1726,44 +1726,21 @@ void Parser::findMissingOperators ()
|
|||
// Two consecutive ID/UUID arguments get an 'or' inserted between them.
|
||||
bool Parser::insertOr ()
|
||||
{
|
||||
std::vector <Tree*> nodes;
|
||||
collect (nodes, collectTerminated);
|
||||
|
||||
// Subset the nodes to only the FILTER, non-PSEUDO nodes.
|
||||
std::vector <Tree*> filterNodes;
|
||||
std::vector <Tree*>::iterator prev = _tree->_branches.begin ();
|
||||
std::vector <Tree*>::iterator i;
|
||||
for (i = nodes.begin (); i != nodes.end (); ++i)
|
||||
if ((*i)->hasTag ("FILTER") && ! (*i)->hasTag ("PSEUDO"))
|
||||
filterNodes.push_back (*i);
|
||||
|
||||
std::vector <Tree*>::iterator prev = filterNodes.begin ();
|
||||
for (i = filterNodes.begin (); i != filterNodes.end (); ++i)
|
||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||
{
|
||||
// std::cout << "# prev = " << (*prev)->attribute ("raw") << " ... i = " << (*i)->attribute ("raw") << "\n";
|
||||
if (i != prev &&
|
||||
((*prev)->hasTag ("ID") || (*prev)->hasTag ("UUID")) &&
|
||||
((*i)->hasTag ("ID") || (*i)->hasTag ("UUID")))
|
||||
{
|
||||
// std::cout << "# needs OR\n";
|
||||
|
||||
Tree* branch = new Tree ("argOp");
|
||||
branch->attribute ("raw", "or");
|
||||
branch->tag ("OP");
|
||||
branch->tag ("FILTER");
|
||||
branch->_trunk = (*i)->_trunk;
|
||||
|
||||
std::vector <Tree*>::iterator b;
|
||||
for (b = (*i)->_trunk->_branches.begin ();
|
||||
b != (*i)->_trunk->_branches.end ();
|
||||
++b)
|
||||
{
|
||||
if (*b == *i)
|
||||
{
|
||||
(*i)->_trunk->_branches.insert (b, branch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
branch->_trunk = _tree;
|
||||
|
||||
_tree->_branches.insert (i, branch);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue