mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-03 07:07:19 +02:00
Parser
- Added ::collect method for recursive node gathering that needs some local persistence.
This commit is contained in:
parent
6a9cca82d7
commit
b84736a05f
2 changed files with 37 additions and 0 deletions
|
@ -270,6 +270,41 @@ bool Parser::canonicalize (
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Recursively scan all nodes, depth first, and create a linear list of node
|
||||||
|
// pointers, for simple iteration. This eliminates the need for recursion in
|
||||||
|
// each ::find* method.
|
||||||
|
void Parser::collect (std::vector <Tree*>& nodes, bool all, Tree* tree /* = NULL */)
|
||||||
|
{
|
||||||
|
if (tree == NULL)
|
||||||
|
tree = _tree;
|
||||||
|
|
||||||
|
std::vector <Tree*>::iterator i;
|
||||||
|
for (i = tree->_branches.begin (); i != tree->_branches.end (); ++i)
|
||||||
|
{
|
||||||
|
if ((*i)->_branches.size ())
|
||||||
|
{
|
||||||
|
collect (nodes, all, *i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! all)
|
||||||
|
{
|
||||||
|
// Parser override operator.
|
||||||
|
if ((*i)->hasTag ("TERMINATOR") ||
|
||||||
|
(*i)->hasTag ("TERMINATED"))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Skip known args.
|
||||||
|
if (! (*i)->hasTag ("?"))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes.push_back (*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Recursively scan all nodes, depth first, skipping terminated nodes, and known
|
// Recursively scan all nodes, depth first, skipping terminated nodes, and known
|
||||||
// nodes, and cal the callback function for each node.
|
// nodes, and cal the callback function for each node.
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
bool exactMatch (const std::string&, const std::string&) const;
|
bool exactMatch (const std::string&, const std::string&) const;
|
||||||
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
||||||
|
|
||||||
|
void collect (std::vector <Tree*>&, bool, Tree* tree = NULL);
|
||||||
|
|
||||||
void findBinary ();
|
void findBinary ();
|
||||||
void resolveAliases ();
|
void resolveAliases ();
|
||||||
void findOverrides ();
|
void findOverrides ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue