- Modified ::resolveAliases to use collect.
This commit is contained in:
Paul Beckingham 2014-08-17 12:11:35 -04:00
parent 4645bbc85d
commit bbff0123b0

View file

@ -412,46 +412,32 @@ void Parser::findTerminator ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TODO This is not recusive, and needs to be.
void Parser::resolveAliases () void Parser::resolveAliases ()
{ {
context.debug ("Parse::resolveAliases");
bool something; bool something;
int safety_valve = safetyValveDefault; int safety_valve = safetyValveDefault;
do do
{ {
something = false; something = false;
std::vector <Tree*> nodes;
collect (nodes, false);
std::vector <Tree*>::iterator i; std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
// Parser override operator. // Parser override operator.
if ((*i)->attribute ("raw") == "--") if ((*i)->attribute ("raw") == "--")
break; break;
std::map <std::string, std::string>::iterator a; std::map <std::string, std::string>::iterator a = _aliases.find ((*i)->attribute ("raw"));
if ((*i)->_branches.size ()) if (a != _aliases.end ())
{ {
std::vector <Tree*>::iterator b; (*i)->attribute ("raw", a->second);
for (b = (*i)->_branches.begin (); b != (*i)->_branches.end (); ++b) (*i)->tag ("ALIAS");
{ something = true;
a = _aliases.find ((*b)->attribute ("raw"));
if (a != _aliases.end ())
{
(*b)->attribute ("raw", a->second);
(*b)->tag ("ALIAS");
something = true;
}
}
}
else
{
a = _aliases.find ((*i)->attribute ("raw"));
if (a != _aliases.end ())
{
(*i)->attribute ("raw", a->second);
(*i)->tag ("ALIAS");
something = true;
}
} }
} }
} }
@ -459,6 +445,9 @@ void Parser::resolveAliases ()
if (safety_valve <= 0) if (safety_valve <= 0)
context.debug (format (STRING_PARSER_ALIAS_NEST, safetyValveDefault)); context.debug (format (STRING_PARSER_ALIAS_NEST, safetyValveDefault));
if (something)
context.debug (_tree->dump ());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////