- Modified ::findTag to use collect.
This commit is contained in:
Paul Beckingham 2014-08-17 12:25:08 -04:00
parent 6dd359e900
commit ed07e47135
2 changed files with 36 additions and 26 deletions

View file

@ -180,8 +180,8 @@ Tree* Parser::parse ()
findSubstitution (); findSubstitution ();
findPattern (); findPattern ();
findTag ();
// GOOD ^^^ // GOOD ^^^
scan (&Parser::findTag);
scan (&Parser::findAttribute); scan (&Parser::findAttribute);
scan (&Parser::findAttributeModifier); scan (&Parser::findAttributeModifier);
scan (&Parser::findOperator); scan (&Parser::findOperator);
@ -913,12 +913,17 @@ void Parser::findSubstitution ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// +tag // +tag
void Parser::findTag (Tree* t) void Parser::findTag ()
{ {
context.debug ("findTag"); context.debug ("Parser::findTag");
context.debug (t->dump ()); bool action = false;
std::string raw = t->attribute ("raw"); std::vector <Tree*> nodes;
collect (nodes, false);
std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i)
{
std::string raw = (*i)->attribute ("raw");
Nibbler n (raw); Nibbler n (raw);
std::string tag; std::string tag;
@ -928,24 +933,29 @@ void Parser::findTag (Tree* t)
n.getUntilEOS (tag) && n.getUntilEOS (tag) &&
tag.find (' ') == std::string::npos) tag.find (' ') == std::string::npos)
{ {
t->unTag ("?"); (*i)->unTag ("?");
t->removeAllBranches (); (*i)->removeAllBranches ();
t->tag ("TAG"); (*i)->tag ("TAG");
t->attribute ("sign", sign); (*i)->attribute ("sign", sign);
t->attribute ("tag", tag); (*i)->attribute ("tag", tag);
Tree* branch = t->addBranch (new Tree ("argTag")); Tree* branch = (*i)->addBranch (new Tree ("argTag"));
branch->attribute ("raw", "tags"); branch->attribute ("raw", "tags");
branch = t->addBranch (new Tree ("argTag")); branch = (*i)->addBranch (new Tree ("argTag"));
branch->attribute ("raw", (sign == "+" ? "_hastag_" : "_notag_")); branch->attribute ("raw", (sign == "+" ? "_hastag_" : "_notag_"));
branch->tag ("OP"); branch->tag ("OP");
branch = t->addBranch (new Tree ("argTag")); branch = (*i)->addBranch (new Tree ("argTag"));
branch->attribute ("raw", tag); branch->attribute ("raw", tag);
action = true;
} }
} }
if (action)
context.debug (_tree->dump ());
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// <name>:['"][<value>]['"] // <name>:['"][<value>]['"]
void Parser::findAttribute (Tree* t) void Parser::findAttribute (Tree* t)

View file

@ -74,7 +74,7 @@ private:
void findTerminator (); void findTerminator ();
void findPattern (); void findPattern ();
void findSubstitution (); void findSubstitution ();
void findTag (Tree*); void findTag ();
void findAttribute (Tree*); void findAttribute (Tree*);
void findAttributeModifier (Tree*); void findAttributeModifier (Tree*);
void findOperator (Tree*); void findOperator (Tree*);