Skip to content

Commit

Permalink
Adding spaces around query to the grammar (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikunjy authored Oct 24, 2023
1 parent 6a1d398 commit 1f5e991
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 118 deletions.
4 changes: 2 additions & 2 deletions parser/JsonQuery.g4
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -70,7 +70,7 @@ value
;

VERSION
: INT '.' INT '.' INT
: INT '.' INT '.' INT
;

STRING
Expand Down
2 changes: 1 addition & 1 deletion parser/JsonQuery.interp
Original file line number Diff line number Diff line change
Expand Up @@ -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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, 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]
1 change: 1 addition & 0 deletions parser/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
antlr4 -Dlanguage=Go -visitor -no-listener JsonQuery.g4 -o ./
Loading

0 comments on commit 1f5e991

Please sign in to comment.