- Converted ::findTerminator to use collect.
This commit is contained in:
Paul Beckingham 2014-08-17 11:56:34 -04:00
parent b84736a05f
commit d1e38a7843
2 changed files with 34 additions and 19 deletions

View file

@ -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");
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -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*);