- Modified ::findAttribute to use collect.
This commit is contained in:
Paul Beckingham 2014-08-17 12:28:40 -04:00
parent ed07e47135
commit 56ab8e7920
2 changed files with 72 additions and 60 deletions

View file

@ -181,8 +181,8 @@ Tree* Parser::parse ()
findSubstitution ();
findPattern ();
findTag ();
findAttribute ();
// GOOD ^^^
scan (&Parser::findAttribute);
scan (&Parser::findAttributeModifier);
scan (&Parser::findOperator);
findCommand ();
@ -958,12 +958,17 @@ void Parser::findTag ()
////////////////////////////////////////////////////////////////////////////////
// <name>:['"][<value>]['"]
void Parser::findAttribute (Tree* t)
void Parser::findAttribute ()
{
context.debug ("findAttribute");
context.debug (t->dump ());
context.debug ("Parser::findAttribute");
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);
// Look for a valid attribute name.
@ -985,39 +990,41 @@ void Parser::findAttribute (Tree* t)
std::string canonical;
if (canonicalize (canonical, "uda", name))
{
t->tag ("UDA");
t->tag ("MODIFIABLE");
(*i)->tag ("UDA");
(*i)->tag ("MODIFIABLE");
action = true;
}
else if (canonicalize (canonical, "pseudo", name))
{
t->unTag ("?");
t->removeAllBranches ();
t->tag ("PSEUDO");
t->attribute ("name", canonical);
t->attribute ("raw", value);
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("PSEUDO");
(*i)->attribute ("name", canonical);
(*i)->attribute ("raw", value);
action = true;
}
else if (canonicalize (canonical, "attribute", name))
{
t->unTag ("?");
t->removeAllBranches ();
t->tag ("ATTRIBUTE");
t->attribute ("name", canonical);
t->attribute ("raw", value);
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("ATTRIBUTE");
(*i)->attribute ("name", canonical);
(*i)->attribute ("raw", value);
std::map <std::string, Column*>::const_iterator col;
col = context.columns.find (canonical);
if (col != context.columns.end () &&
col->second->modifiable ())
{
t->tag ("MODIFIABLE");
(*i)->tag ("MODIFIABLE");
}
Tree* branch = t->addBranch (new Tree ("argAtt"));
Tree* branch = (*i)->addBranch (new Tree ("argAtt"));
branch->attribute ("raw", canonical);
branch = t->addBranch (new Tree ("argAtt"));
branch = (*i)->addBranch (new Tree ("argAtt"));
branch->tag ("OP");
// All 'project' attributes are partial matches.
@ -1027,14 +1034,19 @@ void Parser::findAttribute (Tree* t)
else
branch->attribute ("raw", "==");
branch = t->addBranch (new Tree ("argAtt"));
branch = (*i)->addBranch (new Tree ("argAtt"));
branch->attribute ("raw", value);
action = true;
}
}
}
}
}
if (action)
context.debug (_tree->dump ());
}
////////////////////////////////////////////////////////////////////////////////
// <name>.<mod>[:=]['"]<value>['"]
void Parser::findAttributeModifier (Tree* t)

View file

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