From 9dcd52fc5b04f226af1761531439f6c335cf79a7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 24 Jun 2015 20:59:27 -0400 Subject: [PATCH] CLI2: Inhibit the identification of IDs if preceeded by an operator --- src/CLI2.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 719ed5aea..57b831d8f 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -1144,14 +1144,20 @@ void CLI2::desugarFilterPatterns () // void CLI2::findIDs () { + bool previousArgWasAnOperator = false; + for (auto& a : _args) { if (a.hasTag ("FILTER")) { if (a._lextype == Lexer::Type::number) { - std::string number = a.attribute ("raw"); - _id_ranges.push_back (std::pair (number, number)); + // Skip any number that was preceded by an operator. + if (! previousArgWasAnOperator) + { + std::string number = a.attribute ("raw"); + _id_ranges.push_back (std::pair (number, number)); + } } else if (a._lextype == Lexer::Type::set) { @@ -1172,6 +1178,8 @@ void CLI2::findIDs () } } } + + previousArgWasAnOperator = (a._lextype == Lexer::Type::op) ? true : false; } } @@ -1255,6 +1263,12 @@ void CLI2::findUUIDs () //////////////////////////////////////////////////////////////////////////////// void CLI2::insertIDExpr () { + // Skip completely if no ID/UUID was found. This is because below, '(' and ')' + // are inserted regardless of list size. + if (! _id_ranges.size () && + ! _uuid_list.size ()) + return; + // TODO Strip out Lexer::Type::list from between Lexer::Type::uuid's. // Find the *first* occurence of lexer type set/number/uuid, and replace it