From 694323a8f1fd5a535efec5de7f9890ba02ea7fc9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 12 Jul 2015 17:57:52 -0400 Subject: [PATCH] CLI2: Implemented ::lexFilterArgs - Now spots filter elements that need to be Lexed. --- src/CLI2.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/CLI2.h | 1 + 2 files changed, 39 insertions(+) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index a71e7317d..bd5872dbc 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -650,6 +650,7 @@ void CLI2::prepareFilter (bool applyContext) context.debug (dump ("CLI2::prepareFilter categorize")); // Remove all the syntactic sugar for FILTERs. + lexFilterArgs (); findIDs (); findUUIDs (); insertIDExpr (); @@ -1523,6 +1524,43 @@ void CLI2::insertIDExpr () } } +//////////////////////////////////////////////////////////////////////////////// +// FILTER Lexer::Type::word args will become part of an expression, and so they +// need to be Lexed. +void CLI2::lexFilterArgs () +{ + bool changes = false; + std::vector reconstructed; + for (auto& a : _args) + { + if (a._lextype == Lexer::Type::word && + a.hasTag ("FILTER")) + { + changes = true; + + std::string lexeme; + Lexer::Type type; + Lexer lex (a.attribute ("raw")); + while (lex.token (lexeme, type)) + { + A2 extra (lexeme, type); + extra.tag ("FILTER"); + reconstructed.push_back (extra); + } + } + else + reconstructed.push_back (a); + } + + if (changes) + { + _args = reconstructed; + + if (context.config.getInteger ("debug.parser") >= 3) + context.debug (dump ("CLI2::prepareFilter lexFilterArgs")); + } +} + //////////////////////////////////////////////////////////////////////////////// // FILTER, Lexer::Type::word args are treated as search terms. // diff --git a/src/CLI2.h b/src/CLI2.h index 472b40570..99d17e521 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -101,6 +101,7 @@ private: void findIDs (); void findUUIDs (); void insertIDExpr (); + void lexFilterArgs (); void desugarFilterPlainArgs (); void insertJunctions (); void defaultCommand ();