diff --git a/src/Parser.cpp b/src/Parser.cpp index 8ca062a41..d6079b579 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -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 nodes; + collect (nodes, false); std::vector ::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 ::iterator a; - if ((*i)->_branches.size ()) + std::map ::iterator a = _aliases.find ((*i)->attribute ("raw")); + if (a != _aliases.end ()) { - std::vector ::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 ()); } ////////////////////////////////////////////////////////////////////////////////