Skip to content

Commit 49bbfc2

Browse files
committed
Yank out some parsers too
1 parent 1c16761 commit 49bbfc2

File tree

10 files changed

+4285
-4272
lines changed

10 files changed

+4285
-4272
lines changed

x-pack/plugin/esql/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ tasks.register("regenParser", JavaExec) {
223223
'-package', 'org.elasticsearch.xpack.esql.parser',
224224
'-listener',
225225
'-visitor',
226-
'-o', outputPath,
227226
'-lib', outputPath,
227+
'-lib', "${file(grammarPath)}/parser",
228+
'-o', outputPath,
228229
"${file(grammarPath)}/EsqlBaseParser.g4"
229230
}
230231

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 3 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ options {
2020
tokenVocab=EsqlBaseLexer;
2121
}
2222

23+
import Expression,
24+
Join;
25+
2326
singleStatement
2427
: query EOF
2528
;
@@ -62,62 +65,6 @@ whereCommand
6265
: WHERE booleanExpression
6366
;
6467

65-
booleanExpression
66-
: NOT booleanExpression #logicalNot
67-
| valueExpression #booleanDefault
68-
| regexBooleanExpression #regexExpression
69-
| left=booleanExpression operator=AND right=booleanExpression #logicalBinary
70-
| left=booleanExpression operator=OR right=booleanExpression #logicalBinary
71-
| valueExpression (NOT)? IN LP valueExpression (COMMA valueExpression)* RP #logicalIn
72-
| valueExpression IS NOT? NULL #isNull
73-
| matchBooleanExpression #matchExpression
74-
;
75-
76-
regexBooleanExpression
77-
: valueExpression (NOT)? kind=LIKE pattern=string
78-
| valueExpression (NOT)? kind=RLIKE pattern=string
79-
;
80-
81-
matchBooleanExpression
82-
: fieldExp=qualifiedName (CAST_OP fieldType=dataType)? COLON matchQuery=constant
83-
;
84-
85-
valueExpression
86-
: operatorExpression #valueExpressionDefault
87-
| left=operatorExpression comparisonOperator right=operatorExpression #comparison
88-
;
89-
90-
operatorExpression
91-
: primaryExpression #operatorExpressionDefault
92-
| operator=(MINUS | PLUS) operatorExpression #arithmeticUnary
93-
| left=operatorExpression operator=(ASTERISK | SLASH | PERCENT) right=operatorExpression #arithmeticBinary
94-
| left=operatorExpression operator=(PLUS | MINUS) right=operatorExpression #arithmeticBinary
95-
;
96-
97-
primaryExpression
98-
: constant #constantDefault
99-
| qualifiedName #dereference
100-
| functionExpression #function
101-
| LP booleanExpression RP #parenthesizedExpression
102-
| primaryExpression CAST_OP dataType #inlineCast
103-
;
104-
105-
functionExpression
106-
: functionName LP (ASTERISK | (booleanExpression (COMMA booleanExpression)* (COMMA mapExpression)?))? RP
107-
;
108-
109-
functionName
110-
: identifierOrParameter
111-
;
112-
113-
mapExpression
114-
: LEFT_BRACES entryExpression (COMMA entryExpression)* RIGHT_BRACES
115-
;
116-
117-
entryExpression
118-
: key=string COLON value=constant
119-
;
120-
12168
dataType
12269
: identifier #toDataType
12370
;
@@ -198,19 +145,6 @@ identifierPattern
198145
| parameter
199146
;
200147

201-
constant
202-
: NULL #nullLiteral
203-
| integerValue UNQUOTED_IDENTIFIER #qualifiedIntegerLiteral
204-
| decimalValue #decimalLiteral
205-
| integerValue #integerLiteral
206-
| booleanValue #booleanLiteral
207-
| parameter #inputParameter
208-
| string #stringLiteral
209-
| OPENING_BRACKET numericValue (COMMA numericValue)* CLOSING_BRACKET #numericArrayLiteral
210-
| OPENING_BRACKET booleanValue (COMMA booleanValue)* CLOSING_BRACKET #booleanArrayLiteral
211-
| OPENING_BRACKET string (COMMA string)* CLOSING_BRACKET #stringArrayLiteral
212-
;
213-
214148
parameter
215149
: PARAM #inputParam
216150
| NAMED_OR_POSITIONAL_PARAM #inputNamedOrPositionalParam
@@ -269,31 +203,6 @@ commandOption
269203
: identifier ASSIGN constant
270204
;
271205

272-
booleanValue
273-
: TRUE | FALSE
274-
;
275-
276-
numericValue
277-
: decimalValue
278-
| integerValue
279-
;
280-
281-
decimalValue
282-
: (PLUS | MINUS)? DECIMAL_LITERAL
283-
;
284-
285-
integerValue
286-
: (PLUS | MINUS)? INTEGER_LITERAL
287-
;
288-
289-
string
290-
: QUOTED_STRING
291-
;
292-
293-
comparisonOperator
294-
: EQ | NEQ | LT | LTE | GT | GTE
295-
;
296-
297206
explainCommand
298207
: EXPLAIN subqueryExpression
299208
;
@@ -325,22 +234,6 @@ inlinestatsCommand
325234
: DEV_INLINESTATS stats=aggFields (BY grouping=fields)?
326235
;
327236

