From 26f8d8c45d95a748bbabdb74fa1ae22e64fe384d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 8 Nov 2014 14:22:25 -0500 Subject: [PATCH] CLI - Implemented ::findStrayModifications to spot FILTER args detected before 'add' or 'log' commands, and upgrade them to MODIFICATIONs. --- src/CLI.cpp | 27 +++++++++++++++++++++++++++ src/CLI.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index 0f72f8a67..1ee6d446d 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -341,6 +341,7 @@ void CLI::analyze (bool parse /* = true */, bool strict /* = false */) findUUIDs (); insertIDExpr (); desugarTags (); + findStrayModifications (); desugarAttributes (); desugarAttributeModifiers (); desugarPatterns (); @@ -907,6 +908,32 @@ void CLI::desugarTags () } } +//////////////////////////////////////////////////////////////////////////////// +void CLI::findStrayModifications () +{ + bool changes = false; + + std::string command = getCommand (); + if (command == "add" || + command == "log") + { + std::vector ::iterator a; + for (a = _args.begin (); a != _args.end (); ++a) + { + if (a->hasTag ("FILTER")) + { + a->unTag ("FILTER"); + a->tag ("MODIFICATION"); + changes = true; + } + } + } + + if (changes) + if (context.config.getInteger ("debug.parser") >= 3) + context.debug (context.cli.dump ("CLI::analyze findStrayModifications")); +} + //////////////////////////////////////////////////////////////////////////////// // :['"][]['"] --> name = value void CLI::desugarAttributes () diff --git a/src/CLI.h b/src/CLI.h index 20df68978..68987c695 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -93,6 +93,7 @@ private: void categorize (); bool exactMatch (const std::string&, const std::string&) const; void desugarTags (); + void findStrayModifications (); void desugarAttributes (); void desugarAttributeModifiers (); void desugarPatterns ();