CLI2: Plain arg detection was failing if the arg was the last arg

This commit is contained in:
Paul Beckingham
2015-08-02 11:17:05 -04:00
parent d9fc334098
commit 0c85725a4c

View File

@@ -1673,6 +1673,27 @@ void CLI2::desugarFilterPlainArgs ()
prev = &a;
}
// Cover the case where the *last* argument is a plain arg.
auto& penultimate = _args[_args.size () - 2];
auto praw = penultimate.attribute ("raw");
auto& last = _args[_args.size () - 1];
if ((penultimate._lextype != Lexer::Type::op || // argX
praw == "(" ||
praw == ")" ||
praw == "and" ||
praw == "or" ||
praw == "xor") &&
(last._lextype == Lexer::Type::identifier || // candidate
last._lextype == Lexer::Type::word) && // candidate
last.hasTag ("FILTER") && // candidate
! last.hasTag ("PSEUDO")) // non-candidate
{
last.tag ("PLAIN");
}
// Walk the list again, upgrading PLAIN args.
bool changes = false;
std::vector <A2> reconstructed;