328-
joinCommand
329-
: type=(JOIN_LOOKUP | DEV_JOIN_LEFT | DEV_JOIN_RIGHT) JOIN joinTarget joinCondition
330-
;
331-
332-
joinTarget
333-
: index=indexPattern
334-
;
335-
336-
joinCondition
337-
: ON joinPredicate (COMMA joinPredicate)*
338-
;
339-
340-
joinPredicate
341-
: valueExpression
342-
;
343-
344237
changePointCommand
345238
: DEV_CHANGE_POINT value=qualifiedName (ON key=qualifiedName)? (AS targetType=qualifiedName COMMA targetPvalue=qualifiedName)?
346239
;
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
parser grammar Expression;
8+
9+
booleanExpression
10+
: NOT booleanExpression #logicalNot
11+
| valueExpression #booleanDefault
12+
| regexBooleanExpression #regexExpression
13+
| left=booleanExpression operator=AND right=booleanExpression #logicalBinary
14+
| left=booleanExpression operator=OR right=booleanExpression #logicalBinary
15+
| valueExpression (NOT)? IN LP valueExpression (COMMA valueExpression)* RP #logicalIn
16+
| valueExpression IS NOT? NULL #isNull
17+
| matchBooleanExpression #matchExpression
18+
;
19+
20+
regexBooleanExpression
21+
: valueExpression (NOT)? kind=LIKE pattern=string
22+
| valueExpression (NOT)? kind=RLIKE pattern=string
23+
;
24+
25+
matchBooleanExpression
26+
: fieldExp=qualifiedName (CAST_OP fieldType=dataType)? COLON matchQuery=constant
27+
;
28+
29+
valueExpression
30+
: operatorExpression #valueExpressionDefault
31+
| left=operatorExpression comparisonOperator right=operatorExpression #comparison
32+
;
33+
34+
operatorExpression
35+
: primaryExpression #operatorExpressionDefault
36+
| operator=(MINUS | PLUS) operatorExpression #arithmeticUnary
37+
| left=operatorExpression operator=(ASTERISK | SLASH | PERCENT) right=operatorExpression #arithmeticBinary
38+
| left=operatorExpression operator=(PLUS | MINUS) right=operatorExpression #arithmeticBinary
39+
;
40+
41+
primaryExpression
42+
: constant #constantDefault
43+
| qualifiedName #dereference
44+
| functionExpression #function
45+
| LP booleanExpression RP #parenthesizedExpression
46+
| primaryExpression CAST_OP dataType #inlineCast
47+
;
48+
49+
functionExpression
50+
: functionName LP (ASTERISK | (booleanExpression (COMMA booleanExpression)* (COMMA mapExpression)?))? RP
51+
;
52+
53+
functionName
54+
: identifierOrParameter
55+
;
56+
57+
mapExpression
58+
: LEFT_BRACES entryExpression (COMMA entryExpression)* RIGHT_BRACES
59+
;
60+
61+
entryExpression
62+
: key=string COLON value=constant
63+
;
64+
65+
constant
66+
: NULL #nullLiteral
67+
| integerValue UNQUOTED_IDENTIFIER #qualifiedIntegerLiteral
68+
| decimalValue #decimalLiteral
69+
| integerValue #integerLiteral
70+
| booleanValue #booleanLiteral
71+
| parameter #inputParameter
72+
| string #stringLiteral
73+
| OPENING_BRACKET numericValue (COMMA numericValue)* CLOSING_BRACKET #numericArrayLiteral
74+
| OPENING_BRACKET booleanValue (COMMA booleanValue)* CLOSING_BRACKET #booleanArrayLiteral
75+
| OPENING_BRACKET string (COMMA string)* CLOSING_BRACKET #stringArrayLiteral
76+
;
77+
78+
booleanValue
79+
: TRUE | FALSE
80+
;
81+
82+
numericValue
83+
: decimalValue
84+
| integerValue
85+
;
86+
87+
decimalValue
88+
: (PLUS | MINUS)? DECIMAL_LITERAL
89+
;
90+
91+
integerValue
92+
: (PLUS | MINUS)? INTEGER_LITERAL
93+
;
94+
95+
string
96+
: QUOTED_STRING
97+
;
98+
99+
comparisonOperator
100+
: EQ | NEQ | LT | LTE | GT | GTE
101+
;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
parser grammar Join;
8+
9+
joinCommand
10+
: type=(JOIN_LOOKUP | DEV_JOIN_LEFT | DEV_JOIN_RIGHT) JOIN joinTarget joinCondition
11+
;
12+
13+
joinTarget
14+
: index=indexPattern
15+
;
16+
17+
joinCondition
18+
: ON joinPredicate (COMMA joinPredicate)*
19+
;
20+
21+
joinPredicate
22+
: valueExpression
23+
;
24+
25+

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)