-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add generate antlr files - add antlr grammar query
- Loading branch information
Showing
19 changed files
with
2,133 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
*.out | ||
*.out | ||
.antlr/ | ||
|
||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
grammar Query; | ||
|
||
input | ||
: query EOF | ||
; | ||
|
||
query | ||
: left=query logicalOp=(AND | OR) right=query #opQuery | ||
| LPAREN query RPAREN #priorityQuery | ||
| criteria #atomQuery | ||
; | ||
|
||
criteria | ||
: key op value | ||
| key | ||
; | ||
|
||
key | ||
: IDENTIFIER | ||
| NEG_IDENTIFIER | ||
; | ||
|
||
value | ||
: IDENTIFIER | ||
| STRING | ||
| ENCODED_STRING | ||
; | ||
|
||
op | ||
: EQ | ||
| NE | ||
| GT | ||
| GTE | ||
| LT | ||
| LTE | ||
; | ||
|
||
STRING | ||
: '\'' StringCharacter* '\'' | ||
; | ||
|
||
fragment StringCharacter | ||
: ~["\\\r\n] | ||
| '\\' EscapeSequence | ||
| LineContinuation | ||
; | ||
fragment EscapeSequence | ||
: CharacterEscapeSequence | ||
| HexEscapeSequence | ||
| UnicodeEscapeSequence | ||
; | ||
fragment CharacterEscapeSequence | ||
: SingleEscapeCharacter | ||
| NonEscapeCharacter | ||
; | ||
fragment HexEscapeSequence | ||
: 'x' HexDigit HexDigit | ||
; | ||
fragment UnicodeEscapeSequence | ||
: 'u' HexDigit HexDigit HexDigit HexDigit | ||
; | ||
fragment SingleEscapeCharacter | ||
: ['"\\bfnrtv] | ||
; | ||
|
||
fragment NonEscapeCharacter | ||
: ~['"\\bfnrtv0-9xu\r\n] | ||
; | ||
fragment EscapeCharacter | ||
: SingleEscapeCharacter | ||
| DecimalDigit | ||
| [xu] | ||
; | ||
fragment LineContinuation | ||
: '\\' LineTerminatorSequence | ||
; | ||
fragment LineTerminatorSequence | ||
: '\r\n' | ||
| LineTerminator | ||
; | ||
fragment DecimalDigit | ||
: [0-9] | ||
; | ||
fragment HexDigit | ||
: [0-9a-fA-F] | ||
; | ||
fragment OctalDigit | ||
: [0-7] | ||
; | ||
AND | ||
: 'AND' | ||
| 'and' | ||
; | ||
OR | ||
: 'OR' | ||
| 'or' | ||
; | ||
LPAREN | ||
: '(' | ||
; | ||
RPAREN | ||
: ')' | ||
; | ||
EQ | ||
: '=' | ||
; | ||
NE | ||
: '!=' | ||
; | ||
GT | ||
: '>' | ||
; | ||
GTE | ||
: '>=' | ||
; | ||
LT | ||
: '<' | ||
; | ||
LTE | ||
: '<=' | ||
; | ||
IDENTIFIER | ||
: [A-Za-z0-9.:_-]+ | ||
; | ||
NEG_IDENTIFIER | ||
: '!'[A-Za-z0-9.:_-]+ | ||
; | ||
ENCODED_STRING | ||
: ~([ \\[\]<>!=()])+ | ||
; | ||
LineTerminator | ||
: [\r\n\u2028\u2029] -> channel(HIDDEN) | ||
; | ||
WS | ||
: [ \t\r\n]+ -> skip | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= | ||
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= | ||
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= | ||
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= | ||
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.