mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-03 07:07:19 +02:00
Parser
- Converted ::findTerminator to use collect.
This commit is contained in:
parent
b84736a05f
commit
d1e38a7843
2 changed files with 34 additions and 19 deletions
|
@ -172,7 +172,8 @@ Tree* Parser::tree ()
|
||||||
Tree* Parser::parse ()
|
Tree* Parser::parse ()
|
||||||
{
|
{
|
||||||
findBinary ();
|
findBinary ();
|
||||||
scan (&Parser::findTerminator);
|
findTerminator ();
|
||||||
|
// GOOD ^^^
|
||||||
resolveAliases ();
|
resolveAliases ();
|
||||||
|
|
||||||
findOverrides ();
|
findOverrides ();
|
||||||
|
@ -368,27 +369,41 @@ void Parser::findBinary ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// The parser override operator terminates all subsequent cleverness, leaving
|
// The parser override operator terminates all subsequent cleverness, leaving
|
||||||
// all args in the raw state.
|
// all args in the raw state.
|
||||||
void Parser::findTerminator (Tree* t)
|
void Parser::findTerminator ()
|
||||||
{
|
{
|
||||||
// Mark the terminator.
|
context.debug ("Parser::findTerminator");
|
||||||
static bool found = false;
|
bool found = false;
|
||||||
if (! found &&
|
bool action = false;
|
||||||
t->attribute ("raw") == "--")
|
|
||||||
|
std::vector <Tree*> nodes;
|
||||||
|
collect (nodes, false);
|
||||||
|
std::vector <Tree*>::iterator i;
|
||||||
|
for (i = nodes.begin (); i != nodes.end (); ++i)
|
||||||
{
|
{
|
||||||
t->unTag ("?");
|
// Mark the terminator.
|
||||||
t->removeAllBranches ();
|
if (! found &&
|
||||||
t->tag ("TERMINATOR");
|
(*i)->attribute ("raw") == "--")
|
||||||
found = true;
|
{
|
||||||
|
(*i)->unTag ("?");
|
||||||
|
(*i)->removeAllBranches ();
|
||||||
|
(*i)->tag ("TERMINATOR");
|
||||||
|
found = true;
|
||||||
|
action = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark subsequent nodes.
|
||||||
|
else if (found)
|
||||||
|
{
|
||||||
|
(*i)->unTag ("?");
|
||||||
|
(*i)->removeAllBranches ();
|
||||||
|
(*i)->tag ("WORD");
|
||||||
|
(*i)->tag ("TERMINATED");
|
||||||
|
action = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark subsequent nodes.
|
if (action)
|
||||||
else if (found)
|
context.debug (_tree->dump ());
|
||||||
{
|
|
||||||
t->unTag ("?");
|
|
||||||
t->removeAllBranches ();
|
|
||||||
t->tag ("WORD");
|
|
||||||
t->tag ("TERMINATED");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL);
|
void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL);
|
||||||
void findTerminator (Tree*);
|
void findTerminator ();
|
||||||
void findPattern (Tree*);
|
void findPattern (Tree*);
|
||||||
void findSubstitution (Tree*);
|
void findSubstitution (Tree*);
|
||||||
void findTag (Tree*);
|
void findTag (Tree*);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue