- Modified ::findTag to perform one action and repeat, rather than attempt
  everything at once, with an invalid iterator.
This commit is contained in:
Paul Beckingham 2014-08-23 13:08:52 -04:00
parent 2ce350b3bf
commit af77e2e150

View file

@ -920,44 +920,56 @@ void Parser::findSubstitution ()
void Parser::findTag () void Parser::findTag ()
{ {
context.debug ("Parser::findTag"); context.debug ("Parser::findTag");
bool action = false; bool action = true;
std::vector <Tree*> nodes; do
collect (nodes);
std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
std::string raw = (*i)->attribute ("raw"); action = false;
Nibbler n (raw); std::vector <Tree*> nodes;
collect (nodes, collectAll);
std::string tag; std::vector <Tree*>::iterator i;
std::string sign; for (i = nodes.begin (); i != nodes.end (); ++i)
if (n.getN (1, sign) &&
(sign == "+" || sign == "-") &&
n.getUntilEOS (tag) &&
tag.find (' ') == std::string::npos)
{ {
(*i)->unTag ("?"); if (! (*i)->hasTag ("?"))
(*i)->removeAllBranches (); continue;
(*i)->tag ("TAG");
(*i)->attribute ("sign", sign);
(*i)->attribute ("tag", tag);
Tree* branch = (*i)->addBranch (new Tree ("argTag")); if ((*i)->hasTag ("TERMINATOR") ||
branch->attribute ("raw", "tags"); (*i)->hasTag ("TERMINATED"))
break;
branch = (*i)->addBranch (new Tree ("argTag")); std::string raw = (*i)->attribute ("raw");
branch->attribute ("raw", (sign == "+" ? "_hastag_" : "_notag_")); Nibbler n (raw);
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argTag")); std::string tag;
branch->attribute ("raw", tag); std::string sign;
action = true; if (n.getN (1, sign) &&
(sign == "+" || sign == "-") &&
n.getUntilEOS (tag) &&
tag.find (' ') == std::string::npos)
{
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("TAG");
(*i)->attribute ("sign", sign);
(*i)->attribute ("tag", tag);
Tree* branch = (*i)->addBranch (new Tree ("argTag"));
branch->attribute ("raw", "tags");
branch = (*i)->addBranch (new Tree ("argTag"));
branch->attribute ("raw", (sign == "+" ? "_hastag_" : "_notag_"));
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argTag"));
branch->attribute ("raw", tag);
action = true;
break;
}
} }
} }
while (action);
if (action) context.debug (_tree->dump ());
context.debug (_tree->dump ());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////