From b5b90a0673e1be1f7171780deb04e31a7824b973 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 19 Sep 2023 22:11:18 +0300 Subject: [PATCH] query-parser: 'not' should take units NOT should bind more tightly. --- lib/mu-query-parser.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mu-query-parser.cc b/lib/mu-query-parser.cc index 3af828d2..50a07f48 100644 --- a/lib/mu-query-parser.cc +++ b/lib/mu-query-parser.cc @@ -174,7 +174,7 @@ unit(Sexp& tokens, ParseContext& ctx) { if (tokens.head_symbolp(not_sym)) { /* NOT */ tokens.pop_front(); - Sexp sub{query(tokens, ctx)}; + Sexp sub{unit(tokens, ctx)}; /* special case: interpret "not" as a matcher instead; */ if (sub.empty()) @@ -360,6 +360,8 @@ test_parser_basic() TestCase{R"(not)", R"((_ "not"))"}, // a and (b or c) TestCase{R"(a and (b or c))", R"((and (_ "a") (or (_ "b") (_ "c"))))"}, + // not a and not b + TestCase{R"(not a and b)", R"((and (not (_ "a")) (_ "b")))"}, // TODO: add more... };