From ef94d9e3e626c800517aa8e56e084fcd8061f40c Mon Sep 17 00:00:00 2001 From: Nikunj Yadav Date: Tue, 24 Oct 2023 15:26:27 -0700 Subject: [PATCH] Adding spaces around query to the grammar --- parser/JsonQuery.g4 | 4 +- parser/JsonQuery.interp | 2 +- parser/gen.sh | 1 + parser/jsonquery_parser.go | 271 ++++++++++++++++++++--------------- parser/parse_logical_test.go | 49 +++++++ 5 files changed, 209 insertions(+), 118 deletions(-) create mode 100644 parser/gen.sh diff --git a/parser/JsonQuery.g4 b/parser/JsonQuery.g4 index 582be8c..b66b4ea 100644 --- a/parser/JsonQuery.g4 +++ b/parser/JsonQuery.g4 @@ -1,7 +1,7 @@ grammar JsonQuery; query - : NOT? SP? '(' query ')' #parenExp + : NOT? SP? '(' SP? query SP? ')' #parenExp | query SP LOGICAL_OPERATOR SP query #logicalExp | attrPath SP 'pr' #presentExp | attrPath SP op=( EQ | NE | GT | LT | GE | LE | CO | SW | EW | IN ) SP value #compareExp @@ -70,7 +70,7 @@ value ; VERSION - : INT '.' INT '.' INT + : INT '.' INT '.' INT ; STRING diff --git a/parser/JsonQuery.interp b/parser/JsonQuery.interp index 90b1911..5297170 100644 --- a/parser/JsonQuery.interp +++ b/parser/JsonQuery.interp @@ -78,4 +78,4 @@ subListOfInts atn: -[4, 1, 30, 108, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 1, 0, 1, 0, 3, 0, 23, 8, 0, 1, 0, 3, 0, 26, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 42, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 49, 8, 0, 10, 0, 12, 0, 52, 9, 0, 1, 1, 1, 1, 3, 1, 56, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 67, 8, 3, 1, 3, 1, 3, 3, 3, 71, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 76, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 86, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 96, 8, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 106, 8, 9, 1, 9, 0, 1, 0, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 1, 1, 0, 12, 21, 116, 0, 41, 1, 0, 0, 0, 2, 53, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 75, 1, 0, 0, 0, 8, 77, 1, 0, 0, 0, 10, 85, 1, 0, 0, 0, 12, 87, 1, 0, 0, 0, 14, 95, 1, 0, 0, 0, 16, 97, 1, 0, 0, 0, 18, 105, 1, 0, 0, 0, 20, 22, 6, 0, -1, 0, 21, 23, 5, 8, 0, 0, 22, 21, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 25, 1, 0, 0, 0, 24, 26, 5, 30, 0, 0, 25, 24, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 28, 5, 1, 0, 0, 28, 29, 3, 0, 0, 0, 29, 30, 5, 2, 0, 0, 30, 42, 1, 0, 0, 0, 31, 32, 3, 2, 1, 0, 32, 33, 5, 30, 0, 0, 33, 34, 5, 3, 0, 0, 34, 42, 1, 0, 0, 0, 35, 36, 3, 2, 1, 0, 36, 37, 5, 30, 0, 0, 37, 38, 7, 0, 0, 0, 38, 39, 5, 30, 0, 0, 39, 40, 3, 6, 3, 0, 40, 42, 1, 0, 0, 0, 41, 20, 1, 0, 0, 0, 41, 31, 1, 0, 0, 0, 41, 35, 1, 0, 0, 0, 42, 50, 1, 0, 0, 0, 43, 44, 10, 3, 0, 0, 44, 45, 5, 30, 0, 0, 45, 46, 5, 9, 0, 0, 46, 47, 5, 30, 0, 0, 47, 49, 3, 0, 0, 4, 48, 43, 1, 0, 0, 0, 49, 52, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 1, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 53, 55, 5, 22, 0, 0, 54, 56, 3, 4, 2, 0, 55, 54, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 3, 1, 0, 0, 0, 57, 58, 5, 4, 0, 0, 58, 59, 3, 2, 1, 0, 59, 5, 1, 0, 0, 0, 60, 76, 5, 10, 0, 0, 61, 76, 5, 11, 0, 0, 62, 76, 5, 23, 0, 0, 63, 76, 5, 24, 0, 0, 64, 76, 5, 25, 0, 0, 65, 67, 5, 5, 0, 0, 66, 65, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 70, 5, 26, 0, 0, 69, 71, 5, 27, 0, 0, 70, 69, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 76, 1, 0, 0, 0, 72, 76, 3, 16, 8, 0, 73, 76, 3, 12, 6, 0, 74, 76, 3, 8, 4, 0, 75, 60, 1, 0, 0, 0, 75, 61, 1, 0, 0, 0, 75, 62, 1, 0, 0, 0, 75, 63, 1, 0, 0, 0, 75, 64, 1, 0, 0, 0, 75, 66, 1, 0, 0, 0, 75, 72, 1, 0, 0, 0, 75, 73, 1, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 7, 1, 0, 0, 0, 77, 78, 5, 6, 0, 0, 78, 79, 3, 10, 5, 0, 79, 9, 1, 0, 0, 0, 80, 81, 5, 24, 0, 0, 81, 82, 5, 29, 0, 0, 82, 86, 3, 10, 5, 0, 83, 84, 5, 24, 0, 0, 84, 86, 5, 7, 0, 0, 85, 80, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 86, 11, 1, 0, 0, 0, 87, 88, 5, 6, 0, 0, 88, 89, 3, 14, 7, 0, 89, 13, 1, 0, 0, 0, 90, 91, 5, 25, 0, 0, 91, 92, 5, 29, 0, 0, 92, 96, 3, 14, 7, 0, 93, 94, 5, 25, 0, 0, 94, 96, 5, 7, 0, 0, 95, 90, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 96, 15, 1, 0, 0, 0, 97, 98, 5, 6, 0, 0, 98, 99, 3, 18, 9, 0, 99, 17, 1, 0, 0, 0, 100, 101, 5, 26, 0, 0, 101, 102, 5, 29, 0, 0, 102, 106, 3, 18, 9, 0, 103, 104, 5, 26, 0, 0, 104, 106, 5, 7, 0, 0, 105, 100, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 19, 1, 0, 0, 0, 11, 22, 25, 41, 50, 55, 66, 70, 75, 85, 95, 105] \ No newline at end of file +[4, 1, 30, 114, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 1, 0, 1, 0, 3, 0, 23, 8, 0, 1, 0, 3, 0, 26, 8, 0, 1, 0, 1, 0, 3, 0, 30, 8, 0, 1, 0, 1, 0, 3, 0, 34, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 48, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 55, 8, 0, 10, 0, 12, 0, 58, 9, 0, 1, 1, 1, 1, 3, 1, 62, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 73, 8, 3, 1, 3, 1, 3, 3, 3, 77, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 82, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 92, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 102, 8, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 112, 8, 9, 1, 9, 0, 1, 0, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 1, 1, 0, 12, 21, 124, 0, 47, 1, 0, 0, 0, 2, 59, 1, 0, 0, 0, 4, 63, 1, 0, 0, 0, 6, 81, 1, 0, 0, 0, 8, 83, 1, 0, 0, 0, 10, 91, 1, 0, 0, 0, 12, 93, 1, 0, 0, 0, 14, 101, 1, 0, 0, 0, 16, 103, 1, 0, 0, 0, 18, 111, 1, 0, 0, 0, 20, 22, 6, 0, -1, 0, 21, 23, 5, 8, 0, 0, 22, 21, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 25, 1, 0, 0, 0, 24, 26, 5, 30, 0, 0, 25, 24, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 5, 1, 0, 0, 28, 30, 5, 30, 0, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 33, 3, 0, 0, 0, 32, 34, 5, 30, 0, 0, 33, 32, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 36, 5, 2, 0, 0, 36, 48, 1, 0, 0, 0, 37, 38, 3, 2, 1, 0, 38, 39, 5, 30, 0, 0, 39, 40, 5, 3, 0, 0, 40, 48, 1, 0, 0, 0, 41, 42, 3, 2, 1, 0, 42, 43, 5, 30, 0, 0, 43, 44, 7, 0, 0, 0, 44, 45, 5, 30, 0, 0, 45, 46, 3, 6, 3, 0, 46, 48, 1, 0, 0, 0, 47, 20, 1, 0, 0, 0, 47, 37, 1, 0, 0, 0, 47, 41, 1, 0, 0, 0, 48, 56, 1, 0, 0, 0, 49, 50, 10, 3, 0, 0, 50, 51, 5, 30, 0, 0, 51, 52, 5, 9, 0, 0, 52, 53, 5, 30, 0, 0, 53, 55, 3, 0, 0, 4, 54, 49, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 1, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 61, 5, 22, 0, 0, 60, 62, 3, 4, 2, 0, 61, 60, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 3, 1, 0, 0, 0, 63, 64, 5, 4, 0, 0, 64, 65, 3, 2, 1, 0, 65, 5, 1, 0, 0, 0, 66, 82, 5, 10, 0, 0, 67, 82, 5, 11, 0, 0, 68, 82, 5, 23, 0, 0, 69, 82, 5, 24, 0, 0, 70, 82, 5, 25, 0, 0, 71, 73, 5, 5, 0, 0, 72, 71, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 76, 5, 26, 0, 0, 75, 77, 5, 27, 0, 0, 76, 75, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 82, 1, 0, 0, 0, 78, 82, 3, 16, 8, 0, 79, 82, 3, 12, 6, 0, 80, 82, 3, 8, 4, 0, 81, 66, 1, 0, 0, 0, 81, 67, 1, 0, 0, 0, 81, 68, 1, 0, 0, 0, 81, 69, 1, 0, 0, 0, 81, 70, 1, 0, 0, 0, 81, 72, 1, 0, 0, 0, 81, 78, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 80, 1, 0, 0, 0, 82, 7, 1, 0, 0, 0, 83, 84, 5, 6, 0, 0, 84, 85, 3, 10, 5, 0, 85, 9, 1, 0, 0, 0, 86, 87, 5, 24, 0, 0, 87, 88, 5, 29, 0, 0, 88, 92, 3, 10, 5, 0, 89, 90, 5, 24, 0, 0, 90, 92, 5, 7, 0, 0, 91, 86, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 11, 1, 0, 0, 0, 93, 94, 5, 6, 0, 0, 94, 95, 3, 14, 7, 0, 95, 13, 1, 0, 0, 0, 96, 97, 5, 25, 0, 0, 97, 98, 5, 29, 0, 0, 98, 102, 3, 14, 7, 0, 99, 100, 5, 25, 0, 0, 100, 102, 5, 7, 0, 0, 101, 96, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, 15, 1, 0, 0, 0, 103, 104, 5, 6, 0, 0, 104, 105, 3, 18, 9, 0, 105, 17, 1, 0, 0, 0, 106, 107, 5, 26, 0, 0, 107, 108, 5, 29, 0, 0, 108, 112, 3, 18, 9, 0, 109, 110, 5, 26, 0, 0, 110, 112, 5, 7, 0, 0, 111, 106, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 112, 19, 1, 0, 0, 0, 13, 22, 25, 29, 33, 47, 56, 61, 72, 76, 81, 91, 101, 111] \ No newline at end of file diff --git a/parser/gen.sh b/parser/gen.sh new file mode 100644 index 0000000..588a178 --- /dev/null +++ b/parser/gen.sh @@ -0,0 +1 @@ +antlr4 -Dlanguage=Go -visitor -no-listener JsonQuery.g4 -o ./ \ No newline at end of file diff --git a/parser/jsonquery_parser.go b/parser/jsonquery_parser.go index 35638a4..771c69f 100644 --- a/parser/jsonquery_parser.go +++ b/parser/jsonquery_parser.go @@ -48,51 +48,54 @@ func jsonqueryParserInit() { } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 30, 108, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 1, 30, 114, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 1, 0, 1, - 0, 3, 0, 23, 8, 0, 1, 0, 3, 0, 26, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 42, 8, 0, 1, - 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 49, 8, 0, 10, 0, 12, 0, 52, 9, 0, 1, 1, - 1, 1, 3, 1, 56, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 3, 3, 67, 8, 3, 1, 3, 1, 3, 3, 3, 71, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, - 76, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 86, 8, - 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 96, 8, 7, 1, 8, - 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 106, 8, 9, 1, 9, 0, 1, - 0, 10, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 0, 1, 1, 0, 12, 21, 116, 0, 41, - 1, 0, 0, 0, 2, 53, 1, 0, 0, 0, 4, 57, 1, 0, 0, 0, 6, 75, 1, 0, 0, 0, 8, - 77, 1, 0, 0, 0, 10, 85, 1, 0, 0, 0, 12, 87, 1, 0, 0, 0, 14, 95, 1, 0, 0, - 0, 16, 97, 1, 0, 0, 0, 18, 105, 1, 0, 0, 0, 20, 22, 6, 0, -1, 0, 21, 23, - 5, 8, 0, 0, 22, 21, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 25, 1, 0, 0, 0, - 24, 26, 5, 30, 0, 0, 25, 24, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 1, - 0, 0, 0, 27, 28, 5, 1, 0, 0, 28, 29, 3, 0, 0, 0, 29, 30, 5, 2, 0, 0, 30, - 42, 1, 0, 0, 0, 31, 32, 3, 2, 1, 0, 32, 33, 5, 30, 0, 0, 33, 34, 5, 3, - 0, 0, 34, 42, 1, 0, 0, 0, 35, 36, 3, 2, 1, 0, 36, 37, 5, 30, 0, 0, 37, - 38, 7, 0, 0, 0, 38, 39, 5, 30, 0, 0, 39, 40, 3, 6, 3, 0, 40, 42, 1, 0, - 0, 0, 41, 20, 1, 0, 0, 0, 41, 31, 1, 0, 0, 0, 41, 35, 1, 0, 0, 0, 42, 50, - 1, 0, 0, 0, 43, 44, 10, 3, 0, 0, 44, 45, 5, 30, 0, 0, 45, 46, 5, 9, 0, - 0, 46, 47, 5, 30, 0, 0, 47, 49, 3, 0, 0, 4, 48, 43, 1, 0, 0, 0, 49, 52, - 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 1, 1, 0, 0, 0, - 52, 50, 1, 0, 0, 0, 53, 55, 5, 22, 0, 0, 54, 56, 3, 4, 2, 0, 55, 54, 1, - 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 3, 1, 0, 0, 0, 57, 58, 5, 4, 0, 0, 58, - 59, 3, 2, 1, 0, 59, 5, 1, 0, 0, 0, 60, 76, 5, 10, 0, 0, 61, 76, 5, 11, - 0, 0, 62, 76, 5, 23, 0, 0, 63, 76, 5, 24, 0, 0, 64, 76, 5, 25, 0, 0, 65, - 67, 5, 5, 0, 0, 66, 65, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 68, 1, 0, 0, - 0, 68, 70, 5, 26, 0, 0, 69, 71, 5, 27, 0, 0, 70, 69, 1, 0, 0, 0, 70, 71, - 1, 0, 0, 0, 71, 76, 1, 0, 0, 0, 72, 76, 3, 16, 8, 0, 73, 76, 3, 12, 6, - 0, 74, 76, 3, 8, 4, 0, 75, 60, 1, 0, 0, 0, 75, 61, 1, 0, 0, 0, 75, 62, - 1, 0, 0, 0, 75, 63, 1, 0, 0, 0, 75, 64, 1, 0, 0, 0, 75, 66, 1, 0, 0, 0, - 75, 72, 1, 0, 0, 0, 75, 73, 1, 0, 0, 0, 75, 74, 1, 0, 0, 0, 76, 7, 1, 0, - 0, 0, 77, 78, 5, 6, 0, 0, 78, 79, 3, 10, 5, 0, 79, 9, 1, 0, 0, 0, 80, 81, - 5, 24, 0, 0, 81, 82, 5, 29, 0, 0, 82, 86, 3, 10, 5, 0, 83, 84, 5, 24, 0, - 0, 84, 86, 5, 7, 0, 0, 85, 80, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 86, 11, - 1, 0, 0, 0, 87, 88, 5, 6, 0, 0, 88, 89, 3, 14, 7, 0, 89, 13, 1, 0, 0, 0, - 90, 91, 5, 25, 0, 0, 91, 92, 5, 29, 0, 0, 92, 96, 3, 14, 7, 0, 93, 94, - 5, 25, 0, 0, 94, 96, 5, 7, 0, 0, 95, 90, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, - 96, 15, 1, 0, 0, 0, 97, 98, 5, 6, 0, 0, 98, 99, 3, 18, 9, 0, 99, 17, 1, - 0, 0, 0, 100, 101, 5, 26, 0, 0, 101, 102, 5, 29, 0, 0, 102, 106, 3, 18, - 9, 0, 103, 104, 5, 26, 0, 0, 104, 106, 5, 7, 0, 0, 105, 100, 1, 0, 0, 0, - 105, 103, 1, 0, 0, 0, 106, 19, 1, 0, 0, 0, 11, 22, 25, 41, 50, 55, 66, - 70, 75, 85, 95, 105, + 0, 3, 0, 23, 8, 0, 1, 0, 3, 0, 26, 8, 0, 1, 0, 1, 0, 3, 0, 30, 8, 0, 1, + 0, 1, 0, 3, 0, 34, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 48, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, + 0, 55, 8, 0, 10, 0, 12, 0, 58, 9, 0, 1, 1, 1, 1, 3, 1, 62, 8, 1, 1, 2, + 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 73, 8, 3, 1, 3, 1, + 3, 3, 3, 77, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 82, 8, 3, 1, 4, 1, 4, 1, 4, + 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 92, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, + 7, 1, 7, 1, 7, 1, 7, 3, 7, 102, 8, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, + 9, 1, 9, 1, 9, 3, 9, 112, 8, 9, 1, 9, 0, 1, 0, 10, 0, 2, 4, 6, 8, 10, 12, + 14, 16, 18, 0, 1, 1, 0, 12, 21, 124, 0, 47, 1, 0, 0, 0, 2, 59, 1, 0, 0, + 0, 4, 63, 1, 0, 0, 0, 6, 81, 1, 0, 0, 0, 8, 83, 1, 0, 0, 0, 10, 91, 1, + 0, 0, 0, 12, 93, 1, 0, 0, 0, 14, 101, 1, 0, 0, 0, 16, 103, 1, 0, 0, 0, + 18, 111, 1, 0, 0, 0, 20, 22, 6, 0, -1, 0, 21, 23, 5, 8, 0, 0, 22, 21, 1, + 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 25, 1, 0, 0, 0, 24, 26, 5, 30, 0, 0, 25, + 24, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 5, 1, 0, + 0, 28, 30, 5, 30, 0, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, + 1, 0, 0, 0, 31, 33, 3, 0, 0, 0, 32, 34, 5, 30, 0, 0, 33, 32, 1, 0, 0, 0, + 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 36, 5, 2, 0, 0, 36, 48, 1, + 0, 0, 0, 37, 38, 3, 2, 1, 0, 38, 39, 5, 30, 0, 0, 39, 40, 5, 3, 0, 0, 40, + 48, 1, 0, 0, 0, 41, 42, 3, 2, 1, 0, 42, 43, 5, 30, 0, 0, 43, 44, 7, 0, + 0, 0, 44, 45, 5, 30, 0, 0, 45, 46, 3, 6, 3, 0, 46, 48, 1, 0, 0, 0, 47, + 20, 1, 0, 0, 0, 47, 37, 1, 0, 0, 0, 47, 41, 1, 0, 0, 0, 48, 56, 1, 0, 0, + 0, 49, 50, 10, 3, 0, 0, 50, 51, 5, 30, 0, 0, 51, 52, 5, 9, 0, 0, 52, 53, + 5, 30, 0, 0, 53, 55, 3, 0, 0, 4, 54, 49, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, + 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 1, 1, 0, 0, 0, 58, 56, 1, 0, + 0, 0, 59, 61, 5, 22, 0, 0, 60, 62, 3, 4, 2, 0, 61, 60, 1, 0, 0, 0, 61, + 62, 1, 0, 0, 0, 62, 3, 1, 0, 0, 0, 63, 64, 5, 4, 0, 0, 64, 65, 3, 2, 1, + 0, 65, 5, 1, 0, 0, 0, 66, 82, 5, 10, 0, 0, 67, 82, 5, 11, 0, 0, 68, 82, + 5, 23, 0, 0, 69, 82, 5, 24, 0, 0, 70, 82, 5, 25, 0, 0, 71, 73, 5, 5, 0, + 0, 72, 71, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 74, 1, 0, 0, 0, 74, 76, + 5, 26, 0, 0, 75, 77, 5, 27, 0, 0, 76, 75, 1, 0, 0, 0, 76, 77, 1, 0, 0, + 0, 77, 82, 1, 0, 0, 0, 78, 82, 3, 16, 8, 0, 79, 82, 3, 12, 6, 0, 80, 82, + 3, 8, 4, 0, 81, 66, 1, 0, 0, 0, 81, 67, 1, 0, 0, 0, 81, 68, 1, 0, 0, 0, + 81, 69, 1, 0, 0, 0, 81, 70, 1, 0, 0, 0, 81, 72, 1, 0, 0, 0, 81, 78, 1, + 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 80, 1, 0, 0, 0, 82, 7, 1, 0, 0, 0, 83, + 84, 5, 6, 0, 0, 84, 85, 3, 10, 5, 0, 85, 9, 1, 0, 0, 0, 86, 87, 5, 24, + 0, 0, 87, 88, 5, 29, 0, 0, 88, 92, 3, 10, 5, 0, 89, 90, 5, 24, 0, 0, 90, + 92, 5, 7, 0, 0, 91, 86, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 11, 1, 0, 0, + 0, 93, 94, 5, 6, 0, 0, 94, 95, 3, 14, 7, 0, 95, 13, 1, 0, 0, 0, 96, 97, + 5, 25, 0, 0, 97, 98, 5, 29, 0, 0, 98, 102, 3, 14, 7, 0, 99, 100, 5, 25, + 0, 0, 100, 102, 5, 7, 0, 0, 101, 96, 1, 0, 0, 0, 101, 99, 1, 0, 0, 0, 102, + 15, 1, 0, 0, 0, 103, 104, 5, 6, 0, 0, 104, 105, 3, 18, 9, 0, 105, 17, 1, + 0, 0, 0, 106, 107, 5, 26, 0, 0, 107, 108, 5, 29, 0, 0, 108, 112, 3, 18, + 9, 0, 109, 110, 5, 26, 0, 0, 110, 112, 5, 7, 0, 0, 111, 106, 1, 0, 0, 0, + 111, 109, 1, 0, 0, 0, 112, 19, 1, 0, 0, 0, 13, 22, 25, 29, 33, 47, 56, + 61, 72, 76, 81, 91, 101, 111, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -382,8 +385,12 @@ func (s *ParenExpContext) NOT() antlr.TerminalNode { return s.GetToken(JsonQueryParserNOT, 0) } -func (s *ParenExpContext) SP() antlr.TerminalNode { - return s.GetToken(JsonQueryParserSP, 0) +func (s *ParenExpContext) AllSP() []antlr.TerminalNode { + return s.GetTokens(JsonQueryParserSP) +} + +func (s *ParenExpContext) SP(i int) antlr.TerminalNode { + return s.GetToken(JsonQueryParserSP, i) } func (s *ParenExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { @@ -543,13 +550,13 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { var _alt int p.EnterOuterAlt(localctx, 1) - p.SetState(41) + p.SetState(47) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) { case 1: localctx = NewParenExpContext(p, localctx) p.SetParserRuleContext(localctx) @@ -599,12 +606,46 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { goto errorExit } } + p.SetState(29) + p.GetErrorHandler().Sync(p) + + if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) == 1 { + { + p.SetState(28) + p.Match(JsonQueryParserSP) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + } else if p.HasError() { // JIM + goto errorExit + } { - p.SetState(28) + p.SetState(31) p.query(0) } + p.SetState(33) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + if _la == JsonQueryParserSP { + { + p.SetState(32) + p.Match(JsonQueryParserSP) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + } { - p.SetState(29) + p.SetState(35) p.Match(JsonQueryParserT__1) if p.HasError() { // Recognition error - abort rule @@ -617,11 +658,11 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(31) + p.SetState(37) p.AttrPath() } { - p.SetState(32) + p.SetState(38) p.Match(JsonQueryParserSP) if p.HasError() { // Recognition error - abort rule @@ -629,7 +670,7 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(33) + p.SetState(39) p.Match(JsonQueryParserT__2) if p.HasError() { // Recognition error - abort rule @@ -642,11 +683,11 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { p.SetParserRuleContext(localctx) _prevctx = localctx { - p.SetState(35) + p.SetState(41) p.AttrPath() } { - p.SetState(36) + p.SetState(42) p.Match(JsonQueryParserSP) if p.HasError() { // Recognition error - abort rule @@ -654,7 +695,7 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(37) + p.SetState(43) var _lt = p.GetTokenStream().LT(1) @@ -672,7 +713,7 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(38) + p.SetState(44) p.Match(JsonQueryParserSP) if p.HasError() { // Recognition error - abort rule @@ -680,7 +721,7 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(39) + p.SetState(45) p.Value() } @@ -688,12 +729,12 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { goto errorExit } p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) - p.SetState(50) + p.SetState(56) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -705,14 +746,14 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { _prevctx = localctx localctx = NewLogicalExpContext(p, NewQueryContext(p, _parentctx, _parentState)) p.PushNewRecursionContext(localctx, _startState, JsonQueryParserRULE_query) - p.SetState(43) + p.SetState(49) if !(p.Precpred(p.GetParserRuleContext(), 3)) { p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 3)", "")) goto errorExit } { - p.SetState(44) + p.SetState(50) p.Match(JsonQueryParserSP) if p.HasError() { // Recognition error - abort rule @@ -720,7 +761,7 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(45) + p.SetState(51) p.Match(JsonQueryParserLOGICAL_OPERATOR) if p.HasError() { // Recognition error - abort rule @@ -728,7 +769,7 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(46) + p.SetState(52) p.Match(JsonQueryParserSP) if p.HasError() { // Recognition error - abort rule @@ -736,17 +777,17 @@ func (p *JsonQueryParser) query(_p int) (localctx IQueryContext) { } } { - p.SetState(47) + p.SetState(53) p.query(4) } } - p.SetState(52) + p.SetState(58) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext()) if p.HasError() { goto errorExit } @@ -857,14 +898,14 @@ func (p *JsonQueryParser) AttrPath() (localctx IAttrPathContext) { p.EnterOuterAlt(localctx, 1) { - p.SetState(53) + p.SetState(59) p.Match(JsonQueryParserATTRNAME) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(55) + p.SetState(61) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -873,7 +914,7 @@ func (p *JsonQueryParser) AttrPath() (localctx IAttrPathContext) { if _la == JsonQueryParserT__3 { { - p.SetState(54) + p.SetState(60) p.SubAttr() } @@ -977,7 +1018,7 @@ func (p *JsonQueryParser) SubAttr() (localctx ISubAttrContext) { p.EnterRule(localctx, 4, JsonQueryParserRULE_subAttr) p.EnterOuterAlt(localctx, 1) { - p.SetState(57) + p.SetState(63) p.Match(JsonQueryParserT__3) if p.HasError() { // Recognition error - abort rule @@ -985,7 +1026,7 @@ func (p *JsonQueryParser) SubAttr() (localctx ISubAttrContext) { } } { - p.SetState(58) + p.SetState(64) p.AttrPath() } @@ -1389,18 +1430,18 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { p.EnterRule(localctx, 6, JsonQueryParserRULE_value) var _la int - p.SetState(75) + p.SetState(81) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 9, p.GetParserRuleContext()) { case 1: localctx = NewBooleanContext(p, localctx) p.EnterOuterAlt(localctx, 1) { - p.SetState(60) + p.SetState(66) p.Match(JsonQueryParserBOOLEAN) if p.HasError() { // Recognition error - abort rule @@ -1412,7 +1453,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewNullContext(p, localctx) p.EnterOuterAlt(localctx, 2) { - p.SetState(61) + p.SetState(67) p.Match(JsonQueryParserNULL) if p.HasError() { // Recognition error - abort rule @@ -1424,7 +1465,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewVersionContext(p, localctx) p.EnterOuterAlt(localctx, 3) { - p.SetState(62) + p.SetState(68) p.Match(JsonQueryParserVERSION) if p.HasError() { // Recognition error - abort rule @@ -1436,7 +1477,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewStringContext(p, localctx) p.EnterOuterAlt(localctx, 4) { - p.SetState(63) + p.SetState(69) p.Match(JsonQueryParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -1448,7 +1489,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewDoubleContext(p, localctx) p.EnterOuterAlt(localctx, 5) { - p.SetState(64) + p.SetState(70) p.Match(JsonQueryParserDOUBLE) if p.HasError() { // Recognition error - abort rule @@ -1459,7 +1500,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { case 6: localctx = NewLongContext(p, localctx) p.EnterOuterAlt(localctx, 6) - p.SetState(66) + p.SetState(72) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1468,7 +1509,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { if _la == JsonQueryParserT__4 { { - p.SetState(65) + p.SetState(71) p.Match(JsonQueryParserT__4) if p.HasError() { // Recognition error - abort rule @@ -1478,19 +1519,19 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { } { - p.SetState(68) + p.SetState(74) p.Match(JsonQueryParserINT) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(70) + p.SetState(76) p.GetErrorHandler().Sync(p) - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 6, p.GetParserRuleContext()) == 1 { + if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext()) == 1 { { - p.SetState(69) + p.SetState(75) p.Match(JsonQueryParserEXP) if p.HasError() { // Recognition error - abort rule @@ -1506,7 +1547,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewListOfIntsContext(p, localctx) p.EnterOuterAlt(localctx, 7) { - p.SetState(72) + p.SetState(78) p.ListInts() } @@ -1514,7 +1555,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewListOfDoublesContext(p, localctx) p.EnterOuterAlt(localctx, 8) { - p.SetState(73) + p.SetState(79) p.ListDoubles() } @@ -1522,7 +1563,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { localctx = NewListOfStringsContext(p, localctx) p.EnterOuterAlt(localctx, 9) { - p.SetState(74) + p.SetState(80) p.ListStrings() } @@ -1628,7 +1669,7 @@ func (p *JsonQueryParser) ListStrings() (localctx IListStringsContext) { p.EnterRule(localctx, 8, JsonQueryParserRULE_listStrings) p.EnterOuterAlt(localctx, 1) { - p.SetState(77) + p.SetState(83) p.Match(JsonQueryParserT__5) if p.HasError() { // Recognition error - abort rule @@ -1636,7 +1677,7 @@ func (p *JsonQueryParser) ListStrings() (localctx IListStringsContext) { } } { - p.SetState(78) + p.SetState(84) p.SubListOfStrings() } @@ -1746,17 +1787,17 @@ func (s *SubListOfStringsContext) Accept(visitor antlr.ParseTreeVisitor) interfa func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) { localctx = NewSubListOfStringsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 10, JsonQueryParserRULE_subListOfStrings) - p.SetState(85) + p.SetState(91) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) { case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(80) + p.SetState(86) p.Match(JsonQueryParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -1764,7 +1805,7 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) } } { - p.SetState(81) + p.SetState(87) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -1772,14 +1813,14 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) } } { - p.SetState(82) + p.SetState(88) p.SubListOfStrings() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(83) + p.SetState(89) p.Match(JsonQueryParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -1787,7 +1828,7 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) } } { - p.SetState(84) + p.SetState(90) p.Match(JsonQueryParserT__6) if p.HasError() { // Recognition error - abort rule @@ -1897,7 +1938,7 @@ func (p *JsonQueryParser) ListDoubles() (localctx IListDoublesContext) { p.EnterRule(localctx, 12, JsonQueryParserRULE_listDoubles) p.EnterOuterAlt(localctx, 1) { - p.SetState(87) + p.SetState(93) p.Match(JsonQueryParserT__5) if p.HasError() { // Recognition error - abort rule @@ -1905,7 +1946,7 @@ func (p *JsonQueryParser) ListDoubles() (localctx IListDoublesContext) { } } { - p.SetState(88) + p.SetState(94) p.SubListOfDoubles() } @@ -2015,17 +2056,17 @@ func (s *SubListOfDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interfa func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) { localctx = NewSubListOfDoublesContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 14, JsonQueryParserRULE_subListOfDoubles) - p.SetState(95) + p.SetState(101) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 9, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) { case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(90) + p.SetState(96) p.Match(JsonQueryParserDOUBLE) if p.HasError() { // Recognition error - abort rule @@ -2033,7 +2074,7 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) } } { - p.SetState(91) + p.SetState(97) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -2041,14 +2082,14 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) } } { - p.SetState(92) + p.SetState(98) p.SubListOfDoubles() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(93) + p.SetState(99) p.Match(JsonQueryParserDOUBLE) if p.HasError() { // Recognition error - abort rule @@ -2056,7 +2097,7 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) } } { - p.SetState(94) + p.SetState(100) p.Match(JsonQueryParserT__6) if p.HasError() { // Recognition error - abort rule @@ -2166,7 +2207,7 @@ func (p *JsonQueryParser) ListInts() (localctx IListIntsContext) { p.EnterRule(localctx, 16, JsonQueryParserRULE_listInts) p.EnterOuterAlt(localctx, 1) { - p.SetState(97) + p.SetState(103) p.Match(JsonQueryParserT__5) if p.HasError() { // Recognition error - abort rule @@ -2174,7 +2215,7 @@ func (p *JsonQueryParser) ListInts() (localctx IListIntsContext) { } } { - p.SetState(98) + p.SetState(104) p.SubListOfInts() } @@ -2284,17 +2325,17 @@ func (s *SubListOfIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { localctx = NewSubListOfIntsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 18, JsonQueryParserRULE_subListOfInts) - p.SetState(105) + p.SetState(111) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit } - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) { + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 12, p.GetParserRuleContext()) { case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(100) + p.SetState(106) p.Match(JsonQueryParserINT) if p.HasError() { // Recognition error - abort rule @@ -2302,7 +2343,7 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { } } { - p.SetState(101) + p.SetState(107) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -2310,14 +2351,14 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { } } { - p.SetState(102) + p.SetState(108) p.SubListOfInts() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(103) + p.SetState(109) p.Match(JsonQueryParserINT) if p.HasError() { // Recognition error - abort rule @@ -2325,7 +2366,7 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { } } { - p.SetState(104) + p.SetState(110) p.Match(JsonQueryParserT__6) if p.HasError() { // Recognition error - abort rule diff --git a/parser/parse_logical_test.go b/parser/parse_logical_test.go index 0d7c285..2006bee 100644 --- a/parser/parse_logical_test.go +++ b/parser/parse_logical_test.go @@ -194,6 +194,55 @@ func TestLogicalExpWithAnd(t *testing.T) { assert.Equal(t, tt.result, Evaluate(tt.rule, tt.input), tt.rule) assert.Equal(t, tt.result, Evaluate(fmt.Sprintf("(%s)", tt.rule), tt.input), tt.rule) }) + } +} + +func TestLogicalExpWithAndWithExtraSpaces(t *testing.T) { + tests := []testCase{ + { + `x < 2 and ( y > 4 or z == true )`, + obj{ + "x": 1, + "y": 3, + "z": true, + }, + true, + false, + }, + { + `x < 2 and ( y > 4 or z == true )`, + obj{ + "x": 1, + "y": 3, + }, + false, + false, + }, + { + `x < 2 and ( y > 4 or z == true )`, + obj{ + "x": 1, + "y": 5, + }, + true, + false, + }, + { + `x < 2 and ( y > 4 or z == true)`, + obj{ + "x": 1, + "y": 3, + "z": true, + }, + true, + false, + }, + } + for _, tt := range tests { + t.Run(tt.rule, func(t *testing.T) { + assert.Equal(t, tt.result, Evaluate(tt.rule, tt.input), tt.rule) + assert.Equal(t, tt.result, Evaluate(fmt.Sprintf("(%s)", tt.rule), tt.input), tt.rule) + }) } }