- Converted ::findTerminator to use the recursive scanner.
This commit is contained in:
Paul Beckingham 2014-08-17 00:41:11 -04:00
parent fb32b160b8
commit 3c612a8551
2 changed files with 20 additions and 22 deletions

View file

@ -170,13 +170,12 @@ Tree* Parser::tree ()
Tree* Parser::parse () Tree* Parser::parse ()
{ {
findBinary (); findBinary ();
findTerminator (); scan (&Parser::findTerminator);
resolveAliases (); resolveAliases ();
findOverrides (); findOverrides ();
applyOverrides (); applyOverrides ();
findSubstitution (); findSubstitution ();
findPattern (); findPattern ();
findTag (); findTag ();
@ -331,27 +330,26 @@ 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 () void Parser::findTerminator (Tree* t)
{ {
bool found = false; // Mark the terminator.
std::vector <Tree*>::iterator i; static bool found = false;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) if (! found &&
t->attribute ("raw") == "--")
{ {
if (!found && t->unTag ("?");
(*i)->attribute ("raw") == "--") t->removeAllBranches ();
{ t->tag ("TERMINATOR");
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("TERMINATOR");
found = true; found = true;
} }
// Mark subsequent nodes.
else if (found) else if (found)
{ {
(*i)->unTag ("?"); t->unTag ("?");
(*i)->removeAllBranches (); t->removeAllBranches ();
(*i)->tag ("WORD"); t->tag ("WORD");
(*i)->tag ("TERMINATED"); t->tag ("TERMINATED");
}
} }
} }

View file

@ -68,8 +68,8 @@ public:
std::string getCommand () const; std::string getCommand () const;
private: private:
void findTerminator ();
void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL); void scan (void (Parser::*callback)(Tree*), Tree* tree = NULL);
void findTerminator (Tree*);
void findPattern (); void findPattern ();
void findSubstitution (); void findSubstitution ();
void findTag (); void findTag ();