parser: handle implicit 'and not'

This commit is contained in:
djcb 2017-11-04 12:59:48 +02:00
parent 40dd4751bf
commit 3cd150f289
2 changed files with 6 additions and 2 deletions

View File

@ -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();
}

View File

@ -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")))#"