From a780bd01936abce1f0228e737ba5317211e22dad Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 25 Oct 2014 16:15:31 -0400 Subject: [PATCH] CLI - Implemented ::desugarPlainArgs to upgrade WORD to PATTERN when found in a FILTER context. --- src/CLI.cpp | 35 +++++++++++++++++++++++++++++++++++ src/CLI.h | 1 + 2 files changed, 36 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index 016e772f6..74998b398 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -318,6 +318,7 @@ void CLI::analyze () desugarPatterns (); desugarIDs (); desugarUUIDs (); + //desugarPlainArgs (); findOperators (); insertJunctions (); @@ -1250,6 +1251,40 @@ void CLI::desugarUUIDs () _args = reconstructed; } +//////////////////////////////////////////////////////////////////////////////// +void CLI::desugarPlainArgs () +{ + std::vector reconstructed; + std::vector ::iterator a; + for (a = _args.begin (); a != _args.end (); ++a) + { + if (a->hasTag ("FILTER") && + ! a->hasTag ("ATTRIBUTE") && + ! a->hasTag ("OP") && + ! a->hasTag ("LITERAL")) + { + A lhs ("argPattern", "description"); + lhs.tag ("ATTRIBUTE"); + lhs.tag ("FILTER"); + reconstructed.push_back (lhs); + + A op ("argPattern", "~"); + op.tag ("OP"); + op.tag ("FILTER"); + reconstructed.push_back (op); + + A rhs ("argPattern", "'" + a->attribute ("raw") + "'"); + rhs.tag ("LITERAL"); + rhs.tag ("FILTER"); + reconstructed.push_back (rhs); + } + else + reconstructed.push_back (*a); + } + + _args = reconstructed; +} + //////////////////////////////////////////////////////////////////////////////// void CLI::findOperators () { diff --git a/src/CLI.h b/src/CLI.h index 7e8e5918f..76070721a 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -87,6 +87,7 @@ private: void desugarPatterns (); void desugarIDs (); void desugarUUIDs (); + void desugarPlainArgs (); void findOperators (); void insertJunctions (); void decomposeModAttributes ();