- Implemented ::findAttributes.
This commit is contained in:
Paul Beckingham 2014-10-26 11:12:22 -04:00
parent 286c378180
commit 482d378fdb
2 changed files with 23 additions and 0 deletions

View file

@ -327,6 +327,7 @@ void CLI::analyze (bool parse /* = true */)
findUUIDs (); findUUIDs ();
insertIDExpr (); insertIDExpr ();
findOperators (); findOperators ();
findAttributes ();
insertJunctions (); insertJunctions ();
desugarPlainArgs (); desugarPlainArgs ();
@ -1346,6 +1347,27 @@ void CLI::findOperators ()
a->tag ("OP"); a->tag ("OP");
} }
////////////////////////////////////////////////////////////////////////////////
void CLI::findAttributes ()
{
// Find the category.
std::pair <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c;
c = _entities.equal_range ("attribute");
// Extract a list of entities for category.
std::vector <std::string> options;
std::multimap <std::string, std::string>::const_iterator e;
for (e = c.first; e != c.second; ++e)
options.push_back (e->second);
// Walk the arguments and tag as OP.
std::vector <A>::iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
if (a->hasTag ("FILTER"))
if (std::find (options.begin (), options.end (), a->attribute ("raw")) != options.end ())
a->tag ("ATTRIBUTE");
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an // Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an
// "and" operator inserted between them. // "and" operator inserted between them.

View file

@ -90,6 +90,7 @@ private:
void insertIDExpr (); void insertIDExpr ();
void desugarPlainArgs (); void desugarPlainArgs ();
void findOperators (); void findOperators ();
void findAttributes ();
void insertJunctions (); void insertJunctions ();
void decomposeModAttributes (); void decomposeModAttributes ();
void decomposeModAttributeModifiers (); void decomposeModAttributeModifiers ();