From ca3b5c9a4d369d6705cd2394da95044d2f71cfd9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 Aug 2014 12:40:14 -0400 Subject: [PATCH] Parser - Modified ::findOperator to use collect. --- src/Parser.cpp | 30 +++++++++++++++++------------- src/Parser.h | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index adc5a33db..542752917 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -25,6 +25,7 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -183,8 +184,8 @@ Tree* Parser::parse () findTag (); findAttribute (); findAttributeModifier (); + findOperator (); // GOOD ^^^ - scan (&Parser::findOperator); findCommand (); findUUIDList (); findIdSequence (); @@ -1484,10 +1485,10 @@ void Parser::findUUIDList () } //////////////////////////////////////////////////////////////////////////////// -void Parser::findOperator (Tree* t) +void Parser::findOperator () { - context.debug ("findOperator"); - context.debug (t->dump ()); + context.debug ("Parser::findOperator"); + bool action = false; // Find the category. std::pair ::const_iterator, std::multimap ::const_iterator> c; @@ -1499,19 +1500,22 @@ void Parser::findOperator (Tree* t) for (e = c.first; e != c.second; ++e) options.push_back (e->second); - std::string raw = t->attribute ("raw"); - - std::vector ::iterator opt; - for (opt = options.begin (); opt != options.end (); ++opt) + std::vector nodes; + collect (nodes, false); + std::vector ::iterator i; + for (i = nodes.begin (); i != nodes.end (); ++i) { - if (*opt == raw) + if (std::find (options.begin (), options.end (), (*i)->attribute ("raw")) != options.end ()) { - t->unTag ("?"); - t->removeAllBranches (); - t->tag ("OP"); - break; + (*i)->unTag ("?"); + (*i)->removeAllBranches (); + (*i)->tag ("OP"); + action = true; } } + + if (action) + context.debug (_tree->dump ()); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Parser.h b/src/Parser.h index 6493247ac..7328caf9e 100644 --- a/src/Parser.h +++ b/src/Parser.h @@ -77,7 +77,7 @@ private: void findTag (); void findAttribute (); void findAttributeModifier (); - void findOperator (Tree*); + void findOperator (); void findFilter (); void findModifications (); void findStrayModifications ();