mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Implemented ::scan, which iterates over parse tree nodes and calls back. This method skips parent nodes, terminated nodes, and nodes without the '?' tag.
This commit is contained in:
parent
1a17aac77b
commit
314ac28a0f
2 changed files with 40 additions and 0 deletions
|
@ -269,6 +269,45 @@ bool Parser::canonicalize (
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Experimental method to iterate over nodes, and callback, which is essentially
|
||||
// a co-routine implementation.
|
||||
void Parser::scan (void (Parser::*callback) (Tree*))
|
||||
{
|
||||
std::vector <Tree*>::iterator i;
|
||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||
{
|
||||
if ((*i)->_branches.size ())
|
||||
{
|
||||
std::vector <Tree*>::iterator b;
|
||||
for (b = (*i)->_branches.begin (); b != (*i)->_branches.end (); ++b)
|
||||
{
|
||||
// Parser override operator.
|
||||
if ((*b)->attribute ("raw") == "--")
|
||||
break;
|
||||
|
||||
// Skip known args.
|
||||
if (! (*b)->hasTag ("?"))
|
||||
continue;
|
||||
|
||||
(this->*callback) (*b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parser override operator.
|
||||
if ((*i)->attribute ("raw") == "--")
|
||||
break;
|
||||
|
||||
// Skip known args.
|
||||
if (! (*i)->hasTag ("?"))
|
||||
continue;
|
||||
|
||||
(this->*callback) (*i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Locate and tag the binary.
|
||||
void Parser::findBinary ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue