diff --git a/src/parser/A3t.cpp b/src/parser/A3t.cpp index ad7a445ef..b03a9561a 100644 --- a/src/parser/A3t.cpp +++ b/src/parser/A3t.cpp @@ -71,6 +71,7 @@ Tree* A3t::parse () findAttributeModifier (); findUUIDList (); // Before findIdSequence findIdSequence (); + findOperator (); validate (); @@ -611,6 +612,45 @@ void A3t::findUUIDList () } } +//////////////////////////////////////////////////////////////////////////////// +void A3t::findOperator () +{ + // Find the category. + std::pair ::const_iterator, std::multimap ::const_iterator> c; + c = _entities.equal_range ("operator"); + + // 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); + + std::vector ::iterator i; + for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) + { + // Parser override operator. + if ((*i)->attribute ("raw") == "--") + break; + + // Skip known args. + if (! (*i)->hasTag ("?")) + continue; + + std::string raw = (*i)->attribute ("raw"); + + std::vector ::iterator opt; + for (opt = options.begin (); opt != options.end (); ++opt) + { + if (*opt == raw) + { + (*i)->unTag ("?"); + (*i)->tag ("OP"); + break; + } + } + } +} + //////////////////////////////////////////////////////////////////////////////// // Validate the parse tree. void A3t::validate () diff --git a/src/parser/A3t.h b/src/parser/A3t.h index bac5293d6..2fa8bda28 100644 --- a/src/parser/A3t.h +++ b/src/parser/A3t.h @@ -53,6 +53,7 @@ private: void findAttributeModifier (); void findIdSequence (); void findUUIDList (); + void findOperator (); void validate (); private: diff --git a/src/parser/args.cpp b/src/parser/args.cpp index ca8ea4671..af1af0e43 100644 --- a/src/parser/args.cpp +++ b/src/parser/args.cpp @@ -108,6 +108,29 @@ int main (int argc, char** argv) a3t.identity ("modifier", "word"); a3t.identity ("modifier", "noword"); + // Operators. + a3t.identity ("operator", "and"); + a3t.identity ("operator", "or"); + a3t.identity ("operator", "xor"); + a3t.identity ("operator", "<="); + a3t.identity ("operator", ">="); + a3t.identity ("operator", "!~"); + a3t.identity ("operator", "!="); + a3t.identity ("operator", "="); + a3t.identity ("operator", ">"); + a3t.identity ("operator", "~"); + a3t.identity ("operator", "!"); + a3t.identity ("operator", "_hastag_"); + a3t.identity ("operator", "_notag_"); + a3t.identity ("operator", "-"); + a3t.identity ("operator", "*"); + a3t.identity ("operator", "/"); + a3t.identity ("operator", "+"); + a3t.identity ("operator", "-"); + a3t.identity ("operator", "<"); + a3t.identity ("operator", "("); + a3t.identity ("operator", ")"); + Tree* tree = a3t.parse (); if (tree) tree->dump ();