- 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 ()
{
context.debug ("Parse::resolveAliases");
bool something;
int safety_valve = safetyValveDefault;
do
{
something = false;
std::vector <Tree*> nodes;
collect (nodes, false);
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.
if ((*i)->attribute ("raw") == "--")
break;
std::map <std::string, std::string>::iterator a;
if ((*i)->_branches.size ())
std::map <std::string, std::string>::iterator a = _aliases.find ((*i)->attribute ("raw"));
if (a != _aliases.end ())
{
std::vector <Tree*>::iterator b;
for (b = (*i)->_branches.begin (); b != (*i)->_branches.end (); ++b)
{
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;
}
(*i)->attribute ("raw", a->second);
(*i)->tag ("ALIAS");
something = true;
}
}
}
@ -459,6 +445,9 @@ void Parser::resolveAliases ()
if (safety_valve <= 0)
context.debug (format (STRING_PARSER_ALIAS_NEST, safetyValveDefault));
if (something)
context.debug (_tree->dump ());
}
////////////////////////////////////////////////////////////////////////////////