diff --git a/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 b/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 index 56469956..8d6dc5f4 100644 --- a/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 +++ b/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 @@ -7,10 +7,10 @@ expression | expression bracketSpecifier # bracketedExpression | bracketSpecifier # bracketExpression | expression COMPARATOR expression # comparisonExpression + | '!' expression # notExpression | expression '&&' expression # andExpression | expression '||' expression # orExpression | identifier # identifierExpression - | '!' expression # notExpression | '(' expression ')' # parenExpression | wildcard # wildcardExpression | multiSelectList # multiSelectListExpression diff --git a/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java b/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java index bdfa72b3..0597b06b 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java @@ -805,6 +805,32 @@ public void bareNegatedExpression() { assertThat(actual, is(expected)); } + @Test + public void negatedBooleansTripleConjunctionExpression() { + Expression expected = And( + And( + Negate(Property("foo")), + Negate(Property("bar")) + ), + Negate(Property("buzz")) + ); + Expression actual = compile("!foo && !bar && !buzz"); + assertThat(actual, is(expected)); + } + + @Test + public void negatedBooleansTripleDisjunctionExpression() { + Expression expected = Or( + Or( + Negate(Property("foo")), + Negate(Property("bar")) + ), + Negate(Property("buzz")) + ); + Expression actual = compile("!foo || !bar || !buzz"); + assertThat(actual, is(expected)); + } + @Test public void negatedSelectionExpression() { Expression expected = Sequence(