- Modified ::findOperator to use collect.
This commit is contained in:
Paul Beckingham 2014-08-17 12:40:14 -04:00
parent a13c816919
commit ca3b5c9a4d
2 changed files with 18 additions and 14 deletions

View file

@ -25,6 +25,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <cmake.h> #include <cmake.h>
#include <algorithm>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <Context.h> #include <Context.h>
@ -183,8 +184,8 @@ Tree* Parser::parse ()
findTag (); findTag ();
findAttribute (); findAttribute ();
findAttributeModifier (); findAttributeModifier ();
findOperator ();
// GOOD ^^^ // GOOD ^^^
scan (&Parser::findOperator);
findCommand (); findCommand ();
findUUIDList (); findUUIDList ();
findIdSequence (); findIdSequence ();
@ -1484,10 +1485,10 @@ void Parser::findUUIDList ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Parser::findOperator (Tree* t) void Parser::findOperator ()
{ {
context.debug ("findOperator"); context.debug ("Parser::findOperator");
context.debug (t->dump ()); bool action = false;
// Find the category. // Find the category.
std::pair <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c; std::pair <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c;
@ -1499,19 +1500,22 @@ void Parser::findOperator (Tree* t)
for (e = c.first; e != c.second; ++e) for (e = c.first; e != c.second; ++e)
options.push_back (e->second); options.push_back (e->second);
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)
{
if (std::find (options.begin (), options.end (), (*i)->attribute ("raw")) != options.end ())
{
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("OP");
action = true;
}
}
std::vector <std::string>::iterator opt; if (action)
for (opt = options.begin (); opt != options.end (); ++opt) context.debug (_tree->dump ());
{
if (*opt == raw)
{
t->unTag ("?");
t->removeAllBranches ();
t->tag ("OP");
break;
}
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -77,7 +77,7 @@ private:
void findTag (); void findTag ();
void findAttribute (); void findAttribute ();
void findAttributeModifier (); void findAttributeModifier ();
void findOperator (Tree*); void findOperator ();
void findFilter (); void findFilter ();
void findModifications (); void findModifications ();
void findStrayModifications (); void findStrayModifications ();