From 482d378fdb54ccb9f1b284ecb85dfe34e2dd5c5c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 26 Oct 2014 11:12:22 -0400 Subject: [PATCH] CLI - Implemented ::findAttributes. --- src/CLI.cpp | 22 ++++++++++++++++++++++ src/CLI.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index c02999320..be38d90c8 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -327,6 +327,7 @@ void CLI::analyze (bool parse /* = true */) findUUIDs (); insertIDExpr (); findOperators (); + findAttributes (); insertJunctions (); desugarPlainArgs (); @@ -1346,6 +1347,27 @@ void CLI::findOperators () a->tag ("OP"); } +//////////////////////////////////////////////////////////////////////////////// +void CLI::findAttributes () +{ + // Find the category. + std::pair ::const_iterator, std::multimap ::const_iterator> c; + c = _entities.equal_range ("attribute"); + + // Extract a list of entities for category. + std::vector options; + std::multimap ::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 ::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 // "and" operator inserted between them. diff --git a/src/CLI.h b/src/CLI.h index 32a946394..aa1915c9e 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -90,6 +90,7 @@ private: void insertIDExpr (); void desugarPlainArgs (); void findOperators (); + void findAttributes (); void insertJunctions (); void decomposeModAttributes (); void decomposeModAttributeModifiers ();