Skip to content

Commit

Permalink
[ES|QL] Update grammars (#196046)
Browse files Browse the repository at this point in the history
This PR updates the ES|QL grammars (lexer and parser) to match the
latest version in Elasticsearch.

---------

Co-authored-by: Stratoula Kalafateli <[email protected]>
(cherry picked from commit bed5c4e)
  • Loading branch information
kibanamachine committed Oct 15, 2024
1 parent 8041d69 commit 30a828e
Show file tree
Hide file tree
Showing 23 changed files with 1,904 additions and 1,996 deletions.
30 changes: 9 additions & 21 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ FROM : 'from' -> pushMode(FROM_MODE);
GROK : 'grok' -> pushMode(EXPRESSION_MODE);
KEEP : 'keep' -> pushMode(PROJECT_MODE);
LIMIT : 'limit' -> pushMode(EXPRESSION_MODE);
META : 'meta' -> pushMode(META_MODE);
MV_EXPAND : 'mv_expand' -> pushMode(MVEXPAND_MODE);
RENAME : 'rename' -> pushMode(RENAME_MODE);
ROW : 'row' -> pushMode(EXPRESSION_MODE);
Expand Down Expand Up @@ -309,6 +308,8 @@ mode PROJECT_MODE;
PROJECT_PIPE : PIPE -> type(PIPE), popMode;
PROJECT_DOT: DOT -> type(DOT);
PROJECT_COMMA : COMMA -> type(COMMA);
PROJECT_PARAM : PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
fragment UNQUOTED_ID_BODY_WITH_PATTERN
: (LETTER | DIGIT | UNDERSCORE | ASTERISK)
Expand Down Expand Up @@ -342,6 +343,8 @@ RENAME_PIPE : PIPE -> type(PIPE), popMode;
RENAME_ASSIGN : ASSIGN -> type(ASSIGN);
RENAME_COMMA : COMMA -> type(COMMA);
RENAME_DOT: DOT -> type(DOT);
RENAME_PARAM : PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
AS : 'as';
Expand Down Expand Up @@ -413,6 +416,9 @@ ENRICH_FIELD_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
;

ENRICH_FIELD_PARAM : PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

ENRICH_FIELD_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
;
Expand All @@ -428,6 +434,8 @@ ENRICH_FIELD_WS
mode MVEXPAND_MODE;
MVEXPAND_PIPE : PIPE -> type(PIPE), popMode;
MVEXPAND_DOT: DOT -> type(DOT);
MVEXPAND_PARAM : PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

MVEXPAND_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
Expand Down Expand Up @@ -469,26 +477,6 @@ SHOW_WS
: WS -> channel(HIDDEN)
;

//
// META commands
//
mode META_MODE;
META_PIPE : PIPE -> type(PIPE), popMode;

FUNCTIONS : 'functions';

META_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
;

META_MULTILINE_COMMENT
: MULTILINE_COMMENT -> channel(HIDDEN)
;

META_WS
: WS -> channel(HIDDEN)
;

mode SETTING_MODE;
SETTING_CLOSING_BRACKET : CLOSING_BRACKET -> type(CLOSING_BRACKET), popMode;

Expand Down
27 changes: 9 additions & 18 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit 30a828e

Please sign in to comment.