- ::findPattern was performing the wrong scan, and needed branch pruning outside
  the iterator loop.
This commit is contained in:
Paul Beckingham 2014-08-24 16:09:30 -04:00
parent ce7f6b6492
commit 8b904a57f4

View file

@ -805,43 +805,43 @@ std::string Parser::getCommand () const
// /pattern/ --> description ~ pattern // /pattern/ --> description ~ pattern
void Parser::findPattern () void Parser::findPattern ()
{ {
// context.debug ("Parser::findPattern"); bool action = true;
do
std::vector <Tree*> prune;
std::vector <Tree*> nodes;
collect (nodes, collectAll);
std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
Nibbler n ((*i)->attribute ("raw")); action = false;
std::string pattern;
if (n.getQuoted ('/', pattern) && std::vector <Tree*> prune;
n.depleted () && std::vector <Tree*> nodes;
pattern.length () > 0) collect (nodes);
std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
(*i)->unTag ("?"); Nibbler n ((*i)->attribute ("raw"));
(*i)->tag ("PATTERN"); std::string pattern;
prune.push_back (*i); if (n.getQuoted ('/', pattern) &&
n.depleted () &&
pattern.length () > 0)
{
(*i)->unTag ("?");
(*i)->tag ("PATTERN");
(*i)->removeAllBranches ();
Tree* branch = (*i)->addBranch (new Tree ("argPat")); Tree* branch = (*i)->addBranch (new Tree ("argPat"));
branch->attribute ("raw", "description"); branch->attribute ("raw", "description");
branch = (*i)->addBranch (new Tree ("argPat")); branch = (*i)->addBranch (new Tree ("argPat"));
branch->attribute ("raw", "~"); branch->attribute ("raw", "~");
branch->tag ("OP"); branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argPat")); branch = (*i)->addBranch (new Tree ("argPat"));
branch->attribute ("raw", pattern); branch->attribute ("raw", pattern);
branch->tag ("STRING"); branch->tag ("STRING");
action = true;
break;
}
} }
} }
while (action);
// Prune branches outside the loop.
for (i = prune.begin (); i != prune.end (); ++i)
(*i)->removeAllBranches ();
// if (prune.size ())
// context.debug (_tree->dump ());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////