- Converted ::findAttribute to use recusive ::scan.
This commit is contained in:
Paul Beckingham 2014-08-17 01:04:08 -04:00
parent 3a8d42dae7
commit 989c503446
2 changed files with 61 additions and 70 deletions

View file

@ -181,7 +181,7 @@ Tree* Parser::parse ()
findSubstitution ();
findPattern ();
findTag ();
findAttribute ();
scan (&Parser::findAttribute);
scan (&Parser::findAttributeModifier);
findOperator ();
findCommand ();
@ -910,20 +910,12 @@ void Parser::findTag ()
////////////////////////////////////////////////////////////////////////////////
// <name>:['"][<value>]['"]
void Parser::findAttribute ()
void Parser::findAttribute (Tree* t)
{
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
// Parser override operator.
if ((*i)->attribute ("raw") == "--")
break;
context.debug ("findAttribute");
context.debug (t->dump ());
// Skip known args.
if (! (*i)->hasTag ("?"))
continue;
std::string raw = (*i)->attribute ("raw");
std::string raw = t->attribute ("raw");
Nibbler n (raw);
// Look for a valid attribute name.
@ -945,39 +937,39 @@ void Parser::findAttribute ()
std::string canonical;
if (canonicalize (canonical, "uda", name))
{
(*i)->tag ("UDA");
(*i)->tag ("MODIFIABLE");
t->tag ("UDA");
t->tag ("MODIFIABLE");
}
else if (canonicalize (canonical, "pseudo", name))
{
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("PSEUDO");
(*i)->attribute ("name", canonical);
(*i)->attribute ("raw", value);
t->unTag ("?");
t->removeAllBranches ();
t->tag ("PSEUDO");
t->attribute ("name", canonical);
t->attribute ("raw", value);
}
else if (canonicalize (canonical, "attribute", name))
{
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("ATTRIBUTE");
(*i)->attribute ("name", canonical);
(*i)->attribute ("raw", value);
t->unTag ("?");
t->removeAllBranches ();
t->tag ("ATTRIBUTE");
t->attribute ("name", canonical);
t->attribute ("raw", value);
std::map <std::string, Column*>::const_iterator col;
col = context.columns.find (canonical);
if (col != context.columns.end () &&
col->second->modifiable ())
{
(*i)->tag ("MODIFIABLE");
t->tag ("MODIFIABLE");
}
Tree* branch = (*i)->addBranch (new Tree ("argAtt"));
Tree* branch = t->addBranch (new Tree ("argAtt"));
branch->attribute ("raw", canonical);
branch = (*i)->addBranch (new Tree ("argAtt"));
branch = t->addBranch (new Tree ("argAtt"));
branch->tag ("OP");
// All 'project' attributes are partial matches.
@ -987,14 +979,13 @@ void Parser::findAttribute ()
else
branch->attribute ("raw", "==");
branch = (*i)->addBranch (new Tree ("argAtt"));
branch = t->addBranch (new Tree ("argAtt"));
branch->attribute ("raw", value);
}
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
// <name>.<mod>[:=]['"]<value>['"]

View file

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