feat: support for hasToken (#8891)

* feat: support for hasToken

* fix: address comments

* fix: address comments
This commit is contained in:
Nityananda Gohain 2025-08-26 11:28:31 +05:30 committed by GitHub
parent ac7d8bcde2
commit 514bceca34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 600 additions and 554 deletions

View File

@ -107,7 +107,7 @@ fullText
* ... * ...
*/ */
functionCall functionCall
: (HAS | HASANY | HASALL) LPAREN functionParamList RPAREN : (HASTOKEN | HAS | HASANY | HASALL) LPAREN functionParamList RPAREN
; ;
// Function parameters can be keys, single scalar values, or arrays // Function parameters can be keys, single scalar values, or arrays
@ -180,6 +180,7 @@ AND : [Aa][Nn][Dd] ;
OR : [Oo][Rr] ; OR : [Oo][Rr] ;
// For easy referencing in function calls // For easy referencing in function calls
HASTOKEN : [Hh][Aa][Ss][Tt][Oo][Kk][Ee][Nn];
HAS : [Hh][Aa][Ss] ; HAS : [Hh][Aa][Ss] ;
HASANY : [Hh][Aa][Ss][Aa][Nn][Yy] ; HASANY : [Hh][Aa][Ss][Aa][Nn][Yy] ;
HASALL : [Hh][Aa][Ss][Aa][Ll][Ll] ; HASALL : [Hh][Aa][Ss][Aa][Ll][Ll] ;

View File

@ -236,18 +236,19 @@ func (r *WhereClauseRewriter) VisitComparison(ctx *parser.ComparisonContext) int
} }
} else if ctx.LIKE() != nil || ctx.ILIKE() != nil { } else if ctx.LIKE() != nil || ctx.ILIKE() != nil {
if ctx.LIKE() != nil { if ctx.LIKE() != nil {
if ctx.NOT() != nil {
r.rewritten.WriteString(" NOT LIKE ")
} else {
r.rewritten.WriteString(" LIKE ") r.rewritten.WriteString(" LIKE ")
}
} else {
if ctx.NOT() != nil {
r.rewritten.WriteString(" NOT ILIKE ")
} else { } else {
r.rewritten.WriteString(" ILIKE ") r.rewritten.WriteString(" ILIKE ")
} }
if ctx.Value(0) != nil {
r.rewritten.WriteString(ctx.Value(0).GetText())
}
} else if ctx.NOT_LIKE() != nil || ctx.NOT_ILIKE() != nil {
if ctx.NOT_LIKE() != nil {
r.rewritten.WriteString(" NOT LIKE ")
} else {
r.rewritten.WriteString(" NOT ILIKE ")
} }
if ctx.Value(0) != nil { if ctx.Value(0) != nil {
r.rewritten.WriteString(ctx.Value(0).GetText()) r.rewritten.WriteString(ctx.Value(0).GetText())
@ -367,6 +368,8 @@ func (r *WhereClauseRewriter) VisitFunctionCall(ctx *parser.FunctionCallContext)
r.rewritten.WriteString("hasany") r.rewritten.WriteString("hasany")
} else if ctx.HASALL() != nil { } else if ctx.HASALL() != nil {
r.rewritten.WriteString("hasall") r.rewritten.WriteString("hasall")
} else if ctx.HASTOKEN() != nil {
r.rewritten.WriteString("hasToken")
} }
r.rewritten.WriteString("(") r.rewritten.WriteString("(")

File diff suppressed because one or more lines are too long

View File

@ -11,26 +11,25 @@ LE=10
GT=11 GT=11
GE=12 GE=12
LIKE=13 LIKE=13
NOT_LIKE=14 ILIKE=14
ILIKE=15 BETWEEN=15
NOT_ILIKE=16 EXISTS=16
BETWEEN=17 REGEXP=17
EXISTS=18 CONTAINS=18
REGEXP=19 IN=19
CONTAINS=20 NOT=20
IN=21 AND=21
NOT=22 OR=22
AND=23 HASTOKEN=23
OR=24 HAS=24
HAS=25 HASANY=25
HASANY=26 HASALL=26
HASALL=27 BOOL=27
BOOL=28 NUMBER=28
NUMBER=29 QUOTED_TEXT=29
QUOTED_TEXT=30 KEY=30
KEY=31 WS=31
WS=32 FREETEXT=32
FREETEXT=33
'('=1 '('=1
')'=2 ')'=2
'['=3 '['=3

File diff suppressed because one or more lines are too long

View File

@ -11,26 +11,25 @@ LE=10
GT=11 GT=11
GE=12 GE=12
LIKE=13 LIKE=13
NOT_LIKE=14 ILIKE=14
ILIKE=15 BETWEEN=15
NOT_ILIKE=16 EXISTS=16
BETWEEN=17 REGEXP=17
EXISTS=18 CONTAINS=18
REGEXP=19 IN=19
CONTAINS=20 NOT=20
IN=21 AND=21
NOT=22 OR=22
AND=23 HASTOKEN=23
OR=24 HAS=24
HAS=25 HASANY=25
HASANY=26 HASALL=26
HASALL=27 BOOL=27
BOOL=28 NUMBER=28
NUMBER=29 QUOTED_TEXT=29
QUOTED_TEXT=30 KEY=30
KEY=31 WS=31
WS=32 FREETEXT=32
FREETEXT=33
'('=1 '('=1
')'=2 ')'=2
'['=3 '['=3

View File

@ -48,181 +48,169 @@ func filterquerylexerLexerInit() {
} }
staticData.SymbolicNames = []string{ staticData.SymbolicNames = []string{
"", "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS", "", "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS",
"NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE", "NEQ", "LT", "LE", "GT", "GE", "LIKE", "ILIKE", "BETWEEN", "EXISTS",
"BETWEEN", "EXISTS", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR", "HASTOKEN", "HAS", "HASANY",
"HAS", "HASANY", "HASALL", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", "WS", "HASALL", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", "WS", "FREETEXT",
"FREETEXT",
} }
staticData.RuleNames = []string{ staticData.RuleNames = []string{
"LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS", "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS",
"NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE", "NEQ", "LT", "LE", "GT", "GE", "LIKE", "ILIKE", "BETWEEN", "EXISTS",
"BETWEEN", "EXISTS", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR", "HASTOKEN", "HAS", "HASANY",
"HAS", "HASANY", "HASALL", "BOOL", "SIGN", "NUMBER", "QUOTED_TEXT", "HASALL", "BOOL", "SIGN", "NUMBER", "QUOTED_TEXT", "SEGMENT", "EMPTY_BRACKS",
"SEGMENT", "EMPTY_BRACKS", "OLD_JSON_BRACKS", "KEY", "WS", "DIGIT", "OLD_JSON_BRACKS", "KEY", "WS", "DIGIT", "FREETEXT",
"FREETEXT",
} }
staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.PredictionContextCache = antlr.NewPredictionContextCache()
staticData.serializedATN = []int32{ staticData.serializedATN = []int32{
4, 0, 33, 334, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 0, 32, 314, 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, 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, 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, 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, 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, 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, 2, 35, 7, 35, 2, 36, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36,
7, 36, 2, 37, 7, 37, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 7, 36, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5,
4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 91, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 5, 1, 5, 3, 5, 89, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1,
1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1,
1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 4, 13, 118, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14,
8, 13, 11, 13, 12, 13, 119, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1,
14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 4, 15, 137, 15, 1, 15, 3, 15, 132, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16,
8, 15, 11, 15, 12, 15, 138, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 149,
16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 8, 17, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1,
1, 17, 1, 17, 1, 17, 3, 17, 161, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22,
18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1,
3, 19, 178, 8, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25,
22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 201,
1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 8, 26, 1, 27, 1, 27, 1, 28, 3, 28, 206, 8, 28, 1, 28, 4, 28, 209, 8, 28,
26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 11, 28, 12, 28, 210, 1, 28, 1, 28, 5, 28, 215, 8, 28, 10, 28, 12, 28, 218,
1, 27, 1, 27, 3, 27, 221, 8, 27, 1, 28, 1, 28, 1, 29, 3, 29, 226, 8, 29, 9, 28, 3, 28, 220, 8, 28, 1, 28, 1, 28, 3, 28, 224, 8, 28, 1, 28, 4, 28,
1, 29, 4, 29, 229, 8, 29, 11, 29, 12, 29, 230, 1, 29, 1, 29, 5, 29, 235, 227, 8, 28, 11, 28, 12, 28, 228, 3, 28, 231, 8, 28, 1, 28, 3, 28, 234,
8, 29, 10, 29, 12, 29, 238, 9, 29, 3, 29, 240, 8, 29, 1, 29, 1, 29, 3, 8, 28, 1, 28, 1, 28, 4, 28, 238, 8, 28, 11, 28, 12, 28, 239, 1, 28, 1,
29, 244, 8, 29, 1, 29, 4, 29, 247, 8, 29, 11, 29, 12, 29, 248, 3, 29, 251, 28, 3, 28, 244, 8, 28, 1, 28, 4, 28, 247, 8, 28, 11, 28, 12, 28, 248, 3,
8, 29, 1, 29, 3, 29, 254, 8, 29, 1, 29, 1, 29, 4, 29, 258, 8, 29, 11, 29, 28, 251, 8, 28, 3, 28, 253, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 5, 29, 259,
12, 29, 259, 1, 29, 1, 29, 3, 29, 264, 8, 29, 1, 29, 4, 29, 267, 8, 29, 8, 29, 10, 29, 12, 29, 262, 9, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 5,
11, 29, 12, 29, 268, 3, 29, 271, 8, 29, 3, 29, 273, 8, 29, 1, 30, 1, 30, 29, 269, 8, 29, 10, 29, 12, 29, 272, 9, 29, 1, 29, 3, 29, 275, 8, 29, 1,
1, 30, 1, 30, 5, 30, 279, 8, 30, 10, 30, 12, 30, 282, 9, 30, 1, 30, 1, 30, 1, 30, 5, 30, 279, 8, 30, 10, 30, 12, 30, 282, 9, 30, 1, 31, 1, 31,
30, 1, 30, 1, 30, 1, 30, 5, 30, 289, 8, 30, 10, 30, 12, 30, 292, 9, 30, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 5,
1, 30, 3, 30, 295, 8, 30, 1, 31, 1, 31, 5, 31, 299, 8, 31, 10, 31, 12, 33, 296, 8, 33, 10, 33, 12, 33, 299, 9, 33, 1, 34, 4, 34, 302, 8, 34, 11,
31, 302, 9, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 34, 12, 34, 303, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 4, 36, 311, 8, 36,
1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 316, 8, 34, 10, 34, 12, 34, 319, 9, 11, 36, 12, 36, 312, 0, 0, 37, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13,
34, 1, 35, 4, 35, 322, 8, 35, 11, 35, 12, 35, 323, 1, 35, 1, 35, 1, 36, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16,
1, 36, 1, 37, 4, 37, 331, 8, 37, 11, 37, 12, 37, 332, 0, 0, 38, 1, 1, 3, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25,
2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 51, 26, 53, 27, 55, 0, 57, 28, 59, 29, 61, 0, 63, 0, 65, 0, 67, 30, 69,
25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 31, 71, 0, 73, 32, 1, 0, 29, 2, 0, 76, 76, 108, 108, 2, 0, 73, 73, 105,
43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 0, 59, 29, 105, 2, 0, 75, 75, 107, 107, 2, 0, 69, 69, 101, 101, 2, 0, 66, 66, 98,
61, 30, 63, 0, 65, 0, 67, 0, 69, 31, 71, 32, 73, 0, 75, 33, 1, 0, 30, 2, 98, 2, 0, 84, 84, 116, 116, 2, 0, 87, 87, 119, 119, 2, 0, 78, 78, 110,
0, 76, 76, 108, 108, 2, 0, 73, 73, 105, 105, 2, 0, 75, 75, 107, 107, 2, 110, 2, 0, 88, 88, 120, 120, 2, 0, 83, 83, 115, 115, 2, 0, 82, 82, 114,
0, 69, 69, 101, 101, 2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 114, 2, 0, 71, 71, 103, 103, 2, 0, 80, 80, 112, 112, 2, 0, 67, 67, 99,
0, 84, 84, 116, 116, 2, 0, 9, 9, 32, 32, 2, 0, 66, 66, 98, 98, 2, 0, 87, 99, 2, 0, 79, 79, 111, 111, 2, 0, 65, 65, 97, 97, 2, 0, 68, 68, 100, 100,
87, 119, 119, 2, 0, 88, 88, 120, 120, 2, 0, 83, 83, 115, 115, 2, 0, 82, 2, 0, 72, 72, 104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85, 85, 117, 117,
82, 114, 114, 2, 0, 71, 71, 103, 103, 2, 0, 80, 80, 112, 112, 2, 0, 67, 2, 0, 70, 70, 102, 102, 2, 0, 43, 43, 45, 45, 2, 0, 34, 34, 92, 92, 2,
67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 68, 68, 100, 100, 2, 0, 72, 72, 0, 39, 39, 92, 92, 4, 0, 36, 36, 65, 90, 95, 95, 97, 122, 6, 0, 36, 36,
104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85, 85, 117, 117, 2, 0, 70, 70, 45, 45, 47, 58, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1,
102, 102, 2, 0, 43, 43, 45, 45, 2, 0, 34, 34, 92, 92, 2, 0, 39, 39, 92, 0, 48, 57, 8, 0, 9, 10, 13, 13, 32, 34, 39, 41, 44, 44, 60, 62, 91, 91,
92, 4, 0, 36, 36, 65, 90, 95, 95, 97, 122, 6, 0, 36, 36, 45, 45, 47, 58, 93, 93, 336, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7,
65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57, 8, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0,
0, 9, 10, 13, 13, 32, 34, 39, 41, 44, 44, 60, 62, 91, 91, 93, 93, 358, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0,
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, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 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, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 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, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1,
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, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53,
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, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0,
1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 1, 75, 1, 0, 0, 0, 3, 77, 1, 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, 5, 79, 1, 0, 0, 0, 7, 81, 1, 0, 0, 0, 9, 83, 1, 0, 0, 0, 11, 88, 1, 0,
0, 55, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 13, 90, 1, 0, 0, 0, 15, 93, 1, 0, 0, 0, 17, 96, 1, 0, 0, 0, 19, 98,
0, 0, 71, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 1, 77, 1, 0, 0, 0, 3, 79, 1, 0, 1, 0, 0, 0, 21, 101, 1, 0, 0, 0, 23, 103, 1, 0, 0, 0, 25, 106, 1, 0, 0,
0, 0, 5, 81, 1, 0, 0, 0, 7, 83, 1, 0, 0, 0, 9, 85, 1, 0, 0, 0, 11, 90, 0, 27, 111, 1, 0, 0, 0, 29, 117, 1, 0, 0, 0, 31, 125, 1, 0, 0, 0, 33, 133,
1, 0, 0, 0, 13, 92, 1, 0, 0, 0, 15, 95, 1, 0, 0, 0, 17, 98, 1, 0, 0, 0, 1, 0, 0, 0, 35, 140, 1, 0, 0, 0, 37, 150, 1, 0, 0, 0, 39, 153, 1, 0, 0,
19, 100, 1, 0, 0, 0, 21, 103, 1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 108, 0, 41, 157, 1, 0, 0, 0, 43, 161, 1, 0, 0, 0, 45, 164, 1, 0, 0, 0, 47, 173,
1, 0, 0, 0, 27, 113, 1, 0, 0, 0, 29, 126, 1, 0, 0, 0, 31, 132, 1, 0, 0, 1, 0, 0, 0, 49, 177, 1, 0, 0, 0, 51, 184, 1, 0, 0, 0, 53, 200, 1, 0, 0,
0, 33, 146, 1, 0, 0, 0, 35, 154, 1, 0, 0, 0, 37, 162, 1, 0, 0, 0, 39, 169, 0, 55, 202, 1, 0, 0, 0, 57, 252, 1, 0, 0, 0, 59, 274, 1, 0, 0, 0, 61, 276,
1, 0, 0, 0, 41, 179, 1, 0, 0, 0, 43, 182, 1, 0, 0, 0, 45, 186, 1, 0, 0, 1, 0, 0, 0, 63, 283, 1, 0, 0, 0, 65, 286, 1, 0, 0, 0, 67, 290, 1, 0, 0,
0, 47, 190, 1, 0, 0, 0, 49, 193, 1, 0, 0, 0, 51, 197, 1, 0, 0, 0, 53, 204, 0, 69, 301, 1, 0, 0, 0, 71, 307, 1, 0, 0, 0, 73, 310, 1, 0, 0, 0, 75, 76,
1, 0, 0, 0, 55, 220, 1, 0, 0, 0, 57, 222, 1, 0, 0, 0, 59, 272, 1, 0, 0, 5, 40, 0, 0, 76, 2, 1, 0, 0, 0, 77, 78, 5, 41, 0, 0, 78, 4, 1, 0, 0, 0,
0, 61, 294, 1, 0, 0, 0, 63, 296, 1, 0, 0, 0, 65, 303, 1, 0, 0, 0, 67, 306, 79, 80, 5, 91, 0, 0, 80, 6, 1, 0, 0, 0, 81, 82, 5, 93, 0, 0, 82, 8, 1,
1, 0, 0, 0, 69, 310, 1, 0, 0, 0, 71, 321, 1, 0, 0, 0, 73, 327, 1, 0, 0, 0, 0, 0, 83, 84, 5, 44, 0, 0, 84, 10, 1, 0, 0, 0, 85, 89, 5, 61, 0, 0,
0, 75, 330, 1, 0, 0, 0, 77, 78, 5, 40, 0, 0, 78, 2, 1, 0, 0, 0, 79, 80, 86, 87, 5, 61, 0, 0, 87, 89, 5, 61, 0, 0, 88, 85, 1, 0, 0, 0, 88, 86, 1,
5, 41, 0, 0, 80, 4, 1, 0, 0, 0, 81, 82, 5, 91, 0, 0, 82, 6, 1, 0, 0, 0, 0, 0, 0, 89, 12, 1, 0, 0, 0, 90, 91, 5, 33, 0, 0, 91, 92, 5, 61, 0, 0,
83, 84, 5, 93, 0, 0, 84, 8, 1, 0, 0, 0, 85, 86, 5, 44, 0, 0, 86, 10, 1, 92, 14, 1, 0, 0, 0, 93, 94, 5, 60, 0, 0, 94, 95, 5, 62, 0, 0, 95, 16, 1,
0, 0, 0, 87, 91, 5, 61, 0, 0, 88, 89, 5, 61, 0, 0, 89, 91, 5, 61, 0, 0, 0, 0, 0, 96, 97, 5, 60, 0, 0, 97, 18, 1, 0, 0, 0, 98, 99, 5, 60, 0, 0,
90, 87, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 12, 1, 0, 0, 0, 92, 93, 5, 99, 100, 5, 61, 0, 0, 100, 20, 1, 0, 0, 0, 101, 102, 5, 62, 0, 0, 102,
33, 0, 0, 93, 94, 5, 61, 0, 0, 94, 14, 1, 0, 0, 0, 95, 96, 5, 60, 0, 0, 22, 1, 0, 0, 0, 103, 104, 5, 62, 0, 0, 104, 105, 5, 61, 0, 0, 105, 24,
96, 97, 5, 62, 0, 0, 97, 16, 1, 0, 0, 0, 98, 99, 5, 60, 0, 0, 99, 18, 1, 1, 0, 0, 0, 106, 107, 7, 0, 0, 0, 107, 108, 7, 1, 0, 0, 108, 109, 7, 2,
0, 0, 0, 100, 101, 5, 60, 0, 0, 101, 102, 5, 61, 0, 0, 102, 20, 1, 0, 0, 0, 0, 109, 110, 7, 3, 0, 0, 110, 26, 1, 0, 0, 0, 111, 112, 7, 1, 0, 0,
0, 103, 104, 5, 62, 0, 0, 104, 22, 1, 0, 0, 0, 105, 106, 5, 62, 0, 0, 106, 112, 113, 7, 0, 0, 0, 113, 114, 7, 1, 0, 0, 114, 115, 7, 2, 0, 0, 115,
107, 5, 61, 0, 0, 107, 24, 1, 0, 0, 0, 108, 109, 7, 0, 0, 0, 109, 110, 116, 7, 3, 0, 0, 116, 28, 1, 0, 0, 0, 117, 118, 7, 4, 0, 0, 118, 119, 7,
7, 1, 0, 0, 110, 111, 7, 2, 0, 0, 111, 112, 7, 3, 0, 0, 112, 26, 1, 0, 3, 0, 0, 119, 120, 7, 5, 0, 0, 120, 121, 7, 6, 0, 0, 121, 122, 7, 3, 0,
0, 0, 113, 114, 7, 4, 0, 0, 114, 115, 7, 5, 0, 0, 115, 117, 7, 6, 0, 0, 0, 122, 123, 7, 3, 0, 0, 123, 124, 7, 7, 0, 0, 124, 30, 1, 0, 0, 0, 125,
116, 118, 7, 7, 0, 0, 117, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 126, 7, 3, 0, 0, 126, 127, 7, 8, 0, 0, 127, 128, 7, 1, 0, 0, 128, 129,
117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 7, 9, 0, 0, 129, 131, 7, 5, 0, 0, 130, 132, 7, 9, 0, 0, 131, 130, 1, 0,
7, 0, 0, 0, 122, 123, 7, 1, 0, 0, 123, 124, 7, 2, 0, 0, 124, 125, 7, 3, 0, 0, 131, 132, 1, 0, 0, 0, 132, 32, 1, 0, 0, 0, 133, 134, 7, 10, 0, 0,
0, 0, 125, 28, 1, 0, 0, 0, 126, 127, 7, 1, 0, 0, 127, 128, 7, 0, 0, 0, 134, 135, 7, 3, 0, 0, 135, 136, 7, 11, 0, 0, 136, 137, 7, 3, 0, 0, 137,
128, 129, 7, 1, 0, 0, 129, 130, 7, 2, 0, 0, 130, 131, 7, 3, 0, 0, 131, 138, 7, 8, 0, 0, 138, 139, 7, 12, 0, 0, 139, 34, 1, 0, 0, 0, 140, 141,
30, 1, 0, 0, 0, 132, 133, 7, 4, 0, 0, 133, 134, 7, 5, 0, 0, 134, 136, 7, 7, 13, 0, 0, 141, 142, 7, 14, 0, 0, 142, 143, 7, 7, 0, 0, 143, 144, 7,
6, 0, 0, 135, 137, 7, 7, 0, 0, 136, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 5, 0, 0, 144, 145, 7, 15, 0, 0, 145, 146, 7, 1, 0, 0, 146, 148, 7, 7, 0,
0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 0, 147, 149, 7, 9, 0, 0, 148, 147, 1, 0, 0, 0, 148, 149, 1, 0, 0, 0, 149,
141, 7, 1, 0, 0, 141, 142, 7, 0, 0, 0, 142, 143, 7, 1, 0, 0, 143, 144, 36, 1, 0, 0, 0, 150, 151, 7, 1, 0, 0, 151, 152, 7, 7, 0, 0, 152, 38, 1,
7, 2, 0, 0, 144, 145, 7, 3, 0, 0, 145, 32, 1, 0, 0, 0, 146, 147, 7, 8, 0, 0, 0, 153, 154, 7, 7, 0, 0, 154, 155, 7, 14, 0, 0, 155, 156, 7, 5, 0,
0, 0, 147, 148, 7, 3, 0, 0, 148, 149, 7, 6, 0, 0, 149, 150, 7, 9, 0, 0, 0, 156, 40, 1, 0, 0, 0, 157, 158, 7, 15, 0, 0, 158, 159, 7, 7, 0, 0, 159,
150, 151, 7, 3, 0, 0, 151, 152, 7, 3, 0, 0, 152, 153, 7, 4, 0, 0, 153, 160, 7, 16, 0, 0, 160, 42, 1, 0, 0, 0, 161, 162, 7, 14, 0, 0, 162, 163,
34, 1, 0, 0, 0, 154, 155, 7, 3, 0, 0, 155, 156, 7, 10, 0, 0, 156, 157, 7, 10, 0, 0, 163, 44, 1, 0, 0, 0, 164, 165, 7, 17, 0, 0, 165, 166, 7, 15,
7, 1, 0, 0, 157, 158, 7, 11, 0, 0, 158, 160, 7, 6, 0, 0, 159, 161, 7, 11, 0, 0, 166, 167, 7, 9, 0, 0, 167, 168, 7, 5, 0, 0, 168, 169, 7, 14, 0, 0,
0, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 36, 1, 0, 0, 0, 169, 170, 7, 2, 0, 0, 170, 171, 7, 3, 0, 0, 171, 172, 7, 7, 0, 0, 172,
162, 163, 7, 12, 0, 0, 163, 164, 7, 3, 0, 0, 164, 165, 7, 13, 0, 0, 165, 46, 1, 0, 0, 0, 173, 174, 7, 17, 0, 0, 174, 175, 7, 15, 0, 0, 175, 176,
166, 7, 3, 0, 0, 166, 167, 7, 10, 0, 0, 167, 168, 7, 14, 0, 0, 168, 38, 7, 9, 0, 0, 176, 48, 1, 0, 0, 0, 177, 178, 7, 17, 0, 0, 178, 179, 7, 15,
1, 0, 0, 0, 169, 170, 7, 15, 0, 0, 170, 171, 7, 5, 0, 0, 171, 172, 7, 4, 0, 0, 179, 180, 7, 9, 0, 0, 180, 181, 7, 15, 0, 0, 181, 182, 7, 7, 0, 0,
0, 0, 172, 173, 7, 6, 0, 0, 173, 174, 7, 16, 0, 0, 174, 175, 7, 1, 0, 0, 182, 183, 7, 18, 0, 0, 183, 50, 1, 0, 0, 0, 184, 185, 7, 17, 0, 0, 185,
175, 177, 7, 4, 0, 0, 176, 178, 7, 11, 0, 0, 177, 176, 1, 0, 0, 0, 177, 186, 7, 15, 0, 0, 186, 187, 7, 9, 0, 0, 187, 188, 7, 15, 0, 0, 188, 189,
178, 1, 0, 0, 0, 178, 40, 1, 0, 0, 0, 179, 180, 7, 1, 0, 0, 180, 181, 7, 7, 0, 0, 0, 189, 190, 7, 0, 0, 0, 190, 52, 1, 0, 0, 0, 191, 192, 7, 5,
4, 0, 0, 181, 42, 1, 0, 0, 0, 182, 183, 7, 4, 0, 0, 183, 184, 7, 5, 0, 0, 0, 192, 193, 7, 10, 0, 0, 193, 194, 7, 19, 0, 0, 194, 201, 7, 3, 0,
0, 184, 185, 7, 6, 0, 0, 185, 44, 1, 0, 0, 0, 186, 187, 7, 16, 0, 0, 187, 0, 195, 196, 7, 20, 0, 0, 196, 197, 7, 15, 0, 0, 197, 198, 7, 0, 0, 0,
188, 7, 4, 0, 0, 188, 189, 7, 17, 0, 0, 189, 46, 1, 0, 0, 0, 190, 191, 198, 199, 7, 9, 0, 0, 199, 201, 7, 3, 0, 0, 200, 191, 1, 0, 0, 0, 200,
7, 5, 0, 0, 191, 192, 7, 12, 0, 0, 192, 48, 1, 0, 0, 0, 193, 194, 7, 18, 195, 1, 0, 0, 0, 201, 54, 1, 0, 0, 0, 202, 203, 7, 21, 0, 0, 203, 56, 1,
0, 0, 194, 195, 7, 16, 0, 0, 195, 196, 7, 11, 0, 0, 196, 50, 1, 0, 0, 0, 0, 0, 0, 204, 206, 3, 55, 27, 0, 205, 204, 1, 0, 0, 0, 205, 206, 1, 0,
197, 198, 7, 18, 0, 0, 198, 199, 7, 16, 0, 0, 199, 200, 7, 11, 0, 0, 200, 0, 0, 206, 208, 1, 0, 0, 0, 207, 209, 3, 71, 35, 0, 208, 207, 1, 0, 0,
201, 7, 16, 0, 0, 201, 202, 7, 4, 0, 0, 202, 203, 7, 19, 0, 0, 203, 52, 0, 209, 210, 1, 0, 0, 0, 210, 208, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211,
1, 0, 0, 0, 204, 205, 7, 18, 0, 0, 205, 206, 7, 16, 0, 0, 206, 207, 7, 219, 1, 0, 0, 0, 212, 216, 5, 46, 0, 0, 213, 215, 3, 71, 35, 0, 214, 213,
11, 0, 0, 207, 208, 7, 16, 0, 0, 208, 209, 7, 0, 0, 0, 209, 210, 7, 0, 1, 0, 0, 0, 215, 218, 1, 0, 0, 0, 216, 214, 1, 0, 0, 0, 216, 217, 1, 0,
0, 0, 210, 54, 1, 0, 0, 0, 211, 212, 7, 6, 0, 0, 212, 213, 7, 12, 0, 0, 0, 0, 217, 220, 1, 0, 0, 0, 218, 216, 1, 0, 0, 0, 219, 212, 1, 0, 0, 0,
213, 214, 7, 20, 0, 0, 214, 221, 7, 3, 0, 0, 215, 216, 7, 21, 0, 0, 216, 219, 220, 1, 0, 0, 0, 220, 230, 1, 0, 0, 0, 221, 223, 7, 3, 0, 0, 222,
217, 7, 16, 0, 0, 217, 218, 7, 0, 0, 0, 218, 219, 7, 11, 0, 0, 219, 221, 224, 3, 55, 27, 0, 223, 222, 1, 0, 0, 0, 223, 224, 1, 0, 0, 0, 224, 226,
7, 3, 0, 0, 220, 211, 1, 0, 0, 0, 220, 215, 1, 0, 0, 0, 221, 56, 1, 0, 1, 0, 0, 0, 225, 227, 3, 71, 35, 0, 226, 225, 1, 0, 0, 0, 227, 228, 1,
0, 0, 222, 223, 7, 22, 0, 0, 223, 58, 1, 0, 0, 0, 224, 226, 3, 57, 28, 0, 0, 0, 228, 226, 1, 0, 0, 0, 228, 229, 1, 0, 0, 0, 229, 231, 1, 0, 0,
0, 225, 224, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 228, 1, 0, 0, 0, 227, 0, 230, 221, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 253, 1, 0, 0, 0, 232,
229, 3, 73, 36, 0, 228, 227, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 228, 234, 3, 55, 27, 0, 233, 232, 1, 0, 0, 0, 233, 234, 1, 0, 0, 0, 234, 235,
1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 239, 1, 0, 0, 0, 232, 236, 5, 46, 1, 0, 0, 0, 235, 237, 5, 46, 0, 0, 236, 238, 3, 71, 35, 0, 237, 236, 1,
0, 0, 233, 235, 3, 73, 36, 0, 234, 233, 1, 0, 0, 0, 235, 238, 1, 0, 0, 0, 0, 0, 238, 239, 1, 0, 0, 0, 239, 237, 1, 0, 0, 0, 239, 240, 1, 0, 0,
0, 236, 234, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 240, 1, 0, 0, 0, 238, 0, 240, 250, 1, 0, 0, 0, 241, 243, 7, 3, 0, 0, 242, 244, 3, 55, 27, 0,
236, 1, 0, 0, 0, 239, 232, 1, 0, 0, 0, 239, 240, 1, 0, 0, 0, 240, 250, 243, 242, 1, 0, 0, 0, 243, 244, 1, 0, 0, 0, 244, 246, 1, 0, 0, 0, 245,
1, 0, 0, 0, 241, 243, 7, 3, 0, 0, 242, 244, 3, 57, 28, 0, 243, 242, 1, 247, 3, 71, 35, 0, 246, 245, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 246,
0, 0, 0, 243, 244, 1, 0, 0, 0, 244, 246, 1, 0, 0, 0, 245, 247, 3, 73, 36, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 251, 1, 0, 0, 0, 250, 241, 1, 0,
0, 246, 245, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 248, 0, 0, 250, 251, 1, 0, 0, 0, 251, 253, 1, 0, 0, 0, 252, 205, 1, 0, 0, 0,
249, 1, 0, 0, 0, 249, 251, 1, 0, 0, 0, 250, 241, 1, 0, 0, 0, 250, 251, 252, 233, 1, 0, 0, 0, 253, 58, 1, 0, 0, 0, 254, 260, 5, 34, 0, 0, 255,
1, 0, 0, 0, 251, 273, 1, 0, 0, 0, 252, 254, 3, 57, 28, 0, 253, 252, 1, 259, 8, 22, 0, 0, 256, 257, 5, 92, 0, 0, 257, 259, 9, 0, 0, 0, 258, 255,
0, 0, 0, 253, 254, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 257, 5, 46, 0, 1, 0, 0, 0, 258, 256, 1, 0, 0, 0, 259, 262, 1, 0, 0, 0, 260, 258, 1, 0,
0, 256, 258, 3, 73, 36, 0, 257, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 0, 0, 260, 261, 1, 0, 0, 0, 261, 263, 1, 0, 0, 0, 262, 260, 1, 0, 0, 0,
259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 270, 1, 0, 0, 0, 261, 263, 275, 5, 34, 0, 0, 264, 270, 5, 39, 0, 0, 265, 269, 8, 23, 0, 0, 266,
263, 7, 3, 0, 0, 262, 264, 3, 57, 28, 0, 263, 262, 1, 0, 0, 0, 263, 264, 267, 5, 92, 0, 0, 267, 269, 9, 0, 0, 0, 268, 265, 1, 0, 0, 0, 268, 266,
1, 0, 0, 0, 264, 266, 1, 0, 0, 0, 265, 267, 3, 73, 36, 0, 266, 265, 1, 1, 0, 0, 0, 269, 272, 1, 0, 0, 0, 270, 268, 1, 0, 0, 0, 270, 271, 1, 0,
0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 0, 271, 273, 1, 0, 0, 0, 272, 270, 1, 0, 0, 0, 273, 275, 5, 39, 0, 0,
0, 269, 271, 1, 0, 0, 0, 270, 261, 1, 0, 0, 0, 270, 271, 1, 0, 0, 0, 271, 274, 254, 1, 0, 0, 0, 274, 264, 1, 0, 0, 0, 275, 60, 1, 0, 0, 0, 276, 280,
273, 1, 0, 0, 0, 272, 225, 1, 0, 0, 0, 272, 253, 1, 0, 0, 0, 273, 60, 1, 7, 24, 0, 0, 277, 279, 7, 25, 0, 0, 278, 277, 1, 0, 0, 0, 279, 282, 1,
0, 0, 0, 274, 280, 5, 34, 0, 0, 275, 279, 8, 23, 0, 0, 276, 277, 5, 92, 0, 0, 0, 280, 278, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 62, 1, 0, 0,
0, 0, 277, 279, 9, 0, 0, 0, 278, 275, 1, 0, 0, 0, 278, 276, 1, 0, 0, 0, 0, 282, 280, 1, 0, 0, 0, 283, 284, 5, 91, 0, 0, 284, 285, 5, 93, 0, 0,
279, 282, 1, 0, 0, 0, 280, 278, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 285, 64, 1, 0, 0, 0, 286, 287, 5, 91, 0, 0, 287, 288, 5, 42, 0, 0, 288,
283, 1, 0, 0, 0, 282, 280, 1, 0, 0, 0, 283, 295, 5, 34, 0, 0, 284, 290, 289, 5, 93, 0, 0, 289, 66, 1, 0, 0, 0, 290, 297, 3, 61, 30, 0, 291, 292,
5, 39, 0, 0, 285, 289, 8, 24, 0, 0, 286, 287, 5, 92, 0, 0, 287, 289, 9, 5, 46, 0, 0, 292, 296, 3, 61, 30, 0, 293, 296, 3, 63, 31, 0, 294, 296,
0, 0, 0, 288, 285, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 289, 292, 1, 0, 0, 3, 65, 32, 0, 295, 291, 1, 0, 0, 0, 295, 293, 1, 0, 0, 0, 295, 294, 1,
0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 293, 1, 0, 0, 0, 292, 0, 0, 0, 296, 299, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 297, 298, 1, 0, 0,
290, 1, 0, 0, 0, 293, 295, 5, 39, 0, 0, 294, 274, 1, 0, 0, 0, 294, 284, 0, 298, 68, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 300, 302, 7, 26, 0, 0, 301,
1, 0, 0, 0, 295, 62, 1, 0, 0, 0, 296, 300, 7, 25, 0, 0, 297, 299, 7, 26, 300, 1, 0, 0, 0, 302, 303, 1, 0, 0, 0, 303, 301, 1, 0, 0, 0, 303, 304,
0, 0, 298, 297, 1, 0, 0, 0, 299, 302, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 306, 6, 34, 0, 0, 306, 70, 1, 0,
300, 301, 1, 0, 0, 0, 301, 64, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 303, 304, 0, 0, 307, 308, 7, 27, 0, 0, 308, 72, 1, 0, 0, 0, 309, 311, 8, 28, 0, 0,
5, 91, 0, 0, 304, 305, 5, 93, 0, 0, 305, 66, 1, 0, 0, 0, 306, 307, 5, 91, 310, 309, 1, 0, 0, 0, 311, 312, 1, 0, 0, 0, 312, 310, 1, 0, 0, 0, 312,
0, 0, 307, 308, 5, 42, 0, 0, 308, 309, 5, 93, 0, 0, 309, 68, 1, 0, 0, 0, 313, 1, 0, 0, 0, 313, 74, 1, 0, 0, 0, 28, 0, 88, 131, 148, 200, 205, 210,
310, 317, 3, 63, 31, 0, 311, 312, 5, 46, 0, 0, 312, 316, 3, 63, 31, 0, 216, 219, 223, 228, 230, 233, 239, 243, 248, 250, 252, 258, 260, 268, 270,
313, 316, 3, 65, 32, 0, 314, 316, 3, 67, 33, 0, 315, 311, 1, 0, 0, 0, 315, 274, 280, 295, 297, 303, 312, 1, 6, 0, 0,
313, 1, 0, 0, 0, 315, 314, 1, 0, 0, 0, 316, 319, 1, 0, 0, 0, 317, 315,
1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 70, 1, 0, 0, 0, 319, 317, 1, 0,
0, 0, 320, 322, 7, 27, 0, 0, 321, 320, 1, 0, 0, 0, 322, 323, 1, 0, 0, 0,
323, 321, 1, 0, 0, 0, 323, 324, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325,
326, 6, 35, 0, 0, 326, 72, 1, 0, 0, 0, 327, 328, 7, 28, 0, 0, 328, 74,
1, 0, 0, 0, 329, 331, 8, 29, 0, 0, 330, 329, 1, 0, 0, 0, 331, 332, 1, 0,
0, 0, 332, 330, 1, 0, 0, 0, 332, 333, 1, 0, 0, 0, 333, 76, 1, 0, 0, 0,
30, 0, 90, 119, 138, 160, 177, 220, 225, 230, 236, 239, 243, 248, 250,
253, 259, 263, 268, 270, 272, 278, 280, 288, 290, 294, 300, 315, 317, 323,
332, 1, 6, 0, 0,
} }
deserializer := antlr.NewATNDeserializer(nil) deserializer := antlr.NewATNDeserializer(nil)
staticData.atn = deserializer.Deserialize(staticData.serializedATN) staticData.atn = deserializer.Deserialize(staticData.serializedATN)
@ -276,24 +264,23 @@ const (
FilterQueryLexerGT = 11 FilterQueryLexerGT = 11
FilterQueryLexerGE = 12 FilterQueryLexerGE = 12
FilterQueryLexerLIKE = 13 FilterQueryLexerLIKE = 13
FilterQueryLexerNOT_LIKE = 14 FilterQueryLexerILIKE = 14
FilterQueryLexerILIKE = 15 FilterQueryLexerBETWEEN = 15
FilterQueryLexerNOT_ILIKE = 16 FilterQueryLexerEXISTS = 16
FilterQueryLexerBETWEEN = 17 FilterQueryLexerREGEXP = 17
FilterQueryLexerEXISTS = 18 FilterQueryLexerCONTAINS = 18
FilterQueryLexerREGEXP = 19 FilterQueryLexerIN = 19
FilterQueryLexerCONTAINS = 20 FilterQueryLexerNOT = 20
FilterQueryLexerIN = 21 FilterQueryLexerAND = 21
FilterQueryLexerNOT = 22 FilterQueryLexerOR = 22
FilterQueryLexerAND = 23 FilterQueryLexerHASTOKEN = 23
FilterQueryLexerOR = 24 FilterQueryLexerHAS = 24
FilterQueryLexerHAS = 25 FilterQueryLexerHASANY = 25
FilterQueryLexerHASANY = 26 FilterQueryLexerHASALL = 26
FilterQueryLexerHASALL = 27 FilterQueryLexerBOOL = 27
FilterQueryLexerBOOL = 28 FilterQueryLexerNUMBER = 28
FilterQueryLexerNUMBER = 29 FilterQueryLexerQUOTED_TEXT = 29
FilterQueryLexerQUOTED_TEXT = 30 FilterQueryLexerKEY = 30
FilterQueryLexerKEY = 31 FilterQueryLexerWS = 31
FilterQueryLexerWS = 32 FilterQueryLexerFREETEXT = 32
FilterQueryLexerFREETEXT = 33
) )

