mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Parser
- Modified ::scan to be recursive, which will now allow arbitrary parse tree depth.
This commit is contained in:
parent
3145134953
commit
7848b9284d
2 changed files with 10 additions and 19 deletions
|
@ -270,33 +270,24 @@ bool Parser::canonicalize (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Experimental method to iterate over nodes, and callback, which is essentially
|
||||
// a co-routine implementation.
|
||||
void Parser::scan (void (Parser::*callback) (Tree*))
|
||||
// Recursively scan all nodes, depth first, skipping terminated nodes, and known
|
||||
// nodes, and cal the callback function for each node.
|
||||
void Parser::scan (void (Parser::*callback) (Tree*), Tree* tree /* = NULL */)
|
||||
{
|
||||
if (tree == NULL)
|
||||
tree = _tree;
|
||||
|
||||
std::vector <Tree*>::iterator i;
|
||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++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);
|
||||
}
|
||||
scan (callback, *i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parser override operator.
|
||||
if ((*i)->attribute ("raw") == "--")
|
||||
if ((*i)->hasTag ("TERMINATOR"))
|
||||
break;
|
||||
|
||||
// Skip known args.
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
private:
|
||||
void findTerminator ();
|
||||
void scan (void (Parser::*callback)(Tree*));
|
||||
void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL);
|
||||
void findPattern ();
|
||||
void findSubstitution ();
|
||||
void findTag ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue