CLI2: Inhibit the identification of IDs if preceeded by an operator

This commit is contained in:
Paul Beckingham 2015-06-24 20:59:27 -04:00
parent dfe6927f14
commit 9dcd52fc5b

View file

@ -1144,15 +1144,21 @@ void CLI2::desugarFilterPatterns ()
// //
void CLI2::findIDs () void CLI2::findIDs ()
{ {
bool previousArgWasAnOperator = false;
for (auto& a : _args) for (auto& a : _args)
{ {
if (a.hasTag ("FILTER")) if (a.hasTag ("FILTER"))
{ {
if (a._lextype == Lexer::Type::number) if (a._lextype == Lexer::Type::number)
{
// Skip any number that was preceded by an operator.
if (! previousArgWasAnOperator)
{ {
std::string number = a.attribute ("raw"); std::string number = a.attribute ("raw");
_id_ranges.push_back (std::pair <std::string, std::string> (number, number)); _id_ranges.push_back (std::pair <std::string, std::string> (number, number));
} }
}
else if (a._lextype == Lexer::Type::set) else if (a._lextype == Lexer::Type::set)
{ {
// Split the ID list into elements. // Split the ID list into elements.
@ -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 () 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. // 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 // Find the *first* occurence of lexer type set/number/uuid, and replace it