View File

@ -38,10 +38,9 @@ func filterqueryParserInit() {
} }
staticData.SymbolicNames = []string{ staticData.SymbolicNames = []string{
"", "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS", "", "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS",
"NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE", "NEQ", "LT", "LE", "GT", "GE", "LIKE", "ILIKE", "BETWEEN", "EXISTS",
"BETWEEN", "EXISTS", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR", "REGEXP", "CONTAINS", "IN", "NOT", "AND", "OR", "HASTOKEN", "HAS", "HASANY",
"HAS", "HASANY", "HASALL", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", "WS", "HASALL", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", "WS", "FREETEXT",
"FREETEXT",
} }
staticData.RuleNames = []string{ staticData.RuleNames = []string{
"query", "expression", "orExpression", "andExpression", "unaryExpression", "query", "expression", "orExpression", "andExpression", "unaryExpression",
@ -51,7 +50,7 @@ func filterqueryParserInit() {
} }
staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.PredictionContextCache = antlr.NewPredictionContextCache()
staticData.serializedATN = []int32{ staticData.serializedATN = []int32{
4, 1, 33, 218, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 32, 219, 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, 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, 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, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43, 2, 16, 7, 16, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43,
@ -64,87 +63,87 @@ func filterqueryParserInit() {
6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1,
6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1,
6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1,
6, 3, 6, 149, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 6, 1, 6, 3, 6, 150, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1,
7, 1, 7, 1, 7, 1, 7, 3, 7, 163, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 164, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1,
8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 180, 8, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 181,
8, 1, 9, 1, 9, 1, 9, 5, 9, 185, 8, 9, 10, 9, 12, 9, 188, 9, 9, 1, 10, 1, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 186, 8, 9, 10, 9, 12, 9, 189, 9, 9, 1, 10,
10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 200, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 201,
8, 12, 10, 12, 12, 12, 203, 9, 12, 1, 13, 1, 13, 1, 13, 3, 13, 208, 8, 8, 12, 10, 12, 12, 12, 204, 9, 12, 1, 13, 1, 13, 1, 13, 3, 13, 209, 8,
13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0,
17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 5,
1, 0, 7, 8, 2, 0, 13, 13, 15, 15, 2, 0, 14, 14, 16, 16, 2, 0, 30, 30, 33, 1, 0, 7, 8, 1, 0, 13, 14, 2, 0, 29, 29, 32, 32, 1, 0, 23, 26, 1, 0, 27,
33, 1, 0, 25, 27, 1, 0, 28, 31, 234, 0, 34, 1, 0, 0, 0, 2, 37, 1, 0, 0, 30, 235, 0, 34, 1, 0, 0, 0, 2, 37, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 47,
0, 4, 39, 1, 0, 0, 0, 6, 47, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 70, 1, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 70, 1, 0, 0, 0, 12, 149, 1, 0, 0, 0,
0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 162, 1, 0, 0, 0, 16, 179, 1, 0, 0, 0, 14, 163, 1, 0, 0, 0, 16, 180, 1, 0, 0, 0, 18, 182, 1, 0, 0, 0, 20, 190,
18, 181, 1, 0, 0, 0, 20, 189, 1, 0, 0, 0, 22, 191, 1, 0, 0, 0, 24, 196, 1, 0, 0, 0, 22, 192, 1, 0, 0, 0, 24, 197, 1, 0, 0, 0, 26, 208, 1, 0, 0,
1, 0, 0, 0, 26, 207, 1, 0, 0, 0, 28, 209, 1, 0, 0, 0, 30, 213, 1, 0, 0, 0, 28, 210, 1, 0, 0, 0, 30, 214, 1, 0, 0, 0, 32, 216, 1, 0, 0, 0, 34, 35,
0, 32, 215, 1, 0, 0, 0, 34, 35, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0, 37, 38, 3, 4, 2, 0,
1, 0, 0, 0, 37, 38, 3, 4, 2, 0, 38, 3, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 38, 3, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 40, 41, 5, 22, 0, 0, 41, 43, 3,
40, 41, 5, 24, 0, 0, 41, 43, 3, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44,
0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 53, 3, 8, 4,
44, 1, 0, 0, 0, 47, 53, 3, 8, 4, 0, 48, 49, 5, 23, 0, 0, 49, 52, 3, 8, 0, 48, 49, 5, 21, 0, 0, 49, 52, 3, 8, 4, 0, 50, 52, 3, 8, 4, 0, 51, 48,
4, 0, 50, 52, 3, 8, 4, 0, 51, 48, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 55, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 55, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0,
1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 7, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 7, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 56, 58, 5, 20,
55, 53, 1, 0, 0, 0, 56, 58, 5, 22, 0, 0, 57, 56, 1, 0, 0, 0, 57, 58, 1, 0, 0, 57, 56, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60,
0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 3, 10, 5, 0, 60, 9, 1, 0, 0, 0, 61, 3, 10, 5, 0, 60, 9, 1, 0, 0, 0, 61, 62, 5, 1, 0, 0, 62, 63, 3, 4, 2, 0,
62, 5, 1, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 2, 0, 0, 64, 71, 1, 0, 0, 63, 64, 5, 2, 0, 0, 64, 71, 1, 0, 0, 0, 65, 71, 3, 12, 6, 0, 66, 71, 3,
0, 65, 71, 3, 12, 6, 0, 66, 71, 3, 22, 11, 0, 67, 71, 3, 20, 10, 0, 68, 22, 11, 0, 67, 71, 3, 20, 10, 0, 68, 71, 3, 32, 16, 0, 69, 71, 3, 30, 15,
71, 3, 32, 16, 0, 69, 71, 3, 30, 15, 0, 70, 61, 1, 0, 0, 0, 70, 65, 1, 0, 70, 61, 1, 0, 0, 0, 70, 65, 1, 0, 0, 0, 70, 66, 1, 0, 0, 0, 70, 67,
0, 0, 0, 70, 66, 1, 0, 0, 0, 70, 67, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 69, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0,
69, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0, 72, 73, 3, 32, 16, 0, 73, 74, 5, 6, 72, 73, 3, 32, 16, 0, 73, 74, 5, 6, 0, 0, 74, 75, 3, 30, 15, 0, 75, 150,
0, 0, 74, 75, 3, 30, 15, 0, 75, 149, 1, 0, 0, 0, 76, 77, 3, 32, 16, 0, 1, 0, 0, 0, 76, 77, 3, 32, 16, 0, 77, 78, 7, 0, 0, 0, 78, 79, 3, 30, 15,
77, 78, 7, 0, 0, 0, 78, 79, 3, 30, 15, 0, 79, 149, 1, 0, 0, 0, 80, 81, 0, 79, 150, 1, 0, 0, 0, 80, 81, 3, 32, 16, 0, 81, 82, 5, 9, 0, 0, 82, 83,
3, 32, 16, 0, 81, 82, 5, 9, 0, 0, 82, 83, 3, 30, 15, 0, 83, 149, 1, 0, 3, 30, 15, 0, 83, 150, 1, 0, 0, 0, 84, 85, 3, 32, 16, 0, 85, 86, 5, 10,
0, 0, 84, 85, 3, 32, 16, 0, 85, 86, 5, 10, 0, 0, 86, 87, 3, 30, 15, 0, 0, 0, 86, 87, 3, 30, 15, 0, 87, 150, 1, 0, 0, 0, 88, 89, 3, 32, 16, 0,
87, 149, 1, 0, 0, 0, 88, 89, 3, 32, 16, 0, 89, 90, 5, 11, 0, 0, 90, 91, 89, 90, 5, 11, 0, 0, 90, 91, 3, 30, 15, 0, 91, 150, 1, 0, 0, 0, 92, 93,
3, 30, 15, 0, 91, 149, 1, 0, 0, 0, 92, 93, 3, 32, 16, 0, 93, 94, 5, 12, 3, 32, 16, 0, 93, 94, 5, 12, 0, 0, 94, 95, 3, 30, 15, 0, 95, 150, 1, 0,
0, 0, 94, 95, 3, 30, 15, 0, 95, 149, 1, 0, 0, 0, 96, 97, 3, 32, 16, 0, 0, 0, 96, 97, 3, 32, 16, 0, 97, 98, 7, 1, 0, 0, 98, 99, 3, 30, 15, 0, 99,
97, 98, 7, 1, 0, 0, 98, 99, 3, 30, 15, 0, 99, 149, 1, 0, 0, 0, 100, 101, 150, 1, 0, 0, 0, 100, 101, 3, 32, 16, 0, 101, 102, 5, 20, 0, 0, 102, 103,
3, 32, 16, 0, 101, 102, 7, 2, 0, 0, 102, 103, 3, 30, 15, 0, 103, 149, 1, 7, 1, 0, 0, 103, 104, 3, 30, 15, 0, 104, 150, 1, 0, 0, 0, 105, 106, 3,
0, 0, 0, 104, 105, 3, 32, 16, 0, 105, 106, 5, 17, 0, 0, 106, 107, 3, 30, 32, 16, 0, 106, 107, 5, 15, 0, 0, 107, 108, 3, 30, 15, 0, 108, 109, 5,
15, 0, 107, 108, 5, 23, 0, 0, 108, 109, 3, 30, 15, 0, 109, 149, 1, 0, 0, 21, 0, 0, 109, 110, 3, 30, 15, 0, 110, 150, 1, 0, 0, 0, 111, 112, 3, 32,
0, 110, 111, 3, 32, 16, 0, 111, 112, 5, 22, 0, 0, 112, 113, 5, 17, 0, 0, 16, 0, 112, 113, 5, 20, 0, 0, 113, 114, 5, 15, 0, 0, 114, 115, 3, 30, 15,
113, 114, 3, 30, 15, 0, 114, 115, 5, 23, 0, 0, 115, 116, 3, 30, 15, 0, 0, 115, 116, 5, 21, 0, 0, 116, 117, 3, 30, 15, 0, 117, 150, 1, 0, 0, 0,
116, 149, 1, 0, 0, 0, 117, 118, 3, 32, 16, 0, 118, 119, 3, 14, 7, 0, 119, 118, 119, 3, 32, 16, 0, 119, 120, 3, 14, 7, 0, 120, 150, 1, 0, 0, 0, 121,
149, 1, 0, 0, 0, 120, 121, 3, 32, 16, 0, 121, 122, 3, 16, 8, 0, 122, 149, 122, 3, 32, 16, 0, 122, 123, 3, 16, 8, 0, 123, 150, 1, 0, 0, 0, 124, 125,
1, 0, 0, 0, 123, 124, 3, 32, 16, 0, 124, 125, 5, 18, 0, 0, 125, 149, 1, 3, 32, 16, 0, 125, 126, 5, 16, 0, 0, 126, 150, 1, 0, 0, 0, 127, 128, 3,
0, 0, 0, 126, 127, 3, 32, 16, 0, 127, 128, 5, 22, 0, 0, 128, 129, 5, 18, 32, 16, 0, 128, 129, 5, 20, 0, 0, 129, 130, 5, 16, 0, 0, 130, 150, 1, 0,
0, 0, 129, 149, 1, 0, 0, 0, 130, 131, 3, 32, 16, 0, 131, 132, 5, 19, 0, 0, 0, 131, 132, 3, 32, 16, 0, 132, 133, 5, 17, 0, 0, 133, 134, 3, 30, 15,
0, 132, 133, 3, 30, 15, 0, 133, 149, 1, 0, 0, 0, 134, 135, 3, 32, 16, 0, 0, 134, 150, 1, 0, 0, 0, 135, 136, 3, 32, 16, 0, 136, 137, 5, 20, 0, 0,
135, 136, 5, 22, 0, 0, 136, 137, 5, 19, 0, 0, 137, 138, 3, 30, 15, 0, 138, 137, 138, 5, 17, 0, 0, 138, 139, 3, 30, 15, 0, 139, 150, 1, 0, 0, 0, 140,
149, 1, 0, 0, 0, 139, 140, 3, 32, 16, 0, 140, 141, 5, 20, 0, 0, 141, 142, 141, 3, 32, 16, 0, 141, 142, 5, 18, 0, 0, 142, 143, 3, 30, 15, 0, 143,
3, 30, 15, 0, 142, 149, 1, 0, 0, 0, 143, 144, 3, 32, 16, 0, 144, 145, 5, 150, 1, 0, 0, 0, 144, 145, 3, 32, 16, 0, 145, 146, 5, 20, 0, 0, 146, 147,
22, 0, 0, 145, 146, 5, 20, 0, 0, 146, 147, 3, 30, 15, 0, 147, 149, 1, 0, 5, 18, 0, 0, 147, 148, 3, 30, 15, 0, 148, 150, 1, 0, 0, 0, 149, 72, 1,
0, 0, 148, 72, 1, 0, 0, 0, 148, 76, 1, 0, 0, 0, 148, 80, 1, 0, 0, 0, 148, 0, 0, 0, 149, 76, 1, 0, 0, 0, 149, 80, 1, 0, 0, 0, 149, 84, 1, 0, 0, 0,
84, 1, 0, 0, 0, 148, 88, 1, 0, 0, 0, 148, 92, 1, 0, 0, 0, 148, 96, 1, 0, 149, 88, 1, 0, 0, 0, 149, 92, 1, 0, 0, 0, 149, 96, 1, 0, 0, 0, 149, 100,
0, 0, 148, 100, 1, 0, 0, 0, 148, 104, 1, 0, 0, 0, 148, 110, 1, 0, 0, 0, 1, 0, 0, 0, 149, 105, 1, 0, 0, 0, 149, 111, 1, 0, 0, 0, 149, 118, 1, 0,
148, 117, 1, 0, 0, 0, 148, 120, 1, 0, 0, 0, 148, 123, 1, 0, 0, 0, 148, 0, 0, 149, 121, 1, 0, 0, 0, 149, 124, 1, 0, 0, 0, 149, 127, 1, 0, 0, 0,
126, 1, 0, 0, 0, 148, 130, 1, 0, 0, 0, 148, 134, 1, 0, 0, 0, 148, 139, 149, 131, 1, 0, 0, 0, 149, 135, 1, 0, 0, 0, 149, 140, 1, 0, 0, 0, 149,
1, 0, 0, 0, 148, 143, 1, 0, 0, 0, 149, 13, 1, 0, 0, 0, 150, 151, 5, 21, 144, 1, 0, 0, 0, 150, 13, 1, 0, 0, 0, 151, 152, 5, 19, 0, 0, 152, 153,
0, 0, 151, 152, 5, 1, 0, 0, 152, 153, 3, 18, 9, 0, 153, 154, 5, 2, 0, 0, 5, 1, 0, 0, 153, 154, 3, 18, 9, 0, 154, 155, 5, 2, 0, 0, 155, 164, 1, 0,
154, 163, 1, 0, 0, 0, 155, 156, 5, 21, 0, 0, 156, 157, 5, 3, 0, 0, 157, 0, 0, 156, 157, 5, 19, 0, 0, 157, 158, 5, 3, 0, 0, 158, 159, 3, 18, 9,
158, 3, 18, 9, 0, 158, 159, 5, 4, 0, 0, 159, 163, 1, 0, 0, 0, 160, 161, 0, 159, 160, 5, 4, 0, 0, 160, 164, 1, 0, 0, 0, 161, 162, 5, 19, 0, 0, 162,
5, 21, 0, 0, 161, 163, 3, 30, 15, 0, 162, 150, 1, 0, 0, 0, 162, 155, 1, 164, 3, 30, 15, 0, 163, 151, 1, 0, 0, 0, 163, 156, 1, 0, 0, 0, 163, 161,
0, 0, 0, 162, 160, 1, 0, 0, 0, 163, 15, 1, 0, 0, 0, 164, 165, 5, 22, 0, 1, 0, 0, 0, 164, 15, 1, 0, 0, 0, 165, 166, 5, 20, 0, 0, 166, 167, 5, 19,
0, 165, 166, 5, 21, 0, 0, 166, 167, 5, 1, 0, 0, 167, 168, 3, 18, 9, 0, 0, 0, 167, 168, 5, 1, 0, 0, 168, 169, 3, 18, 9, 0, 169, 170, 5, 2, 0, 0,
168, 169, 5, 2, 0, 0, 169, 180, 1, 0, 0, 0, 170, 171, 5, 22, 0, 0, 171, 170, 181, 1, 0, 0, 0, 171, 172, 5, 20, 0, 0, 172, 173, 5, 19, 0, 0, 173,
172, 5, 21, 0, 0, 172, 173, 5, 3, 0, 0, 173, 174, 3, 18, 9, 0, 174, 175, 174, 5, 3, 0, 0, 174, 175, 3, 18, 9, 0, 175, 176, 5, 4, 0, 0, 176, 181,
5, 4, 0, 0, 175, 180, 1, 0, 0, 0, 176, 177, 5, 22, 0, 0, 177, 178, 5, 21, 1, 0, 0, 0, 177, 178, 5, 20, 0, 0, 178, 179, 5, 19, 0, 0, 179, 181, 3,
0, 0, 178, 180, 3, 30, 15, 0, 179, 164, 1, 0, 0, 0, 179, 170, 1, 0, 0, 30, 15, 0, 180, 165, 1, 0, 0, 0, 180, 171, 1, 0, 0, 0, 180, 177, 1, 0,
0, 179, 176, 1, 0, 0, 0, 180, 17, 1, 0, 0, 0, 181, 186, 3, 30, 15, 0, 182, 0, 0, 181, 17, 1, 0, 0, 0, 182, 187, 3, 30, 15, 0, 183, 184, 5, 5, 0, 0,
183, 5, 5, 0, 0, 183, 185, 3, 30, 15, 0, 184, 182, 1, 0, 0, 0, 185, 188, 184, 186, 3, 30, 15, 0, 185, 183, 1, 0, 0, 0, 186, 189, 1, 0, 0, 0, 187,
1, 0, 0, 0, 186, 184, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 19, 1, 0, 185, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, 19, 1, 0, 0, 0, 189, 187, 1,
0, 0, 188, 186, 1, 0, 0, 0, 189, 190, 7, 3, 0, 0, 190, 21, 1, 0, 0, 0, 0, 0, 0, 190, 191, 7, 2, 0, 0, 191, 21, 1, 0, 0, 0, 192, 193, 7, 3, 0,
191, 192, 7, 4, 0, 0, 192, 193, 5, 1, 0, 0, 193, 194, 3, 24, 12, 0, 194, 0, 193, 194, 5, 1, 0, 0, 194, 195, 3, 24, 12, 0, 195, 196, 5, 2, 0, 0,
195, 5, 2, 0, 0, 195, 23, 1, 0, 0, 0, 196, 201, 3, 26, 13, 0, 197, 198, 196, 23, 1, 0, 0, 0, 197, 202, 3, 26, 13, 0, 198, 199, 5, 5, 0, 0, 199,
5, 5, 0, 0, 198, 200, 3, 26, 13, 0, 199, 197, 1, 0, 0, 0, 200, 203, 1, 201, 3, 26, 13, 0, 200, 198, 1, 0, 0, 0, 201, 204, 1, 0, 0, 0, 202, 200,
0, 0, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 25, 1, 0, 0, 1, 0, 0, 0, 202, 203, 1, 0, 0, 0, 203, 25, 1, 0, 0, 0, 204, 202, 1, 0,
0, 203, 201, 1, 0, 0, 0, 204, 208, 3, 32, 16, 0, 205, 208, 3, 30, 15, 0, 0, 0, 205, 209, 3, 32, 16, 0, 206, 209, 3, 30, 15, 0, 207, 209, 3, 28,
206, 208, 3, 28, 14, 0, 207, 204, 1, 0, 0, 0, 207, 205, 1, 0, 0, 0, 207, 14, 0, 208, 205, 1, 0, 0, 0, 208, 206, 1, 0, 0, 0, 208, 207, 1, 0, 0, 0,
206, 1, 0, 0, 0, 208, 27, 1, 0, 0, 0, 209, 210, 5, 3, 0, 0, 210, 211, 3, 209, 27, 1, 0, 0, 0, 210, 211, 5, 3, 0, 0, 211, 212, 3, 18, 9, 0, 212,
18, 9, 0, 211, 212, 5, 4, 0, 0, 212, 29, 1, 0, 0, 0, 213, 214, 7, 5, 0, 213, 5, 4, 0, 0, 213, 29, 1, 0, 0, 0, 214, 215, 7, 4, 0, 0, 215, 31, 1,
0, 214, 31, 1, 0, 0, 0, 215, 216, 5, 31, 0, 0, 216, 33, 1, 0, 0, 0, 11, 0, 0, 0, 216, 217, 5, 30, 0, 0, 217, 33, 1, 0, 0, 0, 11, 44, 51, 53, 57,
44, 51, 53, 57, 70, 148, 162, 179, 186, 201, 207, 70, 149, 163, 180, 187, 202, 208,
} }
deserializer := antlr.NewATNDeserializer(nil) deserializer := antlr.NewATNDeserializer(nil)
staticData.atn = deserializer.Deserialize(staticData.serializedATN) staticData.atn = deserializer.Deserialize(staticData.serializedATN)
@ -196,26 +195,25 @@ const (
FilterQueryParserGT = 11 FilterQueryParserGT = 11
FilterQueryParserGE = 12 FilterQueryParserGE = 12
FilterQueryParserLIKE = 13 FilterQueryParserLIKE = 13
FilterQueryParserNOT_LIKE = 14 FilterQueryParserILIKE = 14
FilterQueryParserILIKE = 15 FilterQueryParserBETWEEN = 15
FilterQueryParserNOT_ILIKE = 16 FilterQueryParserEXISTS = 16
FilterQueryParserBETWEEN = 17 FilterQueryParserREGEXP = 17
FilterQueryParserEXISTS = 18 FilterQueryParserCONTAINS = 18
FilterQueryParserREGEXP = 19 FilterQueryParserIN = 19
FilterQueryParserCONTAINS = 20 FilterQueryParserNOT = 20
FilterQueryParserIN = 21 FilterQueryParserAND = 21
FilterQueryParserNOT = 22 FilterQueryParserOR = 22
FilterQueryParserAND = 23 FilterQueryParserHASTOKEN = 23
FilterQueryParserOR = 24 FilterQueryParserHAS = 24
FilterQueryParserHAS = 25 FilterQueryParserHASANY = 25
FilterQueryParserHASANY = 26 FilterQueryParserHASALL = 26
FilterQueryParserHASALL = 27 FilterQueryParserBOOL = 27
FilterQueryParserBOOL = 28 FilterQueryParserNUMBER = 28
FilterQueryParserNUMBER = 29 FilterQueryParserQUOTED_TEXT = 29
FilterQueryParserQUOTED_TEXT = 30 FilterQueryParserKEY = 30
FilterQueryParserKEY = 31 FilterQueryParserWS = 31
FilterQueryParserWS = 32 FilterQueryParserFREETEXT = 32
FilterQueryParserFREETEXT = 33
) )
// FilterQueryParser rules. // FilterQueryParser rules.
@ -805,7 +803,7 @@ func (p *FilterQueryParser) AndExpression() (localctx IAndExpressionContext) {
} }
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&12863930370) != 0 { for (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&6437208066) != 0 {
p.SetState(51) p.SetState(51)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
@ -827,7 +825,7 @@ func (p *FilterQueryParser) AndExpression() (localctx IAndExpressionContext) {
p.UnaryExpression() p.UnaryExpression()
} }
case FilterQueryParserLPAREN, FilterQueryParserNOT, FilterQueryParserHAS, FilterQueryParserHASANY, FilterQueryParserHASALL, FilterQueryParserBOOL, FilterQueryParserNUMBER, FilterQueryParserQUOTED_TEXT, FilterQueryParserKEY, FilterQueryParserFREETEXT: case FilterQueryParserLPAREN, FilterQueryParserNOT, FilterQueryParserHASTOKEN, FilterQueryParserHAS, FilterQueryParserHASANY, FilterQueryParserHASALL, FilterQueryParserBOOL, FilterQueryParserNUMBER, FilterQueryParserQUOTED_TEXT, FilterQueryParserKEY, FilterQueryParserFREETEXT:
{ {
p.SetState(50) p.SetState(50)
p.UnaryExpression() p.UnaryExpression()
@ -1290,11 +1288,9 @@ type IComparisonContext interface {
GE() antlr.TerminalNode GE() antlr.TerminalNode
LIKE() antlr.TerminalNode LIKE() antlr.TerminalNode
ILIKE() antlr.TerminalNode ILIKE() antlr.TerminalNode
NOT_LIKE() antlr.TerminalNode NOT() antlr.TerminalNode
NOT_ILIKE() antlr.TerminalNode
BETWEEN() antlr.TerminalNode BETWEEN() antlr.TerminalNode
AND() antlr.TerminalNode AND() antlr.TerminalNode
NOT() antlr.TerminalNode
InClause() IInClauseContext InClause() IInClauseContext
NotInClause() INotInClauseContext NotInClause() INotInClauseContext
EXISTS() antlr.TerminalNode EXISTS() antlr.TerminalNode
@ -1430,12 +1426,8 @@ func (s *ComparisonContext) ILIKE() antlr.TerminalNode {
return s.GetToken(FilterQueryParserILIKE, 0) return s.GetToken(FilterQueryParserILIKE, 0)
} }
func (s *ComparisonContext) NOT_LIKE() antlr.TerminalNode { func (s *ComparisonContext) NOT() antlr.TerminalNode {
return s.GetToken(FilterQueryParserNOT_LIKE, 0) return s.GetToken(FilterQueryParserNOT, 0)
}
func (s *ComparisonContext) NOT_ILIKE() antlr.TerminalNode {
return s.GetToken(FilterQueryParserNOT_ILIKE, 0)
} }
func (s *ComparisonContext) BETWEEN() antlr.TerminalNode { func (s *ComparisonContext) BETWEEN() antlr.TerminalNode {
@ -1446,10 +1438,6 @@ func (s *ComparisonContext) AND() antlr.TerminalNode {
return s.GetToken(FilterQueryParserAND, 0) return s.GetToken(FilterQueryParserAND, 0)
} }
func (s *ComparisonContext) NOT() antlr.TerminalNode {
return s.GetToken(FilterQueryParserNOT, 0)
}
func (s *ComparisonContext) InClause() IInClauseContext { func (s *ComparisonContext) InClause() IInClauseContext {
var t antlr.RuleContext var t antlr.RuleContext
for _, ctx := range s.GetChildren() { for _, ctx := range s.GetChildren() {
@ -1529,7 +1517,7 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
p.EnterRule(localctx, 12, FilterQueryParserRULE_comparison) p.EnterRule(localctx, 12, FilterQueryParserRULE_comparison)
var _la int var _la int
p.SetState(148) p.SetState(149)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -1683,59 +1671,6 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
{ {
p.SetState(101) p.SetState(101)
_la = p.GetTokenStream().LA(1)
if !(_la == FilterQueryParserNOT_LIKE || _la == FilterQueryParserNOT_ILIKE) {
p.GetErrorHandler().RecoverInline(p)
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
{
p.SetState(102)
p.Value()
}
case 9:
p.EnterOuterAlt(localctx, 9)
{
p.SetState(104)
p.Key()
}
{
p.SetState(105)
p.Match(FilterQueryParserBETWEEN)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(106)
p.Value()
}
{
p.SetState(107)
p.Match(FilterQueryParserAND)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(108)
p.Value()
}
case 10:
p.EnterOuterAlt(localctx, 10)
{
p.SetState(110)
p.Key()
}
{
p.SetState(111)
p.Match(FilterQueryParserNOT) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1743,7 +1678,29 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(112) p.SetState(102)
_la = p.GetTokenStream().LA(1)
if !(_la == FilterQueryParserLIKE || _la == FilterQueryParserILIKE) {
p.GetErrorHandler().RecoverInline(p)
} else {
p.GetErrorHandler().ReportMatch(p)
p.Consume()
}
}
{
p.SetState(103)
p.Value()
}
case 9:
p.EnterOuterAlt(localctx, 9)
{
p.SetState(105)
p.Key()
}
{
p.SetState(106)
p.Match(FilterQueryParserBETWEEN) p.Match(FilterQueryParserBETWEEN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1751,52 +1708,91 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(113) p.SetState(107)
p.Value() p.Value()
} }
{ {
p.SetState(114) p.SetState(108)
p.Match(FilterQueryParserAND) p.Match(FilterQueryParserAND)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
goto errorExit goto errorExit
} }
} }
{
p.SetState(109)
p.Value()
}
case 10:
p.EnterOuterAlt(localctx, 10)
{
p.SetState(111)
p.Key()
}
{
p.SetState(112)
p.Match(FilterQueryParserNOT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(113)
p.Match(FilterQueryParserBETWEEN)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(114)
p.Value()
}
{ {
p.SetState(115) p.SetState(115)
p.Match(FilterQueryParserAND)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(116)
p.Value() p.Value()
} }
case 11: case 11:
p.EnterOuterAlt(localctx, 11) p.EnterOuterAlt(localctx, 11)
{ {
p.SetState(117) p.SetState(118)
p.Key() p.Key()
} }
{ {
p.SetState(118) p.SetState(119)
p.InClause() p.InClause()
} }
case 12: case 12:
p.EnterOuterAlt(localctx, 12) p.EnterOuterAlt(localctx, 12)
{ {
p.SetState(120) p.SetState(121)
p.Key() p.Key()
} }
{ {
p.SetState(121) p.SetState(122)
p.NotInClause() p.NotInClause()
} }
case 13: case 13:
p.EnterOuterAlt(localctx, 13) p.EnterOuterAlt(localctx, 13)
{ {
p.SetState(123) p.SetState(124)
p.Key() p.Key()
} }
{ {
p.SetState(124) p.SetState(125)
p.Match(FilterQueryParserEXISTS) p.Match(FilterQueryParserEXISTS)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1807,11 +1803,11 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
case 14: case 14:
p.EnterOuterAlt(localctx, 14) p.EnterOuterAlt(localctx, 14)
{ {
p.SetState(126) p.SetState(127)
p.Key() p.Key()
} }
{ {
p.SetState(127) p.SetState(128)
p.Match(FilterQueryParserNOT) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1819,7 +1815,7 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(128) p.SetState(129)
p.Match(FilterQueryParserEXISTS) p.Match(FilterQueryParserEXISTS)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1830,11 +1826,11 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
case 15: case 15:
p.EnterOuterAlt(localctx, 15) p.EnterOuterAlt(localctx, 15)
{ {
p.SetState(130) p.SetState(131)
p.Key() p.Key()
} }
{ {
p.SetState(131) p.SetState(132)
p.Match(FilterQueryParserREGEXP) p.Match(FilterQueryParserREGEXP)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1842,27 +1838,19 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(132) p.SetState(133)
p.Value() p.Value()
} }
case 16: case 16:
p.EnterOuterAlt(localctx, 16) p.EnterOuterAlt(localctx, 16)
{ {
p.SetState(134) p.SetState(135)
p.Key() p.Key()
} }
{
p.SetState(135)
p.Match(FilterQueryParserNOT)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{ {
p.SetState(136) p.SetState(136)
p.Match(FilterQueryParserREGEXP) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
goto errorExit goto errorExit
@ -1870,17 +1858,25 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
{ {
p.SetState(137) p.SetState(137)
p.Match(FilterQueryParserREGEXP)
if p.HasError() {
// Recognition error - abort rule
goto errorExit
}
}
{
p.SetState(138)
p.Value() p.Value()
} }
case 17: case 17:
p.EnterOuterAlt(localctx, 17) p.EnterOuterAlt(localctx, 17)
{ {
p.SetState(139) p.SetState(140)
p.Key() p.Key()
} }
{ {
p.SetState(140) p.SetState(141)
p.Match(FilterQueryParserCONTAINS) p.Match(FilterQueryParserCONTAINS)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1888,18 +1884,18 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(141) p.SetState(142)
p.Value() p.Value()
} }
case 18: case 18:
p.EnterOuterAlt(localctx, 18) p.EnterOuterAlt(localctx, 18)
{ {
p.SetState(143) p.SetState(144)
p.Key() p.Key()
} }
{ {
p.SetState(144) p.SetState(145)
p.Match(FilterQueryParserNOT) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1907,7 +1903,7 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(145) p.SetState(146)
p.Match(FilterQueryParserCONTAINS) p.Match(FilterQueryParserCONTAINS)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -1915,7 +1911,7 @@ func (p *FilterQueryParser) Comparison() (localctx IComparisonContext) {
} }
} }
{ {
p.SetState(146) p.SetState(147)
p.Value() p.Value()
} }
@ -2073,7 +2069,7 @@ func (s *InClauseContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
func (p *FilterQueryParser) InClause() (localctx IInClauseContext) { func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
localctx = NewInClauseContext(p, p.GetParserRuleContext(), p.GetState()) localctx = NewInClauseContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 14, FilterQueryParserRULE_inClause) p.EnterRule(localctx, 14, FilterQueryParserRULE_inClause)
p.SetState(162) p.SetState(163)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -2083,7 +2079,7 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(150) p.SetState(151)
p.Match(FilterQueryParserIN) p.Match(FilterQueryParserIN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2091,7 +2087,7 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
} }
} }
{ {
p.SetState(151) p.SetState(152)
p.Match(FilterQueryParserLPAREN) p.Match(FilterQueryParserLPAREN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2099,11 +2095,11 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
} }
} }
{ {
p.SetState(152) p.SetState(153)
p.ValueList() p.ValueList()
} }
{ {
p.SetState(153) p.SetState(154)
p.Match(FilterQueryParserRPAREN) p.Match(FilterQueryParserRPAREN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2114,7 +2110,7 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(155) p.SetState(156)
p.Match(FilterQueryParserIN) p.Match(FilterQueryParserIN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2122,7 +2118,7 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
} }
} }
{ {
p.SetState(156) p.SetState(157)
p.Match(FilterQueryParserLBRACK) p.Match(FilterQueryParserLBRACK)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2130,11 +2126,11 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
} }
} }
{ {
p.SetState(157) p.SetState(158)
p.ValueList() p.ValueList()
} }
{ {
p.SetState(158) p.SetState(159)
p.Match(FilterQueryParserRBRACK) p.Match(FilterQueryParserRBRACK)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2145,7 +2141,7 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
case 3: case 3:
p.EnterOuterAlt(localctx, 3) p.EnterOuterAlt(localctx, 3)
{ {
p.SetState(160) p.SetState(161)
p.Match(FilterQueryParserIN) p.Match(FilterQueryParserIN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2153,7 +2149,7 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
} }
} }
{ {
p.SetState(161) p.SetState(162)
p.Value() p.Value()
} }
@ -2316,7 +2312,7 @@ func (s *NotInClauseContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) { func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
localctx = NewNotInClauseContext(p, p.GetParserRuleContext(), p.GetState()) localctx = NewNotInClauseContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 16, FilterQueryParserRULE_notInClause) p.EnterRule(localctx, 16, FilterQueryParserRULE_notInClause)
p.SetState(179) p.SetState(180)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -2326,7 +2322,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(164) p.SetState(165)
p.Match(FilterQueryParserNOT) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2334,7 +2330,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(165) p.SetState(166)
p.Match(FilterQueryParserIN) p.Match(FilterQueryParserIN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2342,7 +2338,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(166) p.SetState(167)
p.Match(FilterQueryParserLPAREN) p.Match(FilterQueryParserLPAREN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2350,11 +2346,11 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(167) p.SetState(168)
p.ValueList() p.ValueList()
} }
{ {
p.SetState(168) p.SetState(169)
p.Match(FilterQueryParserRPAREN) p.Match(FilterQueryParserRPAREN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2365,7 +2361,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(170) p.SetState(171)
p.Match(FilterQueryParserNOT) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2373,7 +2369,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(171) p.SetState(172)
p.Match(FilterQueryParserIN) p.Match(FilterQueryParserIN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2381,7 +2377,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(172) p.SetState(173)
p.Match(FilterQueryParserLBRACK) p.Match(FilterQueryParserLBRACK)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2389,11 +2385,11 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(173) p.SetState(174)
p.ValueList() p.ValueList()
} }
{ {
p.SetState(174) p.SetState(175)
p.Match(FilterQueryParserRBRACK) p.Match(FilterQueryParserRBRACK)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2404,7 +2400,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
case 3: case 3:
p.EnterOuterAlt(localctx, 3) p.EnterOuterAlt(localctx, 3)
{ {
p.SetState(176) p.SetState(177)
p.Match(FilterQueryParserNOT) p.Match(FilterQueryParserNOT)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2412,7 +2408,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(177) p.SetState(178)
p.Match(FilterQueryParserIN) p.Match(FilterQueryParserIN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2420,7 +2416,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
} }
} }
{ {
p.SetState(178) p.SetState(179)
p.Value() p.Value()
} }
@ -2576,10 +2572,10 @@ func (p *FilterQueryParser) ValueList() (localctx IValueListContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(181) p.SetState(182)
p.Value() p.Value()
} }
p.SetState(186) p.SetState(187)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -2588,7 +2584,7 @@ func (p *FilterQueryParser) ValueList() (localctx IValueListContext) {
for _la == FilterQueryParserCOMMA { for _la == FilterQueryParserCOMMA {
{ {
p.SetState(182) p.SetState(183)
p.Match(FilterQueryParserCOMMA) p.Match(FilterQueryParserCOMMA)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2596,11 +2592,11 @@ func (p *FilterQueryParser) ValueList() (localctx IValueListContext) {
} }
} }
{ {
p.SetState(183) p.SetState(184)
p.Value() p.Value()
} }
p.SetState(188) p.SetState(189)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -2713,7 +2709,7 @@ func (p *FilterQueryParser) FullText() (localctx IFullTextContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(189) p.SetState(190)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if !(_la == FilterQueryParserQUOTED_TEXT || _la == FilterQueryParserFREETEXT) { if !(_la == FilterQueryParserQUOTED_TEXT || _la == FilterQueryParserFREETEXT) {
@ -2748,6 +2744,7 @@ type IFunctionCallContext interface {
LPAREN() antlr.TerminalNode LPAREN() antlr.TerminalNode
FunctionParamList() IFunctionParamListContext FunctionParamList() IFunctionParamListContext
RPAREN() antlr.TerminalNode RPAREN() antlr.TerminalNode
HASTOKEN() antlr.TerminalNode
HAS() antlr.TerminalNode HAS() antlr.TerminalNode
HASANY() antlr.TerminalNode HASANY() antlr.TerminalNode
HASALL() antlr.TerminalNode HASALL() antlr.TerminalNode
@ -2812,6 +2809,10 @@ func (s *FunctionCallContext) RPAREN() antlr.TerminalNode {
return s.GetToken(FilterQueryParserRPAREN, 0) return s.GetToken(FilterQueryParserRPAREN, 0)
} }
func (s *FunctionCallContext) HASTOKEN() antlr.TerminalNode {
return s.GetToken(FilterQueryParserHASTOKEN, 0)
}
func (s *FunctionCallContext) HAS() antlr.TerminalNode { func (s *FunctionCallContext) HAS() antlr.TerminalNode {
return s.GetToken(FilterQueryParserHAS, 0) return s.GetToken(FilterQueryParserHAS, 0)
} }
@ -2861,10 +2862,10 @@ func (p *FilterQueryParser) FunctionCall() (localctx IFunctionCallContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(191) p.SetState(192)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&234881024) != 0) { if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&125829120) != 0) {
p.GetErrorHandler().RecoverInline(p) p.GetErrorHandler().RecoverInline(p)
} else { } else {
p.GetErrorHandler().ReportMatch(p) p.GetErrorHandler().ReportMatch(p)
@ -2872,7 +2873,7 @@ func (p *FilterQueryParser) FunctionCall() (localctx IFunctionCallContext) {
} }
} }
{ {
p.SetState(192) p.SetState(193)
p.Match(FilterQueryParserLPAREN) p.Match(FilterQueryParserLPAREN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -2880,11 +2881,11 @@ func (p *FilterQueryParser) FunctionCall() (localctx IFunctionCallContext) {
} }
} }
{ {
p.SetState(193) p.SetState(194)
p.FunctionParamList() p.FunctionParamList()
} }
{ {
p.SetState(194) p.SetState(195)
p.Match(FilterQueryParserRPAREN) p.Match(FilterQueryParserRPAREN)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -3040,10 +3041,10 @@ func (p *FilterQueryParser) FunctionParamList() (localctx IFunctionParamListCont
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(196) p.SetState(197)
p.FunctionParam() p.FunctionParam()
} }
p.SetState(201) p.SetState(202)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -3052,7 +3053,7 @@ func (p *FilterQueryParser) FunctionParamList() (localctx IFunctionParamListCont
for _la == FilterQueryParserCOMMA { for _la == FilterQueryParserCOMMA {
{ {
p.SetState(197) p.SetState(198)
p.Match(FilterQueryParserCOMMA) p.Match(FilterQueryParserCOMMA)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -3060,11 +3061,11 @@ func (p *FilterQueryParser) FunctionParamList() (localctx IFunctionParamListCont
} }
} }
{ {
p.SetState(198) p.SetState(199)
p.FunctionParam() p.FunctionParam()
} }
p.SetState(203) p.SetState(204)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -3214,7 +3215,7 @@ func (s *FunctionParamContext) Accept(visitor antlr.ParseTreeVisitor) interface{
func (p *FilterQueryParser) FunctionParam() (localctx IFunctionParamContext) { func (p *FilterQueryParser) FunctionParam() (localctx IFunctionParamContext) {
localctx = NewFunctionParamContext(p, p.GetParserRuleContext(), p.GetState()) localctx = NewFunctionParamContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 26, FilterQueryParserRULE_functionParam) p.EnterRule(localctx, 26, FilterQueryParserRULE_functionParam)
p.SetState(207) p.SetState(208)
p.GetErrorHandler().Sync(p) p.GetErrorHandler().Sync(p)
if p.HasError() { if p.HasError() {
goto errorExit goto errorExit
@ -3224,21 +3225,21 @@ func (p *FilterQueryParser) FunctionParam() (localctx IFunctionParamContext) {
case 1: case 1:
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(204) p.SetState(205)
p.Key() p.Key()
} }
case 2: case 2:
p.EnterOuterAlt(localctx, 2) p.EnterOuterAlt(localctx, 2)
{ {
p.SetState(205) p.SetState(206)
p.Value() p.Value()
} }
case 3: case 3:
p.EnterOuterAlt(localctx, 3) p.EnterOuterAlt(localctx, 3)
{ {
p.SetState(206) p.SetState(207)
p.Array() p.Array()
} }
@ -3366,7 +3367,7 @@ func (p *FilterQueryParser) Array() (localctx IArrayContext) {
p.EnterRule(localctx, 28, FilterQueryParserRULE_array) p.EnterRule(localctx, 28, FilterQueryParserRULE_array)
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(209) p.SetState(210)
p.Match(FilterQueryParserLBRACK) p.Match(FilterQueryParserLBRACK)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -3374,11 +3375,11 @@ func (p *FilterQueryParser) Array() (localctx IArrayContext) {
} }
} }
{ {
p.SetState(210) p.SetState(211)
p.ValueList() p.ValueList()
} }
{ {
p.SetState(211) p.SetState(212)
p.Match(FilterQueryParserRBRACK) p.Match(FilterQueryParserRBRACK)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule
@ -3501,10 +3502,10 @@ func (p *FilterQueryParser) Value() (localctx IValueContext) {
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(213) p.SetState(214)
_la = p.GetTokenStream().LA(1) _la = p.GetTokenStream().LA(1)
if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&4026531840) != 0) { if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&2013265920) != 0) {
p.GetErrorHandler().RecoverInline(p) p.GetErrorHandler().RecoverInline(p)
} else { } else {
p.GetErrorHandler().ReportMatch(p) p.GetErrorHandler().ReportMatch(p)
@ -3610,7 +3611,7 @@ func (p *FilterQueryParser) Key() (localctx IKeyContext) {
p.EnterRule(localctx, 32, FilterQueryParserRULE_key) p.EnterRule(localctx, 32, FilterQueryParserRULE_key)
p.EnterOuterAlt(localctx, 1) p.EnterOuterAlt(localctx, 1)
{ {
p.SetState(215) p.SetState(216)
p.Match(FilterQueryParserKEY) p.Match(FilterQueryParserKEY)
if p.HasError() { if p.HasError() {
// Recognition error - abort rule // Recognition error - abort rule

View File

@ -32,6 +32,7 @@ var friendly = map[string]string{
"BETWEEN": "BETWEEN", "IN": "IN", "EXISTS": "EXISTS", "BETWEEN": "BETWEEN", "IN": "IN", "EXISTS": "EXISTS",
"REGEXP": "REGEXP", "CONTAINS": "CONTAINS", "REGEXP": "REGEXP", "CONTAINS": "CONTAINS",
"HAS": "has()", "HASANY": "hasAny()", "HASALL": "hasAll()", "HAS": "has()", "HASANY": "hasAny()", "HASALL": "hasAll()",
"HASTOKEN": "hasToken()",
// literals / identifiers // literals / identifiers
"NUMBER": "number", "NUMBER": "number",

View File

@ -300,12 +300,14 @@ func (d *LogicalContradictionDetector) VisitComparison(ctx *grammar.ComparisonCo
operator = qbtypes.FilterOperatorGreaterThanOrEq operator = qbtypes.FilterOperatorGreaterThanOrEq
} else if ctx.LIKE() != nil { } else if ctx.LIKE() != nil {
operator = qbtypes.FilterOperatorLike operator = qbtypes.FilterOperatorLike
if ctx.NOT() != nil {
operator = qbtypes.FilterOperatorNotLike
}
} else if ctx.ILIKE() != nil { } else if ctx.ILIKE() != nil {
operator = qbtypes.FilterOperatorILike operator = qbtypes.FilterOperatorILike
} else if ctx.NOT_LIKE() != nil { if ctx.NOT() != nil {
operator = qbtypes.FilterOperatorNotLike
} else if ctx.NOT_ILIKE() != nil {
operator = qbtypes.FilterOperatorNotILike operator = qbtypes.FilterOperatorNotILike
}
} else if ctx.REGEXP() != nil { } else if ctx.REGEXP() != nil {
operator = qbtypes.FilterOperatorRegexp operator = qbtypes.FilterOperatorRegexp
if ctx.NOT() != nil { if ctx.NOT() != nil {

View File

@ -512,12 +512,14 @@ func (v *filterExpressionVisitor) VisitComparison(ctx *grammar.ComparisonContext
op = qbtypes.FilterOperatorGreaterThanOrEq op = qbtypes.FilterOperatorGreaterThanOrEq
} else if ctx.LIKE() != nil { } else if ctx.LIKE() != nil {
op = qbtypes.FilterOperatorLike op = qbtypes.FilterOperatorLike
if ctx.NOT() != nil {
op = qbtypes.FilterOperatorNotLike
}
} else if ctx.ILIKE() != nil { } else if ctx.ILIKE() != nil {
op = qbtypes.FilterOperatorILike op = qbtypes.FilterOperatorILike
} else if ctx.NOT_LIKE() != nil { if ctx.NOT() != nil {
op = qbtypes.FilterOperatorNotLike
} else if ctx.NOT_ILIKE() != nil {
op = qbtypes.FilterOperatorNotILike op = qbtypes.FilterOperatorNotILike
}
} else if ctx.REGEXP() != nil { } else if ctx.REGEXP() != nil {
op = qbtypes.FilterOperatorRegexp op = qbtypes.FilterOperatorRegexp
if ctx.NOT() != nil { if ctx.NOT() != nil {
@ -617,6 +619,8 @@ func (v *filterExpressionVisitor) VisitFunctionCall(ctx *grammar.FunctionCallCon
functionName = "hasAny" functionName = "hasAny"
} else if ctx.HASALL() != nil { } else if ctx.HASALL() != nil {
functionName = "hasAll" functionName = "hasAll"
} else if ctx.HASTOKEN() != nil {
functionName = "hasToken"
} else { } else {
// Default fallback // Default fallback
v.errors = append(v.errors, fmt.Sprintf("unknown function `%s`", ctx.GetText())) v.errors = append(v.errors, fmt.Sprintf("unknown function `%s`", ctx.GetText()))
@ -639,6 +643,26 @@ func (v *filterExpressionVisitor) VisitFunctionCall(ctx *grammar.FunctionCallCon
for _, key := range keys { for _, key := range keys {
var fieldName string var fieldName string
if functionName == "hasToken" {
if key.Name != "body" {
if v.mainErrorURL == "" {
v.mainErrorURL = "https://signoz.io/docs/userguide/functions-reference/#hastoken-function"
}
v.errors = append(v.errors, fmt.Sprintf("function `%s` only supports body field as first parameter", functionName))
}
// this will only work with string.
if _, ok := value[0].(string); !ok {
if v.mainErrorURL == "" {
v.mainErrorURL = "https://signoz.io/docs/userguide/functions-reference/#hastoken-function"
}
v.errors = append(v.errors, fmt.Sprintf("function `%s` expects value parameter to be a string", functionName))
return ""
}
conds = append(conds, fmt.Sprintf("hasToken(LOWER(%s), LOWER(%s))", key.Name, v.builder.Var(value[0])))
} else {
// this is that all other functions only support array fields
if strings.HasPrefix(key.Name, v.jsonBodyPrefix) { if strings.HasPrefix(key.Name, v.jsonBodyPrefix) {
fieldName, _ = v.jsonKeyToKey(context.Background(), key, qbtypes.FilterOperatorUnknown, value) fieldName, _ = v.jsonKeyToKey(context.Background(), key, qbtypes.FilterOperatorUnknown, value)
} else { } else {
@ -662,6 +686,7 @@ func (v *filterExpressionVisitor) VisitFunctionCall(ctx *grammar.FunctionCallCon
} }
conds = append(conds, cond) conds = append(conds, cond)
} }
}
if len(conds) == 1 { if len(conds) == 1 {
return conds[0] return conds[0]

View File

@ -91,7 +91,7 @@ func TestFilterExprLogs(t *testing.T) {
category: "Single word", category: "Single word",
query: "<script>alert('xss')</script>", query: "<script>alert('xss')</script>",
shouldPass: false, shouldPass: false,
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got '<'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got '<'",
}, },
// Single word searches with spaces // Single word searches with spaces
@ -125,7 +125,7 @@ func TestFilterExprLogs(t *testing.T) {
category: "Special characters", category: "Special characters",
query: "[tracing]", query: "[tracing]",
shouldPass: false, shouldPass: false,
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got '['", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got '['",
}, },
{ {
category: "Special characters", category: "Special characters",
@ -155,7 +155,7 @@ func TestFilterExprLogs(t *testing.T) {
category: "Special characters", category: "Special characters",
query: "ERROR: cannot execute update() in a read-only context", query: "ERROR: cannot execute update() in a read-only context",
shouldPass: false, shouldPass: false,
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got ')'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got ')'",
}, },
{ {
category: "Special characters", category: "Special characters",
@ -567,7 +567,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'and'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'and'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -575,7 +575,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'or'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'or'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -583,7 +583,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), FREETEXT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got EOF", expectedErrorContains: "expecting one of {(, ), FREETEXT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got EOF",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -591,7 +591,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'like'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'like'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -599,7 +599,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'between'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'between'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -607,7 +607,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'in'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'in'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -615,7 +615,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'exists'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'exists'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -623,7 +623,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'regexp'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'regexp'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -631,7 +631,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: []any{}, expectedArgs: []any{},
expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'contains'", expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'contains'",
}, },
{ {
category: "Keyword conflict", category: "Keyword conflict",
@ -1464,6 +1464,24 @@ func TestFilterExprLogs(t *testing.T) {
expectedErrorContains: "", expectedErrorContains: "",
}, },
// HASTOKEN
{
category: "hasToken",
query: "hasToken(body, \"download\")",
shouldPass: true,
expectedQuery: "WHERE hasToken(LOWER(body), LOWER(?))",
expectedArgs: []any{"download"},
expectedErrorContains: "",
},
{
category: "hasTokenNumber",
query: "hasToken(body, 1)",
shouldPass: false,
expectedQuery: "WHERE hasToken(LOWER(body), LOWER(?))",
expectedArgs: []any{"download"},
expectedErrorContains: "function `hasToken` expects value parameter to be a string",
},
// Basic materialized key // Basic materialized key
{ {
category: "Materialized key", category: "Materialized key",
@ -1935,9 +1953,9 @@ func TestFilterExprLogs(t *testing.T) {
expectedErrorContains: "", expectedErrorContains: "",
}, },
{category: "Only keywords", query: "AND", shouldPass: false, expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'AND'"}, {category: "Only keywords", query: "AND", shouldPass: false, expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'AND'"},
{category: "Only keywords", query: "OR", shouldPass: false, expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'OR'"}, {category: "Only keywords", query: "OR", shouldPass: false, expectedErrorContains: "expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'OR'"},
{category: "Only keywords", query: "NOT", shouldPass: false, expectedErrorContains: "expecting one of {(, ), FREETEXT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got EOF"}, {category: "Only keywords", query: "NOT", shouldPass: false, expectedErrorContains: "expecting one of {(, ), FREETEXT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got EOF"},
{category: "Only functions", query: "has", shouldPass: false, expectedErrorContains: "expecting one of {(, )} but got EOF"}, {category: "Only functions", query: "has", shouldPass: false, expectedErrorContains: "expecting one of {(, )} but got EOF"},
{category: "Only functions", query: "hasAny", shouldPass: false, expectedErrorContains: "expecting one of {(, )} but got EOF"}, {category: "Only functions", query: "hasAny", shouldPass: false, expectedErrorContains: "expecting one of {(, )} but got EOF"},
@ -2079,7 +2097,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: nil, expectedArgs: nil,
expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'and'", expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'and'",
}, },
{ {
category: "Operator keywords as keys", category: "Operator keywords as keys",
@ -2087,7 +2105,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: nil, expectedArgs: nil,
expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'or'", expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'or'",
}, },
{ {
category: "Operator keywords as keys", category: "Operator keywords as keys",
@ -2095,7 +2113,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: nil, expectedArgs: nil,
expectedErrorContains: "line 1:3 expecting one of {(, ), FREETEXT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got '='", expectedErrorContains: "line 1:3 expecting one of {(, ), FREETEXT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got '='",
}, },
{ {
category: "Operator keywords as keys", category: "Operator keywords as keys",
@ -2103,7 +2121,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: nil, expectedArgs: nil,
expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'between'", expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'between'",
}, },
{ {
category: "Operator keywords as keys", category: "Operator keywords as keys",
@ -2111,7 +2129,7 @@ func TestFilterExprLogs(t *testing.T) {
shouldPass: false, shouldPass: false,
expectedQuery: "", expectedQuery: "",
expectedArgs: nil, expectedArgs: nil,
expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), number, quoted text} but got 'in'", expectedErrorContains: "line 1:0 expecting one of {(, ), AND, FREETEXT, NOT, boolean, has(), hasAll(), hasAny(), hasToken(), number, quoted text} but got 'in'",
}, },
// Using function keywords as keys // Using function keywords as keys

View File

@ -300,13 +300,15 @@ func (v *variableReplacementVisitor) VisitComparison(ctx *grammar.ComparisonCont
} else if ctx.GE() != nil { } else if ctx.GE() != nil {
parts = append(parts, " >= ") parts = append(parts, " >= ")
} else if ctx.LIKE() != nil { } else if ctx.LIKE() != nil {
if ctx.NOT() != nil {
parts = append(parts, " NOT")
}
parts = append(parts, " LIKE ") parts = append(parts, " LIKE ")
} else if ctx.ILIKE() != nil { } else if ctx.ILIKE() != nil {
if ctx.NOT() != nil {
parts = append(parts, " NOT")
}
parts = append(parts, " ILIKE ") parts = append(parts, " ILIKE ")
} else if ctx.NOT_LIKE() != nil {
parts = append(parts, " NOT LIKE ")
} else if ctx.NOT_ILIKE() != nil {
parts = append(parts, " NOT ILIKE ")
} else if ctx.REGEXP() != nil { } else if ctx.REGEXP() != nil {
if ctx.NOT() != nil { if ctx.NOT() != nil {
parts = append(parts, " NOT") parts = append(parts, " NOT")
@ -396,6 +398,8 @@ func (v *variableReplacementVisitor) VisitFunctionCall(ctx *grammar.FunctionCall
functionName = "hasAny" functionName = "hasAny"
} else if ctx.HASALL() != nil { } else if ctx.HASALL() != nil {
functionName = "hasAll" functionName = "hasAll"
} else if ctx.HASTOKEN() != nil {
functionName = "hasToken"
} }
params := v.Visit(ctx.FunctionParamList()).(string) params := v.Visit(ctx.FunctionParamList()).(string)

View File

@ -235,6 +235,17 @@ func TestReplaceVariablesInExpression(t *testing.T) {
}, },
expected: "hasAny(tags, ('error', 'warning', 'info'))", expected: "hasAny(tags, ('error', 'warning', 'info'))",
}, },
{
name: "variable in hasToken function",
expression: "hasToken(tags, $tags)",
variables: map[string]qbtypes.VariableItem{
"tags": {
Type: qbtypes.DynamicVariableType,
Value: "test",
},
},
expected: "hasToken(tags, 'test')",
},
{ {
name: "empty array variable", name: "empty array variable",
expression: "service.name IN $services", expression: "service.name IN $services",