mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 06:49:01 +08:00
chore: add generated parser files for go (#7538)
This commit is contained in:
parent
1c43655336
commit
c8c56c544e
1
go.mod
1
go.mod
@ -91,6 +91,7 @@ require (
|
|||||||
github.com/ClickHouse/ch-go v0.61.5 // indirect
|
github.com/ClickHouse/ch-go v0.61.5 // indirect
|
||||||
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
|
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
|
||||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||||
|
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
|
||||||
github.com/armon/go-metrics v0.4.1 // indirect
|
github.com/armon/go-metrics v0.4.1 // indirect
|
||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||||
github.com/aws/aws-sdk-go v1.55.5 // indirect
|
github.com/aws/aws-sdk-go v1.55.5 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -113,6 +113,8 @@ github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4
|
|||||||
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
|
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
|
||||||
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
|
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
|
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
|
||||||
|
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
|
||||||
github.com/antonmedv/expr v1.15.3 h1:q3hOJZNvLvhqE8OHBs1cFRdbXFNKuA+bHmRaI+AmRmI=
|
github.com/antonmedv/expr v1.15.3 h1:q3hOJZNvLvhqE8OHBs1cFRdbXFNKuA+bHmRaI+AmRmI=
|
||||||
github.com/antonmedv/expr v1.15.3/go.mod h1:0E/6TxnOlRNp81GMzX9QfDPAmHo2Phg00y4JUv1ihsE=
|
github.com/antonmedv/expr v1.15.3/go.mod h1:0E/6TxnOlRNp81GMzX9QfDPAmHo2Phg00y4JUv1ihsE=
|
||||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||||
|
221
grammar/FilterQuery.g4
Normal file
221
grammar/FilterQuery.g4
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
grammar FilterQuery;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parser Rules
|
||||||
|
*/
|
||||||
|
|
||||||
|
query
|
||||||
|
: expression
|
||||||
|
EOF
|
||||||
|
;
|
||||||
|
|
||||||
|
// Expression with standard boolean precedence:
|
||||||
|
// - parentheses > NOT > AND > OR
|
||||||
|
// - consecutive expressions with no AND/OR => implicit AND
|
||||||
|
expression
|
||||||
|
: orExpression
|
||||||
|
;
|
||||||
|
|
||||||
|
// OR expressions
|
||||||
|
orExpression
|
||||||
|
: andExpression ( OR andExpression )*
|
||||||
|
;
|
||||||
|
|
||||||
|
// AND expressions + optional chaining with implicit AND if no OR is present
|
||||||
|
andExpression
|
||||||
|
: unaryExpression ( AND unaryExpression | unaryExpression )*
|
||||||
|
;
|
||||||
|
|
||||||
|
// A unary expression handles optional NOT
|
||||||
|
unaryExpression
|
||||||
|
: NOT? primary
|
||||||
|
;
|
||||||
|
|
||||||
|
// Primary constructs: grouped expressions, a comparison (key op value),
|
||||||
|
// a function call, or a full-text string
|
||||||
|
primary
|
||||||
|
: LPAREN orExpression RPAREN
|
||||||
|
| comparison
|
||||||
|
| functionCall
|
||||||
|
| fullText
|
||||||
|
| key
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Comparison-like filters
|
||||||
|
*
|
||||||
|
* Includes all operators: =, !=, <>, <, <=, >, >=, [NOT] LIKE, [NOT] ILIKE,
|
||||||
|
* [NOT] BETWEEN, [NOT] IN, [NOT] EXISTS, [NOT] REGEXP, [NOT] CONTAINS, etc.
|
||||||
|
*/
|
||||||
|
comparison
|
||||||
|
: key EQUALS value
|
||||||
|
| key (NOT_EQUALS | NEQ) value
|
||||||
|
| key LT value
|
||||||
|
| key LE value
|
||||||
|
| key GT value
|
||||||
|
| key GE value
|
||||||
|
|
||||||
|
| key (LIKE | ILIKE) value
|
||||||
|
| key (NOT_LIKE | NOT_ILIKE) value
|
||||||
|
|
||||||
|
| key BETWEEN value AND value
|
||||||
|
| key NOT BETWEEN value AND value
|
||||||
|
|
||||||
|
| key inClause
|
||||||
|
| key notInClause
|
||||||
|
|
||||||
|
| key EXISTS
|
||||||
|
| key NOT EXISTS
|
||||||
|
|
||||||
|
| key REGEXP value
|
||||||
|
| key NOT REGEXP value
|
||||||
|
|
||||||
|
| key CONTAINS value
|
||||||
|
| key NOT CONTAINS value
|
||||||
|
;
|
||||||
|
|
||||||
|
// in(...) or in[...]
|
||||||
|
inClause
|
||||||
|
: IN LPAREN valueList RPAREN
|
||||||
|
| IN LBRACK valueList RBRACK
|
||||||
|
;
|
||||||
|
|
||||||
|
notInClause
|
||||||
|
: NOT IN LPAREN valueList RPAREN
|
||||||
|
| NOT IN LBRACK valueList RBRACK
|
||||||
|
;
|
||||||
|
|
||||||
|
// List of values for in(...) or in[...]
|
||||||
|
valueList
|
||||||
|
: value ( COMMA value )*
|
||||||
|
;
|
||||||
|
|
||||||
|
// Full-text search: a standalone quoted string is allowed as a "primary"
|
||||||
|
// e.g. `"Waiting for response" http.status_code=200`
|
||||||
|
fullText
|
||||||
|
: QUOTED_TEXT
|
||||||
|
| FREETEXT
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function calls like:
|
||||||
|
* has(payload.user_ids, 123)
|
||||||
|
* hasAny(payload.user_ids, [123, 456])
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
functionCall
|
||||||
|
: (HAS | HASANY | HASALL | HASNONE) LPAREN functionParamList RPAREN
|
||||||
|
;
|
||||||
|
|
||||||
|
// Function parameters can be keys, single scalar values, or arrays
|
||||||
|
functionParamList
|
||||||
|
: functionParam ( COMMA functionParam )*
|
||||||
|
;
|
||||||
|
|
||||||
|
functionParam
|
||||||
|
: key
|
||||||
|
| value
|
||||||
|
| array
|
||||||
|
;
|
||||||
|
|
||||||
|
// An array: [ item1, item2, item3 ]
|
||||||
|
array
|
||||||
|
: LBRACK valueList RBRACK
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A 'value' can be a string literal (double or single-quoted),
|
||||||
|
// a numeric literal, boolean, or a "bare" token as needed.
|
||||||
|
*/
|
||||||
|
value
|
||||||
|
: QUOTED_TEXT
|
||||||
|
| NUMBER
|
||||||
|
| BOOL
|
||||||
|
| KEY
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A key can include letters, digits, underscores, dots, brackets
|
||||||
|
* E.g. service.name, query_log.query_duration_ms, proto.user_objects[].name
|
||||||
|
*/
|
||||||
|
key
|
||||||
|
: KEY
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lexer Rules
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Common punctuation / symbols
|
||||||
|
LPAREN : '(' ;
|
||||||
|
RPAREN : ')' ;
|
||||||
|
LBRACK : '[' ;
|
||||||
|
RBRACK : ']' ;
|
||||||
|
COMMA : ',' ;
|
||||||
|
|
||||||
|
EQUALS : '=' | '==' ;
|
||||||
|
NOT_EQUALS : '!=' ;
|
||||||
|
NEQ : '<>' ; // alternate not-equals operator
|
||||||
|
LT : '<' ;
|
||||||
|
LE : '<=' ;
|
||||||
|
GT : '>' ;
|
||||||
|
GE : '>=' ;
|
||||||
|
|
||||||
|
// Operators that are made of multiple keywords
|
||||||
|
LIKE : [Ll][Ii][Kk][Ee] ;
|
||||||
|
NOT_LIKE : [Nn][Oo][Tt] [ \t]+ [Ll][Ii][Kk][Ee] ;
|
||||||
|
ILIKE : [Ii][Ll][Ii][Kk][Ee] ;
|
||||||
|
NOT_ILIKE : [Nn][Oo][Tt] [ \t]+ [Ii][Ll][Ii][Kk][Ee] ;
|
||||||
|
BETWEEN : [Bb][Ee][Tt][Ww][Ee][Ee][Nn] ;
|
||||||
|
EXISTS : [Ee][Xx][Ii][Ss][Tt][Ss]? ;
|
||||||
|
REGEXP : [Rr][Ee][Gg][Ee][Xx][Pp] ;
|
||||||
|
CONTAINS : [Cc][Oo][Nn][Tt][Aa][Ii][Nn][Ss]? ;
|
||||||
|
IN : [Ii][Nn] ;
|
||||||
|
|
||||||
|
// Boolean logic
|
||||||
|
NOT : [Nn][Oo][Tt] ;
|
||||||
|
AND : [Aa][Nn][Dd] ;
|
||||||
|
OR : [Oo][Rr] ;
|
||||||
|
|
||||||
|
// For easy referencing in function calls
|
||||||
|
HAS : [Hh][Aa][Ss] ;
|
||||||
|
HASANY : [Hh][Aa][Ss][Aa][Nn][Yy] ;
|
||||||
|
HASALL : [Hh][Aa][Ss][Aa][Ll][Ll] ;
|
||||||
|
HASNONE : [Hh][Aa][Ss][Nn][Oo][Nn][Ee] ;
|
||||||
|
|
||||||
|
// Potential boolean constants
|
||||||
|
BOOL
|
||||||
|
: [Tt][Rr][Uu][Ee]
|
||||||
|
| [Ff][Aa][Ll][Ss][Ee]
|
||||||
|
;
|
||||||
|
|
||||||
|
// Numbers (integer or float). Adjust as needed for your domain.
|
||||||
|
NUMBER
|
||||||
|
: DIGIT+ ( '.' DIGIT+ )?
|
||||||
|
;
|
||||||
|
|
||||||
|
// Double/single-quoted text, capturing full text search strings, values, etc.
|
||||||
|
QUOTED_TEXT
|
||||||
|
: ( '"' ( ~["\\] | '\\' . )* '"' // double-quoted
|
||||||
|
| '\'' ( ~['\\] | '\\' . )* '\'' // single-quoted
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
// Keys can have letters, digits, underscores, dots, and bracket pairs
|
||||||
|
// e.g. service.name, service.namespace, db.queries[].query_duration
|
||||||
|
KEY
|
||||||
|
: [a-zA-Z0-9_] [a-zA-Z0-9_.[\]]*
|
||||||
|
;
|
||||||
|
|
||||||
|
// Ignore whitespace
|
||||||
|
WS
|
||||||
|
: [ \t\r\n]+ -> skip
|
||||||
|
;
|
||||||
|
|
||||||
|
// Digits used by NUMBER
|
||||||
|
fragment DIGIT
|
||||||
|
: [0-9]
|
||||||
|
;
|
||||||
|
|
||||||
|
FREETEXT : (~[ \t\r\n=()'"<>![\]])+ ;
|
96
pkg/parser/grammar/FilterQuery.interp
Normal file
96
pkg/parser/grammar/FilterQuery.interp
Normal file
File diff suppressed because one or more lines are too long
45
pkg/parser/grammar/FilterQuery.tokens
Normal file
45
pkg/parser/grammar/FilterQuery.tokens
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
LPAREN=1
|
||||||
|
RPAREN=2
|
||||||
|
LBRACK=3
|
||||||
|
RBRACK=4
|
||||||
|
COMMA=5
|
||||||
|
EQUALS=6
|
||||||
|
NOT_EQUALS=7
|
||||||
|
NEQ=8
|
||||||
|
LT=9
|
||||||
|
LE=10
|
||||||
|
GT=11
|
||||||
|
GE=12
|
||||||
|
LIKE=13
|
||||||
|
NOT_LIKE=14
|
||||||
|
ILIKE=15
|
||||||
|
NOT_ILIKE=16
|
||||||
|
BETWEEN=17
|
||||||
|
EXISTS=18
|
||||||
|
REGEXP=19
|
||||||
|
CONTAINS=20
|
||||||
|
IN=21
|
||||||
|
NOT=22
|
||||||
|
AND=23
|
||||||
|
OR=24
|
||||||
|
HAS=25
|
||||||
|
HASANY=26
|
||||||
|
HASALL=27
|
||||||
|
HASNONE=28
|
||||||
|
BOOL=29
|
||||||
|
NUMBER=30
|
||||||
|
QUOTED_TEXT=31
|
||||||
|
KEY=32
|
||||||
|
WS=33
|
||||||
|
FREETEXT=34
|
||||||
|
'('=1
|
||||||
|
')'=2
|
||||||
|
'['=3
|
||||||
|
']'=4
|
||||||
|
','=5
|
||||||
|
'!='=7
|
||||||
|
'<>'=8
|
||||||
|
'<'=9
|
||||||
|
'<='=10
|
||||||
|
'>'=11
|
||||||
|
'>='=12
|
120
pkg/parser/grammar/FilterQueryLexer.interp
Normal file
120
pkg/parser/grammar/FilterQueryLexer.interp
Normal file
File diff suppressed because one or more lines are too long
45
pkg/parser/grammar/FilterQueryLexer.tokens
Normal file
45
pkg/parser/grammar/FilterQueryLexer.tokens
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
LPAREN=1
|
||||||
|
RPAREN=2
|
||||||
|
LBRACK=3
|
||||||
|
RBRACK=4
|
||||||
|
COMMA=5
|
||||||
|
EQUALS=6
|
||||||
|
NOT_EQUALS=7
|
||||||
|
NEQ=8
|
||||||
|
LT=9
|
||||||
|
LE=10
|
||||||
|
GT=11
|
||||||
|
GE=12
|
||||||
|
LIKE=13
|
||||||
|
NOT_LIKE=14
|
||||||
|
ILIKE=15
|
||||||
|
NOT_ILIKE=16
|
||||||
|
BETWEEN=17
|
||||||
|
EXISTS=18
|
||||||
|
REGEXP=19
|
||||||
|
CONTAINS=20
|
||||||
|
IN=21
|
||||||
|
NOT=22
|
||||||
|
AND=23
|
||||||
|
OR=24
|
||||||
|
HAS=25
|
||||||
|
HASANY=26
|
||||||
|
HASALL=27
|
||||||
|
HASNONE=28
|
||||||
|
BOOL=29
|
||||||
|
NUMBER=30
|
||||||
|
QUOTED_TEXT=31
|
||||||
|
KEY=32
|
||||||
|
WS=33
|
||||||
|
FREETEXT=34
|
||||||
|
'('=1
|
||||||
|
')'=2
|
||||||
|
'['=3
|
||||||
|
']'=4
|
||||||
|
','=5
|
||||||
|
'!='=7
|
||||||
|
'<>'=8
|
||||||
|
'<'=9
|
||||||
|
'<='=10
|
||||||
|
'>'=11
|
||||||
|
'>='=12
|
124
pkg/parser/grammar/filterquery_base_listener.go
Normal file
124
pkg/parser/grammar/filterquery_base_listener.go
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
// Code generated from grammar/FilterQuery.g4 by ANTLR 4.13.2. DO NOT EDIT.
|
||||||
|
|
||||||
|
package parser // FilterQuery
|
||||||
|
|
||||||
|
import "github.com/antlr4-go/antlr/v4"
|
||||||
|
|
||||||
|
// BaseFilterQueryListener is a complete listener for a parse tree produced by FilterQueryParser.
|
||||||
|
type BaseFilterQueryListener struct{}
|
||||||
|
|
||||||
|
var _ FilterQueryListener = &BaseFilterQueryListener{}
|
||||||
|
|
||||||
|
// VisitTerminal is called when a terminal node is visited.
|
||||||
|
func (s *BaseFilterQueryListener) VisitTerminal(node antlr.TerminalNode) {}
|
||||||
|
|
||||||
|
// VisitErrorNode is called when an error node is visited.
|
||||||
|
func (s *BaseFilterQueryListener) VisitErrorNode(node antlr.ErrorNode) {}
|
||||||
|
|
||||||
|
// EnterEveryRule is called when any rule is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterEveryRule(ctx antlr.ParserRuleContext) {}
|
||||||
|
|
||||||
|
// ExitEveryRule is called when any rule is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitEveryRule(ctx antlr.ParserRuleContext) {}
|
||||||
|
|
||||||
|
// EnterQuery is called when production query is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterQuery(ctx *QueryContext) {}
|
||||||
|
|
||||||
|
// ExitQuery is called when production query is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitQuery(ctx *QueryContext) {}
|
||||||
|
|
||||||
|
// EnterExpression is called when production expression is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterExpression(ctx *ExpressionContext) {}
|
||||||
|
|
||||||
|
// ExitExpression is called when production expression is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitExpression(ctx *ExpressionContext) {}
|
||||||
|
|
||||||
|
// EnterOrExpression is called when production orExpression is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterOrExpression(ctx *OrExpressionContext) {}
|
||||||
|
|
||||||
|
// ExitOrExpression is called when production orExpression is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitOrExpression(ctx *OrExpressionContext) {}
|
||||||
|
|
||||||
|
// EnterAndExpression is called when production andExpression is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterAndExpression(ctx *AndExpressionContext) {}
|
||||||
|
|
||||||
|
// ExitAndExpression is called when production andExpression is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitAndExpression(ctx *AndExpressionContext) {}
|
||||||
|
|
||||||
|
// EnterUnaryExpression is called when production unaryExpression is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterUnaryExpression(ctx *UnaryExpressionContext) {}
|
||||||
|
|
||||||
|
// ExitUnaryExpression is called when production unaryExpression is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitUnaryExpression(ctx *UnaryExpressionContext) {}
|
||||||
|
|
||||||
|
// EnterPrimary is called when production primary is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterPrimary(ctx *PrimaryContext) {}
|
||||||
|
|
||||||
|
// ExitPrimary is called when production primary is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitPrimary(ctx *PrimaryContext) {}
|
||||||
|
|
||||||
|
// EnterComparison is called when production comparison is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterComparison(ctx *ComparisonContext) {}
|
||||||
|
|
||||||
|
// ExitComparison is called when production comparison is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitComparison(ctx *ComparisonContext) {}
|
||||||
|
|
||||||
|
// EnterInClause is called when production inClause is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterInClause(ctx *InClauseContext) {}
|
||||||
|
|
||||||
|
// ExitInClause is called when production inClause is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitInClause(ctx *InClauseContext) {}
|
||||||
|
|
||||||
|
// EnterNotInClause is called when production notInClause is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterNotInClause(ctx *NotInClauseContext) {}
|
||||||
|
|
||||||
|
// ExitNotInClause is called when production notInClause is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitNotInClause(ctx *NotInClauseContext) {}
|
||||||
|
|
||||||
|
// EnterValueList is called when production valueList is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterValueList(ctx *ValueListContext) {}
|
||||||
|
|
||||||
|
// ExitValueList is called when production valueList is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitValueList(ctx *ValueListContext) {}
|
||||||
|
|
||||||
|
// EnterFullText is called when production fullText is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterFullText(ctx *FullTextContext) {}
|
||||||
|
|
||||||
|
// ExitFullText is called when production fullText is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitFullText(ctx *FullTextContext) {}
|
||||||
|
|
||||||
|
// EnterFunctionCall is called when production functionCall is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterFunctionCall(ctx *FunctionCallContext) {}
|
||||||
|
|
||||||
|
// ExitFunctionCall is called when production functionCall is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitFunctionCall(ctx *FunctionCallContext) {}
|
||||||
|
|
||||||
|
// EnterFunctionParamList is called when production functionParamList is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterFunctionParamList(ctx *FunctionParamListContext) {}
|
||||||
|
|
||||||
|
// ExitFunctionParamList is called when production functionParamList is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitFunctionParamList(ctx *FunctionParamListContext) {}
|
||||||
|
|
||||||
|
// EnterFunctionParam is called when production functionParam is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterFunctionParam(ctx *FunctionParamContext) {}
|
||||||
|
|
||||||
|
// ExitFunctionParam is called when production functionParam is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitFunctionParam(ctx *FunctionParamContext) {}
|
||||||
|
|
||||||
|
// EnterArray is called when production array is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterArray(ctx *ArrayContext) {}
|
||||||
|
|
||||||
|
// ExitArray is called when production array is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitArray(ctx *ArrayContext) {}
|
||||||
|
|
||||||
|
// EnterValue is called when production value is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterValue(ctx *ValueContext) {}
|
||||||
|
|
||||||
|
// ExitValue is called when production value is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitValue(ctx *ValueContext) {}
|
||||||
|
|
||||||
|
// EnterKey is called when production key is entered.
|
||||||
|
func (s *BaseFilterQueryListener) EnterKey(ctx *KeyContext) {}
|
||||||
|
|
||||||
|
// ExitKey is called when production key is exited.
|
||||||
|
func (s *BaseFilterQueryListener) ExitKey(ctx *KeyContext) {}
|
77
pkg/parser/grammar/filterquery_base_visitor.go
Normal file
77
pkg/parser/grammar/filterquery_base_visitor.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// Code generated from grammar/FilterQuery.g4 by ANTLR 4.13.2. DO NOT EDIT.
|
||||||
|
|
||||||
|
package parser // FilterQuery
|
||||||
|
|
||||||
|
import "github.com/antlr4-go/antlr/v4"
|
||||||
|
|
||||||
|
type BaseFilterQueryVisitor struct {
|
||||||
|
*antlr.BaseParseTreeVisitor
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitQuery(ctx *QueryContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitExpression(ctx *ExpressionContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitOrExpression(ctx *OrExpressionContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitAndExpression(ctx *AndExpressionContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitUnaryExpression(ctx *UnaryExpressionContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitPrimary(ctx *PrimaryContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitComparison(ctx *ComparisonContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitInClause(ctx *InClauseContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitNotInClause(ctx *NotInClauseContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitValueList(ctx *ValueListContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitFullText(ctx *FullTextContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitFunctionCall(ctx *FunctionCallContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitFunctionParamList(ctx *FunctionParamListContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitFunctionParam(ctx *FunctionParamContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitArray(ctx *ArrayContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitValue(ctx *ValueContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *BaseFilterQueryVisitor) VisitKey(ctx *KeyContext) interface{} {
|
||||||
|
return v.VisitChildren(ctx)
|
||||||
|
}
|
271
pkg/parser/grammar/filterquery_lexer.go
Normal file
271
pkg/parser/grammar/filterquery_lexer.go
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
// Code generated from grammar/FilterQuery.g4 by ANTLR 4.13.2. DO NOT EDIT.
|
||||||
|
|
||||||
|
package parser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/antlr4-go/antlr/v4"
|
||||||
|
"sync"
|
||||||
|
"unicode"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Suppress unused import error
|
||||||
|
var _ = fmt.Printf
|
||||||
|
var _ = sync.Once{}
|
||||||
|
var _ = unicode.IsLetter
|
||||||
|
|
||||||
|
type FilterQueryLexer struct {
|
||||||
|
*antlr.BaseLexer
|
||||||
|
channelNames []string
|
||||||
|
modeNames []string
|
||||||
|
// TODO: EOF string
|
||||||
|
}
|
||||||
|
|
||||||
|
var FilterQueryLexerLexerStaticData struct {
|
||||||
|
once sync.Once
|
||||||
|
serializedATN []int32
|
||||||
|
ChannelNames []string
|
||||||
|
ModeNames []string
|
||||||
|
LiteralNames []string
|
||||||
|
SymbolicNames []string
|
||||||
|
RuleNames []string
|
||||||
|
PredictionContextCache *antlr.PredictionContextCache
|
||||||
|
atn *antlr.ATN
|
||||||
|
decisionToDFA []*antlr.DFA
|
||||||
|
}
|
||||||
|
|
||||||
|
func filterquerylexerLexerInit() {
|
||||||
|
staticData := &FilterQueryLexerLexerStaticData
|
||||||
|
staticData.ChannelNames = []string{
|
||||||
|
"DEFAULT_TOKEN_CHANNEL", "HIDDEN",
|
||||||
|
}
|
||||||
|
staticData.ModeNames = []string{
|
||||||
|
"DEFAULT_MODE",
|
||||||
|
}
|
||||||
|
staticData.LiteralNames = []string{
|
||||||
|
"", "'('", "')'", "'['", "']'", "','", "", "'!='", "'<>'", "'<'", "'<='",
|
||||||
|
"'>'", "'>='",
|
||||||
|
}
|
||||||
|
staticData.SymbolicNames = []string{
|
||||||
|
"", "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS",
|
||||||
|
"NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE",
|
||||||
|
"BETWEEN", "EXISTS", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR",
|
||||||
|
"HAS", "HASANY", "HASALL", "HASNONE", "BOOL", "NUMBER", "QUOTED_TEXT",
|
||||||
|
"KEY", "WS", "FREETEXT",
|
||||||
|
}
|
||||||
|
staticData.RuleNames = []string{
|
||||||
|
"LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS",
|
||||||
|
"NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE",
|
||||||
|
"BETWEEN", "EXISTS", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR",
|
||||||
|
"HAS", "HASANY", "HASALL", "HASNONE", "BOOL", "NUMBER", "QUOTED_TEXT",
|
||||||
|
"KEY", "WS", "DIGIT", "FREETEXT",
|
||||||
|
}
|
||||||
|
staticData.PredictionContextCache = antlr.NewPredictionContextCache()
|
||||||
|
staticData.serializedATN = []int32{
|
||||||
|
4, 0, 34, 280, 6, -1, 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, 2,
|
||||||
|
10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15,
|
||||||
|
7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7,
|
||||||
|
20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25,
|
||||||
|
2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2,
|
||||||
|
31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 1, 0, 1, 0, 1, 1,
|
||||||
|
1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 85, 8,
|
||||||
|
5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1,
|
||||||
|
10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13,
|
||||||
|
1, 13, 1, 13, 1, 13, 4, 13, 112, 8, 13, 11, 13, 12, 13, 113, 1, 13, 1,
|
||||||
|
13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15,
|
||||||
|
1, 15, 1, 15, 1, 15, 4, 15, 131, 8, 15, 11, 15, 12, 15, 132, 1, 15, 1,
|
||||||
|
15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16,
|
||||||
|
1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 155, 8,
|
||||||
|
17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19,
|
||||||
|
1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 172, 8, 19, 1, 20, 1, 20, 1,
|
||||||
|
20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23,
|
||||||
|
1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1,
|
||||||
|
25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27,
|
||||||
|
1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1,
|
||||||
|
28, 1, 28, 1, 28, 1, 28, 1, 28, 3, 28, 223, 8, 28, 1, 29, 4, 29, 226, 8,
|
||||||
|
29, 11, 29, 12, 29, 227, 1, 29, 1, 29, 4, 29, 232, 8, 29, 11, 29, 12, 29,
|
||||||
|
233, 3, 29, 236, 8, 29, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 242, 8, 30,
|
||||||
|
10, 30, 12, 30, 245, 9, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 252,
|
||||||
|
8, 30, 10, 30, 12, 30, 255, 9, 30, 1, 30, 3, 30, 258, 8, 30, 1, 31, 1,
|
||||||
|
31, 5, 31, 262, 8, 31, 10, 31, 12, 31, 265, 9, 31, 1, 32, 4, 32, 268, 8,
|
||||||
|
32, 11, 32, 12, 32, 269, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 4, 34, 277,
|
||||||
|
8, 34, 11, 34, 12, 34, 278, 0, 0, 35, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11,
|
||||||
|
6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15,
|
||||||
|
31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24,
|
||||||
|
49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33,
|
||||||
|
67, 0, 69, 34, 1, 0, 29, 2, 0, 76, 76, 108, 108, 2, 0, 73, 73, 105, 105,
|
||||||
|
2, 0, 75, 75, 107, 107, 2, 0, 69, 69, 101, 101, 2, 0, 78, 78, 110, 110,
|
||||||
|
2, 0, 79, 79, 111, 111, 2, 0, 84, 84, 116, 116, 2, 0, 9, 9, 32, 32, 2,
|
||||||
|
0, 66, 66, 98, 98, 2, 0, 87, 87, 119, 119, 2, 0, 88, 88, 120, 120, 2, 0,
|
||||||
|
83, 83, 115, 115, 2, 0, 82, 82, 114, 114, 2, 0, 71, 71, 103, 103, 2, 0,
|
||||||
|
80, 80, 112, 112, 2, 0, 67, 67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 68,
|
||||||
|
68, 100, 100, 2, 0, 72, 72, 104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85,
|
||||||
|
85, 117, 117, 2, 0, 70, 70, 102, 102, 2, 0, 34, 34, 92, 92, 2, 0, 39, 39,
|
||||||
|
92, 92, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 6, 0, 46, 46, 48, 57, 65,
|
||||||
|
91, 93, 93, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57,
|
||||||
|
7, 0, 9, 10, 13, 13, 32, 34, 39, 41, 60, 62, 91, 91, 93, 93, 295, 0, 1,
|
||||||
|
1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9,
|
||||||
|
1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0,
|
||||||
|
17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0,
|
||||||
|
0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0,
|
||||||
|
0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0,
|
||||||
|
0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1,
|
||||||
|
0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55,
|
||||||
|
1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0,
|
||||||
|
63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 1, 71, 1, 0, 0, 0,
|
||||||
|
3, 73, 1, 0, 0, 0, 5, 75, 1, 0, 0, 0, 7, 77, 1, 0, 0, 0, 9, 79, 1, 0, 0,
|
||||||
|
0, 11, 84, 1, 0, 0, 0, 13, 86, 1, 0, 0, 0, 15, 89, 1, 0, 0, 0, 17, 92,
|
||||||
|
1, 0, 0, 0, 19, 94, 1, 0, 0, 0, 21, 97, 1, 0, 0, 0, 23, 99, 1, 0, 0, 0,
|
||||||
|
25, 102, 1, 0, 0, 0, 27, 107, 1, 0, 0, 0, 29, 120, 1, 0, 0, 0, 31, 126,
|
||||||
|
1, 0, 0, 0, 33, 140, 1, 0, 0, 0, 35, 148, 1, 0, 0, 0, 37, 156, 1, 0, 0,
|
||||||
|
0, 39, 163, 1, 0, 0, 0, 41, 173, 1, 0, 0, 0, 43, 176, 1, 0, 0, 0, 45, 180,
|
||||||
|
1, 0, 0, 0, 47, 184, 1, 0, 0, 0, 49, 187, 1, 0, 0, 0, 51, 191, 1, 0, 0,
|
||||||
|
0, 53, 198, 1, 0, 0, 0, 55, 205, 1, 0, 0, 0, 57, 222, 1, 0, 0, 0, 59, 225,
|
||||||
|
1, 0, 0, 0, 61, 257, 1, 0, 0, 0, 63, 259, 1, 0, 0, 0, 65, 267, 1, 0, 0,
|
||||||
|
0, 67, 273, 1, 0, 0, 0, 69, 276, 1, 0, 0, 0, 71, 72, 5, 40, 0, 0, 72, 2,
|
||||||
|
1, 0, 0, 0, 73, 74, 5, 41, 0, 0, 74, 4, 1, 0, 0, 0, 75, 76, 5, 91, 0, 0,
|
||||||
|
76, 6, 1, 0, 0, 0, 77, 78, 5, 93, 0, 0, 78, 8, 1, 0, 0, 0, 79, 80, 5, 44,
|
||||||
|
0, 0, 80, 10, 1, 0, 0, 0, 81, 85, 5, 61, 0, 0, 82, 83, 5, 61, 0, 0, 83,
|
||||||
|
85, 5, 61, 0, 0, 84, 81, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 85, 12, 1, 0,
|
||||||
|
0, 0, 86, 87, 5, 33, 0, 0, 87, 88, 5, 61, 0, 0, 88, 14, 1, 0, 0, 0, 89,
|
||||||
|
90, 5, 60, 0, 0, 90, 91, 5, 62, 0, 0, 91, 16, 1, 0, 0, 0, 92, 93, 5, 60,
|
||||||
|
0, 0, 93, 18, 1, 0, 0, 0, 94, 95, 5, 60, 0, 0, 95, 96, 5, 61, 0, 0, 96,
|
||||||
|
20, 1, 0, 0, 0, 97, 98, 5, 62, 0, 0, 98, 22, 1, 0, 0, 0, 99, 100, 5, 62,
|
||||||
|
0, 0, 100, 101, 5, 61, 0, 0, 101, 24, 1, 0, 0, 0, 102, 103, 7, 0, 0, 0,
|
||||||
|
103, 104, 7, 1, 0, 0, 104, 105, 7, 2, 0, 0, 105, 106, 7, 3, 0, 0, 106,
|
||||||
|
26, 1, 0, 0, 0, 107, 108, 7, 4, 0, 0, 108, 109, 7, 5, 0, 0, 109, 111, 7,
|
||||||
|
6, 0, 0, 110, 112, 7, 7, 0, 0, 111, 110, 1, 0, 0, 0, 112, 113, 1, 0, 0,
|
||||||
|
0, 113, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115,
|
||||||
|
116, 7, 0, 0, 0, 116, 117, 7, 1, 0, 0, 117, 118, 7, 2, 0, 0, 118, 119,
|
||||||
|
7, 3, 0, 0, 119, 28, 1, 0, 0, 0, 120, 121, 7, 1, 0, 0, 121, 122, 7, 0,
|
||||||
|
0, 0, 122, 123, 7, 1, 0, 0, 123, 124, 7, 2, 0, 0, 124, 125, 7, 3, 0, 0,
|
||||||
|
125, 30, 1, 0, 0, 0, 126, 127, 7, 4, 0, 0, 127, 128, 7, 5, 0, 0, 128, 130,
|
||||||
|
7, 6, 0, 0, 129, 131, 7, 7, 0, 0, 130, 129, 1, 0, 0, 0, 131, 132, 1, 0,
|
||||||
|
0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 134, 1, 0, 0, 0,
|
||||||
|
134, 135, 7, 1, 0, 0, 135, 136, 7, 0, 0, 0, 136, 137, 7, 1, 0, 0, 137,
|
||||||
|
138, 7, 2, 0, 0, 138, 139, 7, 3, 0, 0, 139, 32, 1, 0, 0, 0, 140, 141, 7,
|
||||||
|
8, 0, 0, 141, 142, 7, 3, 0, 0, 142, 143, 7, 6, 0, 0, 143, 144, 7, 9, 0,
|
||||||
|
0, 144, 145, 7, 3, 0, 0, 145, 146, 7, 3, 0, 0, 146, 147, 7, 4, 0, 0, 147,
|
||||||
|
34, 1, 0, 0, 0, 148, 149, 7, 3, 0, 0, 149, 150, 7, 10, 0, 0, 150, 151,
|
||||||
|
7, 1, 0, 0, 151, 152, 7, 11, 0, 0, 152, 154, 7, 6, 0, 0, 153, 155, 7, 11,
|
||||||
|
0, 0, 154, 153, 1, 0, 0, 0, 154, 155, 1, 0, 0, 0, 155, 36, 1, 0, 0, 0,
|
||||||
|
156, 157, 7, 12, 0, 0, 157, 158, 7, 3, 0, 0, 158, 159, 7, 13, 0, 0, 159,
|
||||||
|
160, 7, 3, 0, 0, 160, 161, 7, 10, 0, 0, 161, 162, 7, 14, 0, 0, 162, 38,
|
||||||
|
1, 0, 0, 0, 163, 164, 7, 15, 0, 0, 164, 165, 7, 5, 0, 0, 165, 166, 7, 4,
|
||||||
|
0, 0, 166, 167, 7, 6, 0, 0, 167, 168, 7, 16, 0, 0, 168, 169, 7, 1, 0, 0,
|
||||||
|
169, 171, 7, 4, 0, 0, 170, 172, 7, 11, 0, 0, 171, 170, 1, 0, 0, 0, 171,
|
||||||
|
172, 1, 0, 0, 0, 172, 40, 1, 0, 0, 0, 173, 174, 7, 1, 0, 0, 174, 175, 7,
|
||||||
|
4, 0, 0, 175, 42, 1, 0, 0, 0, 176, 177, 7, 4, 0, 0, 177, 178, 7, 5, 0,
|
||||||
|
0, 178, 179, 7, 6, 0, 0, 179, 44, 1, 0, 0, 0, 180, 181, 7, 16, 0, 0, 181,
|
||||||
|
182, 7, 4, 0, 0, 182, 183, 7, 17, 0, 0, 183, 46, 1, 0, 0, 0, 184, 185,
|
||||||
|
7, 5, 0, 0, 185, 186, 7, 12, 0, 0, 186, 48, 1, 0, 0, 0, 187, 188, 7, 18,
|
||||||
|
0, 0, 188, 189, 7, 16, 0, 0, 189, 190, 7, 11, 0, 0, 190, 50, 1, 0, 0, 0,
|
||||||
|
191, 192, 7, 18, 0, 0, 192, 193, 7, 16, 0, 0, 193, 194, 7, 11, 0, 0, 194,
|
||||||
|
195, 7, 16, 0, 0, 195, 196, 7, 4, 0, 0, 196, 197, 7, 19, 0, 0, 197, 52,
|
||||||
|
1, 0, 0, 0, 198, 199, 7, 18, 0, 0, 199, 200, 7, 16, 0, 0, 200, 201, 7,
|
||||||
|
11, 0, 0, 201, 202, 7, 16, 0, 0, 202, 203, 7, 0, 0, 0, 203, 204, 7, 0,
|
||||||
|
0, 0, 204, 54, 1, 0, 0, 0, 205, 206, 7, 18, 0, 0, 206, 207, 7, 16, 0, 0,
|
||||||
|
207, 208, 7, 11, 0, 0, 208, 209, 7, 4, 0, 0, 209, 210, 7, 5, 0, 0, 210,
|
||||||
|
211, 7, 4, 0, 0, 211, 212, 7, 3, 0, 0, 212, 56, 1, 0, 0, 0, 213, 214, 7,
|
||||||
|
6, 0, 0, 214, 215, 7, 12, 0, 0, 215, 216, 7, 20, 0, 0, 216, 223, 7, 3,
|
||||||
|
0, 0, 217, 218, 7, 21, 0, 0, 218, 219, 7, 16, 0, 0, 219, 220, 7, 0, 0,
|
||||||
|
0, 220, 221, 7, 11, 0, 0, 221, 223, 7, 3, 0, 0, 222, 213, 1, 0, 0, 0, 222,
|
||||||
|
217, 1, 0, 0, 0, 223, 58, 1, 0, 0, 0, 224, 226, 3, 67, 33, 0, 225, 224,
|
||||||
|
1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 225, 1, 0, 0, 0, 227, 228, 1, 0,
|
||||||
|
0, 0, 228, 235, 1, 0, 0, 0, 229, 231, 5, 46, 0, 0, 230, 232, 3, 67, 33,
|
||||||
|
0, 231, 230, 1, 0, 0, 0, 232, 233, 1, 0, 0, 0, 233, 231, 1, 0, 0, 0, 233,
|
||||||
|
234, 1, 0, 0, 0, 234, 236, 1, 0, 0, 0, 235, 229, 1, 0, 0, 0, 235, 236,
|
||||||
|
1, 0, 0, 0, 236, 60, 1, 0, 0, 0, 237, 243, 5, 34, 0, 0, 238, 242, 8, 22,
|
||||||
|
0, 0, 239, 240, 5, 92, 0, 0, 240, 242, 9, 0, 0, 0, 241, 238, 1, 0, 0, 0,
|
||||||
|
241, 239, 1, 0, 0, 0, 242, 245, 1, 0, 0, 0, 243, 241, 1, 0, 0, 0, 243,
|
||||||
|
244, 1, 0, 0, 0, 244, 246, 1, 0, 0, 0, 245, 243, 1, 0, 0, 0, 246, 258,
|
||||||
|
5, 34, 0, 0, 247, 253, 5, 39, 0, 0, 248, 252, 8, 23, 0, 0, 249, 250, 5,
|
||||||
|
92, 0, 0, 250, 252, 9, 0, 0, 0, 251, 248, 1, 0, 0, 0, 251, 249, 1, 0, 0,
|
||||||
|
0, 252, 255, 1, 0, 0, 0, 253, 251, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254,
|
||||||
|
256, 1, 0, 0, 0, 255, 253, 1, 0, 0, 0, 256, 258, 5, 39, 0, 0, 257, 237,
|
||||||
|
1, 0, 0, 0, 257, 247, 1, 0, 0, 0, 258, 62, 1, 0, 0, 0, 259, 263, 7, 24,
|
||||||
|
0, 0, 260, 262, 7, 25, 0, 0, 261, 260, 1, 0, 0, 0, 262, 265, 1, 0, 0, 0,
|
||||||
|
263, 261, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 64, 1, 0, 0, 0, 265, 263,
|
||||||
|
1, 0, 0, 0, 266, 268, 7, 26, 0, 0, 267, 266, 1, 0, 0, 0, 268, 269, 1, 0,
|
||||||
|
0, 0, 269, 267, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 271, 1, 0, 0, 0,
|
||||||
|
271, 272, 6, 32, 0, 0, 272, 66, 1, 0, 0, 0, 273, 274, 7, 27, 0, 0, 274,
|
||||||
|
68, 1, 0, 0, 0, 275, 277, 8, 28, 0, 0, 276, 275, 1, 0, 0, 0, 277, 278,
|
||||||
|
1, 0, 0, 0, 278, 276, 1, 0, 0, 0, 278, 279, 1, 0, 0, 0, 279, 70, 1, 0,
|
||||||
|
0, 0, 18, 0, 84, 113, 132, 154, 171, 222, 227, 233, 235, 241, 243, 251,
|
||||||
|
253, 257, 263, 269, 278, 1, 6, 0, 0,
|
||||||
|
}
|
||||||
|
deserializer := antlr.NewATNDeserializer(nil)
|
||||||
|
staticData.atn = deserializer.Deserialize(staticData.serializedATN)
|
||||||
|
atn := staticData.atn
|
||||||
|
staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState))
|
||||||
|
decisionToDFA := staticData.decisionToDFA
|
||||||
|
for index, state := range atn.DecisionToState {
|
||||||
|
decisionToDFA[index] = antlr.NewDFA(state, index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterQueryLexerInit initializes any static state used to implement FilterQueryLexer. By default the
|
||||||
|
// static state used to implement the lexer is lazily initialized during the first call to
|
||||||
|
// NewFilterQueryLexer(). You can call this function if you wish to initialize the static state ahead
|
||||||
|
// of time.
|
||||||
|
func FilterQueryLexerInit() {
|
||||||
|
staticData := &FilterQueryLexerLexerStaticData
|
||||||
|
staticData.once.Do(filterquerylexerLexerInit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFilterQueryLexer produces a new lexer instance for the optional input antlr.CharStream.
|
||||||
|
func NewFilterQueryLexer(input antlr.CharStream) *FilterQueryLexer {
|
||||||
|
FilterQueryLexerInit()
|
||||||
|
l := new(FilterQueryLexer)
|
||||||
|
l.BaseLexer = antlr.NewBaseLexer(input)
|
||||||
|
staticData := &FilterQueryLexerLexerStaticData
|
||||||
|
l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache)
|
||||||
|
l.channelNames = staticData.ChannelNames
|
||||||
|
l.modeNames = staticData.ModeNames
|
||||||
|
l.RuleNames = staticData.RuleNames
|
||||||
|
l.LiteralNames = staticData.LiteralNames
|
||||||
|
l.SymbolicNames = staticData.SymbolicNames
|
||||||
|
l.GrammarFileName = "FilterQuery.g4"
|
||||||
|
// TODO: l.EOF = antlr.TokenEOF
|
||||||
|
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterQueryLexer tokens.
|
||||||
|
const (
|
||||||
|
FilterQueryLexerLPAREN = 1
|
||||||
|
FilterQueryLexerRPAREN = 2
|
||||||
|
FilterQueryLexerLBRACK = 3
|
||||||
|
FilterQueryLexerRBRACK = 4
|
||||||
|
FilterQueryLexerCOMMA = 5
|
||||||
|
FilterQueryLexerEQUALS = 6
|
||||||
|
FilterQueryLexerNOT_EQUALS = 7
|
||||||
|
FilterQueryLexerNEQ = 8
|
||||||
|
FilterQueryLexerLT = 9
|
||||||
|
FilterQueryLexerLE = 10
|
||||||
|
FilterQueryLexerGT = 11
|
||||||
|
FilterQueryLexerGE = 12
|
||||||
|
FilterQueryLexerLIKE = 13
|
||||||
|
FilterQueryLexerNOT_LIKE = 14
|
||||||
|
FilterQueryLexerILIKE = 15
|
||||||
|
FilterQueryLexerNOT_ILIKE = 16
|
||||||
|
FilterQueryLexerBETWEEN = 17
|
||||||
|
FilterQueryLexerEXISTS = 18
|
||||||
|
FilterQueryLexerREGEXP = 19
|
||||||
|
FilterQueryLexerCONTAINS = 20
|
||||||
|
FilterQueryLexerIN = 21
|
||||||
|
FilterQueryLexerNOT = 22
|
||||||
|
FilterQueryLexerAND = 23
|
||||||
|
FilterQueryLexerOR = 24
|
||||||
|
FilterQueryLexerHAS = 25
|
||||||
|
FilterQueryLexerHASANY = 26
|
||||||
|
FilterQueryLexerHASALL = 27
|
||||||
|
FilterQueryLexerHASNONE = 28
|
||||||
|
FilterQueryLexerBOOL = 29
|
||||||
|
FilterQueryLexerNUMBER = 30
|
||||||
|
FilterQueryLexerQUOTED_TEXT = 31
|
||||||
|
FilterQueryLexerKEY = 32
|
||||||
|
FilterQueryLexerWS = 33
|
||||||
|
FilterQueryLexerFREETEXT = 34
|
||||||
|
)
|
112
pkg/parser/grammar/filterquery_listener.go
Normal file
112
pkg/parser/grammar/filterquery_listener.go
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
// Code generated from grammar/FilterQuery.g4 by ANTLR 4.13.2. DO NOT EDIT.
|
||||||
|
|
||||||
|
package parser // FilterQuery
|
||||||
|
|
||||||
|
import "github.com/antlr4-go/antlr/v4"
|
||||||
|
|
||||||
|
// FilterQueryListener is a complete listener for a parse tree produced by FilterQueryParser.
|
||||||
|
type FilterQueryListener interface {
|
||||||
|
antlr.ParseTreeListener
|
||||||
|
|
||||||
|
// EnterQuery is called when entering the query production.
|
||||||
|
EnterQuery(c *QueryContext)
|
||||||
|
|
||||||
|
// EnterExpression is called when entering the expression production.
|
||||||
|
EnterExpression(c *ExpressionContext)
|
||||||
|
|
||||||
|
// EnterOrExpression is called when entering the orExpression production.
|
||||||
|
EnterOrExpression(c *OrExpressionContext)
|
||||||
|
|
||||||
|
// EnterAndExpression is called when entering the andExpression production.
|
||||||
|
EnterAndExpression(c *AndExpressionContext)
|
||||||
|
|
||||||
|
// EnterUnaryExpression is called when entering the unaryExpression production.
|
||||||
|
EnterUnaryExpression(c *UnaryExpressionContext)
|
||||||
|
|
||||||
|
// EnterPrimary is called when entering the primary production.
|
||||||
|
EnterPrimary(c *PrimaryContext)
|
||||||
|
|
||||||
|
// EnterComparison is called when entering the comparison production.
|
||||||
|
EnterComparison(c *ComparisonContext)
|
||||||
|
|
||||||
|
// EnterInClause is called when entering the inClause production.
|
||||||
|
EnterInClause(c *InClauseContext)
|
||||||
|
|
||||||
|
// EnterNotInClause is called when entering the notInClause production.
|
||||||
|
EnterNotInClause(c *NotInClauseContext)
|
||||||
|
|
||||||
|
// EnterValueList is called when entering the valueList production.
|
||||||
|
EnterValueList(c *ValueListContext)
|
||||||
|
|
||||||
|
// EnterFullText is called when entering the fullText production.
|
||||||
|
EnterFullText(c *FullTextContext)
|
||||||
|
|
||||||
|
// EnterFunctionCall is called when entering the functionCall production.
|
||||||
|
EnterFunctionCall(c *FunctionCallContext)
|
||||||
|
|
||||||
|
// EnterFunctionParamList is called when entering the functionParamList production.
|
||||||
|
EnterFunctionParamList(c *FunctionParamListContext)
|
||||||
|
|
||||||
|
// EnterFunctionParam is called when entering the functionParam production.
|
||||||
|
EnterFunctionParam(c *FunctionParamContext)
|
||||||
|
|
||||||
|
// EnterArray is called when entering the array production.
|
||||||
|
EnterArray(c *ArrayContext)
|
||||||
|
|
||||||
|
// EnterValue is called when entering the value production.
|
||||||
|
EnterValue(c *ValueContext)
|
||||||
|
|
||||||
|
// EnterKey is called when entering the key production.
|
||||||
|
EnterKey(c *KeyContext)
|
||||||
|
|
||||||
|
// ExitQuery is called when exiting the query production.
|
||||||
|
ExitQuery(c *QueryContext)
|
||||||
|
|
||||||
|
// ExitExpression is called when exiting the expression production.
|
||||||
|
ExitExpression(c *ExpressionContext)
|
||||||
|
|
||||||
|
// ExitOrExpression is called when exiting the orExpression production.
|
||||||
|
ExitOrExpression(c *OrExpressionContext)
|
||||||
|
|
||||||
|
// ExitAndExpression is called when exiting the andExpression production.
|
||||||
|
ExitAndExpression(c *AndExpressionContext)
|
||||||
|
|
||||||
|
// ExitUnaryExpression is called when exiting the unaryExpression production.
|
||||||
|
ExitUnaryExpression(c *UnaryExpressionContext)
|
||||||
|
|
||||||
|
// ExitPrimary is called when exiting the primary production.
|
||||||
|
ExitPrimary(c *PrimaryContext)
|
||||||
|
|
||||||
|
// ExitComparison is called when exiting the comparison production.
|
||||||
|
ExitComparison(c *ComparisonContext)
|
||||||
|
|
||||||
|
// ExitInClause is called when exiting the inClause production.
|
||||||
|
ExitInClause(c *InClauseContext)
|
||||||
|
|
||||||
|
// ExitNotInClause is called when exiting the notInClause production.
|
||||||
|
ExitNotInClause(c *NotInClauseContext)
|
||||||
|
|
||||||
|
// ExitValueList is called when exiting the valueList production.
|
||||||
|
ExitValueList(c *ValueListContext)
|
||||||
|
|
||||||
|
// ExitFullText is called when exiting the fullText production.
|
||||||
|
ExitFullText(c *FullTextContext)
|
||||||
|
|
||||||
|
// ExitFunctionCall is called when exiting the functionCall production.
|
||||||
|
ExitFunctionCall(c *FunctionCallContext)
|
||||||
|
|
||||||
|
// ExitFunctionParamList is called when exiting the functionParamList production.
|
||||||
|
ExitFunctionParamList(c *FunctionParamListContext)
|
||||||
|
|
||||||
|
// ExitFunctionParam is called when exiting the functionParam production.
|
||||||
|
ExitFunctionParam(c *FunctionParamContext)
|
||||||
|
|
||||||
|
// ExitArray is called when exiting the array production.
|
||||||
|
ExitArray(c *ArrayContext)
|
||||||
|
|
||||||
|
// ExitValue is called when exiting the value production.
|
||||||
|
ExitValue(c *ValueContext)
|
||||||
|
|
||||||
|
// ExitKey is called when exiting the key production.
|
||||||
|
ExitKey(c *KeyContext)
|
||||||
|
}
|
3539
pkg/parser/grammar/filterquery_parser.go
Normal file
3539
pkg/parser/grammar/filterquery_parser.go
Normal file
File diff suppressed because it is too large
Load Diff
61
pkg/parser/grammar/filterquery_visitor.go
Normal file
61
pkg/parser/grammar/filterquery_visitor.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Code generated from grammar/FilterQuery.g4 by ANTLR 4.13.2. DO NOT EDIT.
|
||||||
|
|
||||||
|
package parser // FilterQuery
|
||||||
|
|
||||||
|
import "github.com/antlr4-go/antlr/v4"
|
||||||
|
|
||||||
|
// A complete Visitor for a parse tree produced by FilterQueryParser.
|
||||||
|
type FilterQueryVisitor interface {
|
||||||
|
antlr.ParseTreeVisitor
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#query.
|
||||||
|
VisitQuery(ctx *QueryContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#expression.
|
||||||
|
VisitExpression(ctx *ExpressionContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#orExpression.
|
||||||
|
VisitOrExpression(ctx *OrExpressionContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#andExpression.
|
||||||
|
VisitAndExpression(ctx *AndExpressionContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#unaryExpression.
|
||||||
|
VisitUnaryExpression(ctx *UnaryExpressionContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#primary.
|
||||||
|
VisitPrimary(ctx *PrimaryContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#comparison.
|
||||||
|
VisitComparison(ctx *ComparisonContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#inClause.
|
||||||
|
VisitInClause(ctx *InClauseContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#notInClause.
|
||||||
|
VisitNotInClause(ctx *NotInClauseContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#valueList.
|
||||||
|
VisitValueList(ctx *ValueListContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#fullText.
|
||||||
|
VisitFullText(ctx *FullTextContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#functionCall.
|
||||||
|
VisitFunctionCall(ctx *FunctionCallContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#functionParamList.
|
||||||
|
VisitFunctionParamList(ctx *FunctionParamListContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#functionParam.
|
||||||
|
VisitFunctionParam(ctx *FunctionParamContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#array.
|
||||||
|
VisitArray(ctx *ArrayContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#value.
|
||||||
|
VisitValue(ctx *ValueContext) interface{}
|
||||||
|
|
||||||
|
// Visit a parse tree produced by FilterQueryParser#key.
|
||||||
|
VisitKey(ctx *KeyContext) interface{}
|
||||||
|
}
|
11
scripts/grammar/generate-go-parser.sh
Executable file
11
scripts/grammar/generate-go-parser.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Generating Go parser..."
|
||||||
|
# Create output directory if it doesn't exist
|
||||||
|
mkdir -p pkg/parser
|
||||||
|
|
||||||
|
# Generate Go parser
|
||||||
|
antlr -visitor -Dlanguage=Go -o pkg/parser grammar/FilterQuery.g4
|
||||||
|
|
||||||
|
echo "Go parser generation complete"
|
Loading…
x
Reference in New Issue
Block a user