From 3cd150f28940f4fef23d8877d6585da7a86978cb Mon Sep 17 00:00:00 2001 From: djcb Date: Sat, 4 Nov 2017 12:59:48 +0200 Subject: [PATCH] parser: handle implicit 'and not' --- lib/parser/parser.cc | 3 +++ lib/parser/test-parser.cc | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/parser/parser.cc b/lib/parser/parser.cc index cdb6f55f..78413f1f 100644 --- a/lib/parser/parser.cc +++ b/lib/parser/parser.cc @@ -239,10 +239,13 @@ factor_2 (Mux::Tokens& tokens, Node::Type& op, ProcPtr proc, tokens.pop_front(); op = Node::Type::OpAnd; } break; + case Token::Type::Open: case Token::Type::Data: + case Token::Type::Not: op = Node::Type::OpAnd; // implicit AND break; + default: return empty(); } diff --git a/lib/parser/test-parser.cc b/lib/parser/test-parser.cc index e0e144d7..5fe5e0a0 100644 --- a/lib/parser/test-parser.cc +++ b/lib/parser/test-parser.cc @@ -84,8 +84,9 @@ test_complex () { "foo and bar or cuux", R"#((or(and(value "" "foo")(value "" "bar")))#" + std::string(R"#((value "" "cuux")))#") }, + { "a and not b", - R"#((andnot(value "" "a")(value "" "b")))#" + R"#((and(value "" "a")(not(value "" "b"))))#" }, { "a and b and c", R"#((and(value "" "a")(and(value "" "b")(value "" "c"))))#" @@ -97,7 +98,7 @@ test_complex () R"#((and(value "" "a")(value "" "b")))#" }, { "a not b", // implicit and not - R"#((andnot(value "" "a")(value "" "b")))#" + R"#((and(value "" "a")(not(value "" "b"))))#" }, { "not b", // implicit and not R"#((not(value "" "b")))#"