query-parser: 'not' should take units

NOT should bind more tightly.
This commit is contained in:
Dirk-Jan C. Binnema 2023-09-19 22:11:18 +03:00
parent 5bda8c321b
commit b5b90a0673
1 changed files with 3 additions and 1 deletions

View File

@ -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...
};