[Step 1][ESQL] Syntax part (#146379)

Part of: #144296

## Summary

First step of `[ESQL] Improve the typing experience` (#144296). This PR
is the skeleton for later parts, but already supports basic parsing
scenarios.

## What was done: 
- [x] Added new `ESQL` language in `@kbn/monaco` package. Parsing was
done using the `antl` syntax;
- [x] `kbnUiSharedDeps`-srcJs bundle has been optimised, all workers
have been moved into separate chunks. This gave almost minus` 2 MB` 🕺
- [x] existing `esql` lang was renamed to `sql`. In order not to confuse
anyone in the future
- [x] some code from `painless` folder was moved to `common` and reused
in ESQL (probably needs some refactoring in future)

## Next steps: 
- [ ]  improving `ANLT` syntax to cover all cases
- [ ]  implementing `Autocomplete` feature

## How to use new `ESQL Lang`:
To use new language 2 properties should be set for `CodeEditor`
component

```ts
import { ESQL_LANG_ID, ESQL_THEME_ID  } from '@kbn/monaco';
import { CodeEditor  } from '@kbn/kibana-react-plugin/public';

 <CodeEditor
      ...
      languageId={ESQL_LANG_ID}
      options={{
        ...
        theme: ESQL_THEME_ID,
      }}
 />
```

Currently syntax highlighting looks like: 

<img width="450" alt="image"
src="https://user-images.githubusercontent.com/20072247/205685072-0658fad1-d034-4d36-a44d-6a49e7365ab3.png">

<img width="450" alt="image"
src="https://user-images.githubusercontent.com/20072247/205685220-c67db50c-6f3b-49b5-9576-d1ee68428184.png">


Will be updated in Step 2

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
This commit is contained in:
Alexey Antonov 2022-12-07 14:12:28 +03:00 committed by GitHub
parent 9b828e3c4c
commit 464a9f7cf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 6172 additions and 144 deletions

View file

@ -39,7 +39,7 @@ snapshots.js
/packages/kbn-test/src/functional_test_runner/lib/config/__tests__/fixtures/
/packages/kbn-ui-framework/dist
/packages/kbn-flot-charts/lib
/packages/kbn-monaco/src/painless/antlr
/packages/kbn-monaco/src/**/antlr
# Bazel
/bazel-*

View file

@ -42,6 +42,7 @@ NPM_MODULE_EXTRA_FILES = [
RUNTIME_DEPS = [
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"//packages/kbn-ui-theme",
"@npm//@babel/runtime",
"@npm//antlr4ts",
"@npm//babel-loader",
@ -52,6 +53,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-i18n:npm_module_types",
"//packages/kbn-ui-theme:npm_module_types",
"@npm//antlr4ts",
"@npm//monaco-editor",
"@npm//rxjs",

View file

@ -11,7 +11,9 @@ import './src/register_globals';
export { monaco } from './src/monaco_imports';
export { XJsonLang } from './src/xjson';
export { EsqlLang } from './src/esql';
export { SQLLang } from './src/sql';
export { ESQL_LANG_ID, ESQL_THEME_ID } from './src/esql';
export * from './src/painless';
/* eslint-disable-next-line @kbn/eslint/module_migration */
import * as BarePluginApi from 'monaco-editor/esm/vs/editor/editor.api';

View file

@ -6,7 +6,10 @@
"main": "target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0",
"scripts": {
"build:antlr4ts": "../../node_modules/antlr4ts-cli/antlr4ts ./src/painless/antlr/painless_lexer.g4 ./src/painless/antlr/painless_parser.g4 && node ./scripts/fix_generated_antlr.js"
"build:antlr4ts:painless": "../../node_modules/antlr4ts-cli/antlr4ts ./src/painless/antlr/painless_lexer.g4 ./src/painless/antlr/painless_parser.g4 && node ./scripts/fix_generated_antlr.js painless",
"build:antlr4ts:esql": "../../node_modules/antlr4ts-cli/antlr4ts src/esql/antlr/esql_lexer.g4 src/esql/antlr/esql_parser.g4 && node ./scripts/fix_generated_antlr.js esql",
"build:antlr4ts": "npm run build:antlr4ts:painless && npm run build:antlr4ts:esql"
},
"types": "./target_types/index.d.ts"
}

View file

@ -9,47 +9,60 @@
const { join } = require('path');
const { readdirSync, readFileSync, writeFileSync, renameSync } = require('fs');
const ora = require('ora');
const generatedAntlrFolder = join(__dirname, '..', 'src', 'painless', 'antlr');
const generatedAntlrFolderContents = readdirSync(generatedAntlrFolder);
const log = ora('Updating generated antlr grammar').start();
// The generated TS produces some TS linting errors
// This script adds a //@ts-nocheck comment at the top of each generated file
// so that the errors can be ignored for now
generatedAntlrFolderContents
.filter((file) => {
const fileExtension = file.split('.')[1];
return fileExtension.includes('ts');
})
.forEach((file) => {
try {
const fileContentRows = readFileSync(join(generatedAntlrFolder, file), 'utf8')
.toString()
.split('\n');
const SUPPORTED_FOLDERS = ['painless', 'esql'];
fileContentRows.unshift('// @ts-nocheck');
function execute(folder) {
const generatedAntlrFolder = join(__dirname, '..', 'src', folder, 'antlr');
const filePath = join(generatedAntlrFolder, file);
const fileContent = fileContentRows.join('\n');
const generatedAntlrFolderContents = readdirSync(generatedAntlrFolder);
writeFileSync(filePath, fileContent, { encoding: 'utf8' });
} catch (err) {
return log.fail(err.message);
}
});
// The generated TS produces some TS linting errors
// This script adds a //@ts-nocheck comment at the top of each generated file
// so that the errors can be ignored for now
generatedAntlrFolderContents
.filter((file) => {
const fileExtension = file.split('.')[1];
return fileExtension.includes('ts');
})
.forEach((file) => {
try {
const fileContentRows = readFileSync(join(generatedAntlrFolder, file), 'utf8')
.toString()
.split('\n');
// Rename generated parserListener file to snakecase to satisfy file casing check
// There doesn't appear to be a way to fix this OOTB with antlr4ts-cli
try {
renameSync(
join(generatedAntlrFolder, 'painless_parserListener.ts'),
join(generatedAntlrFolder, 'painless_parser_listener.ts')
);
} catch (err) {
log.warn(`Unable to rename parserListener file to snakecase: ${err.message}`);
fileContentRows.unshift('// @ts-nocheck');
const filePath = join(generatedAntlrFolder, file);
const fileContent = fileContentRows.join('\n');
writeFileSync(filePath, fileContent, { encoding: 'utf8' });
} catch (err) {
return log.fail(err.message);
}
});
// Rename generated parserListener file to snakecase to satisfy file casing check
// There doesn't appear to be a way to fix this OOTB with antlr4ts-cli
try {
renameSync(
join(generatedAntlrFolder, `${folder}_parserListener.ts`),
join(generatedAntlrFolder, `${folder}_parser_listener.ts`)
);
} catch (err) {
log.warn(`Unable to rename parserListener file to snake-case: ${err.message}`);
}
log.succeed('Updated generated antlr grammar successfully');
}
log.succeed('Updated generated antlr grammar successfully');
const [folder] = process.argv.slice(2);
if (!SUPPORTED_FOLDERS.includes(folder)) {
log.warn(
`Target folder should be one of: ${SUPPORTED_FOLDERS.join(' ')}. Got: ${folder ?? '(empty)'}`
);
} else {
execute(folder);
}

View file

@ -12,7 +12,6 @@ import { Subscription } from 'rxjs';
import { MockIModel } from '../__jest__/types';
import { LangValidation } from '../types';
import { monaco } from '../monaco_imports';
import { ID } from './constants';
import { DiagnosticsAdapter } from './diagnostics_adapter';
@ -24,10 +23,12 @@ const getMockWorker = async () => {
} as any;
};
const ID = 'painless';
const flushPromises = () =>
new Promise((resolve) => jest.requireActual('timers').setImmediate(resolve));
describe('Painless DiagnosticAdapter', () => {
describe('DiagnosticAdapter', () => {
let diagnosticAdapter: DiagnosticsAdapter;
let subscription: Subscription;
let model: MockIModel;
@ -43,7 +44,7 @@ describe('Painless DiagnosticAdapter', () => {
beforeEach(async () => {
model = monaco.editor.createModel(ID) as unknown as MockIModel;
diagnosticAdapter = new DiagnosticsAdapter(getMockWorker);
diagnosticAdapter = new DiagnosticsAdapter(ID, getMockWorker);
// validate() has a promise we need to wait for
// --> await worker.getSyntaxErrors()

View file

@ -9,18 +9,17 @@
import { BehaviorSubject } from 'rxjs';
import { monaco } from '../monaco_imports';
import { SyntaxErrors, LangValidation } from '../types';
import { ID } from './constants';
import { WorkerAccessor } from './language';
import { PainlessError } from './worker';
import type { SyntaxErrors, LangValidation, EditorError, BaseWorkerDefinition } from '../types';
const toDiagnostics = (error: PainlessError): monaco.editor.IMarkerData => {
const toDiagnostics = (error: EditorError): monaco.editor.IMarkerData => {
return {
...error,
severity: monaco.MarkerSeverity.Error,
};
};
export type WorkerAccessor = (...uris: monaco.Uri[]) => Promise<BaseWorkerDefinition>;
export class DiagnosticsAdapter {
private errors: SyntaxErrors = {};
private validation = new BehaviorSubject<LangValidation>({
@ -33,14 +32,14 @@ export class DiagnosticsAdapter {
public validation$ = this.validation.asObservable();
constructor(private worker: WorkerAccessor) {
constructor(private langId: string, private worker: WorkerAccessor) {
const onModelAdd = (model: monaco.editor.IModel): void => {
let handle: any;
if (model.getModeId() === ID) {
if (model.getModeId() === this.langId) {
model.onDidChangeContent(() => {
// Do not validate if the language ID has changed
if (model.getModeId() !== ID) {
if (model.getModeId() !== this.langId) {
return;
}
@ -54,7 +53,7 @@ export class DiagnosticsAdapter {
isValidating: false,
errors: [],
});
return monaco.editor.setModelMarkers(model, ID, []);
return monaco.editor.setModelMarkers(model, this.langId, []);
}
this.validation.next({
@ -70,8 +69,8 @@ export class DiagnosticsAdapter {
model.onDidChangeLanguage(({ newLanguage }) => {
// Reset the model markers if the language ID has changed and is no longer "painless"
// Otherwise, re-validate
if (newLanguage !== ID) {
return monaco.editor.setModelMarkers(model, ID, []);
if (newLanguage !== this.langId) {
return monaco.editor.setModelMarkers(model, this.langId, []);
} else {
this.validate(model.uri, ++this.validateIdx);
}
@ -107,7 +106,7 @@ export class DiagnosticsAdapter {
[model!.id]: errorMarkers,
};
// Set the error markers and underline them with "Error" severity
monaco.editor.setModelMarkers(model!, ID, errorMarkers.map(toDiagnostics));
monaco.editor.setModelMarkers(model!, this.langId, errorMarkers.map(toDiagnostics));
}
const isValid = errorMarkers === undefined || errorMarkers.length === 0;

View file

@ -7,17 +7,10 @@
*/
import { ANTLRErrorListener, RecognitionException, Recognizer } from 'antlr4ts';
import type { EditorError } from '../types';
export interface PainlessError {
startLineNumber: number;
startColumn: number;
endLineNumber: number;
endColumn: number;
message: string;
}
export class PainlessErrorListener implements ANTLRErrorListener<any> {
private errors: PainlessError[] = [];
export class ANTLREErrorListener implements ANTLRErrorListener<any> {
private errors: EditorError[] = [];
syntaxError(
recognizer: Recognizer<any, any>,
@ -42,7 +35,7 @@ export class PainlessErrorListener implements ANTLRErrorListener<any> {
});
}
getErrors(): PainlessError[] {
getErrors(): EditorError[] {
return this.errors;
}
}

View file

@ -6,12 +6,11 @@
* Side Public License, v 1.
*/
import { monaco } from '../../monaco_imports';
import { PainlessWorker } from '../worker';
import { ID } from '../constants';
import { monaco } from '../monaco_imports';
import type { BaseWorkerDefinition } from '../types';
export class WorkerProxyService {
private worker: monaco.editor.MonacoWebWorker<PainlessWorker> | undefined;
export class WorkerProxyService<IWorker extends BaseWorkerDefinition> {
private worker: monaco.editor.MonacoWebWorker<IWorker> | undefined;
public async getWorker(resources: monaco.Uri[]) {
if (!this.worker) {
@ -19,12 +18,11 @@ export class WorkerProxyService {
}
await this.worker.withSyncedResources(resources);
const proxy = await this.worker.getProxy();
return proxy;
return await this.worker.getProxy();
}
public setup() {
this.worker = monaco.editor.createWebWorker({ label: ID, moduleId: '' });
public setup(langId: string) {
this.worker = monaco.editor.createWebWorker({ label: langId, moduleId: '' });
}
public stop() {

View file

@ -0,0 +1,167 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
lexer grammar esql_lexer;
EVAL : 'eval' -> pushMode(EXPRESSION);
EXPLAIN : 'explain' -> pushMode(EXPRESSION);
FROM : 'from' -> pushMode(SOURCE_IDENTIFIERS);
ROW : 'row' -> pushMode(EXPRESSION);
STATS : 'stats' -> pushMode(EXPRESSION);
WHERE : 'where' -> pushMode(EXPRESSION);
SORT : 'sort' -> pushMode(EXPRESSION);
LIMIT : 'limit' -> pushMode(EXPRESSION);
PROJECT : 'project' -> pushMode(SOURCE_IDENTIFIERS);
LINE_COMMENT
: '//' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN)
;
MULTILINE_COMMENT
: '/*' (MULTILINE_COMMENT|.)*? '*/' -> channel(HIDDEN)
;
WS
: [ \r\n\t]+ -> channel(HIDDEN)
;
mode EXPRESSION;
PIPE : '|' -> popMode;
fragment DIGIT
: [0-9]
;
fragment LETTER
: [A-Za-z]
;
fragment ESCAPE_SEQUENCE
: '\\' [tnr"\\]
;
fragment UNESCAPED_CHARS
: ~[\r\n"\\]
;
fragment EXPONENT
: [Ee] [+-]? DIGIT+
;
STRING
: '"' (ESCAPE_SEQUENCE | UNESCAPED_CHARS)* '"'
| '"""' (~[\r\n])*? '"""' '"'? '"'?
;
INTEGER_LITERAL
: DIGIT+
;
DECIMAL_LITERAL
: DIGIT+ DOT DIGIT*
| DOT DIGIT+
| DIGIT+ (DOT DIGIT*)? EXPONENT
| DOT DIGIT+ EXPONENT
;
BY : 'by';
AND : 'and';
ASC : 'asc';
ASSIGN : '=';
COMMA : ',';
DESC : 'desc';
DOT : '.';
FALSE : 'false';
FIRST : 'first';
LAST : 'last';
LP : '(';
OPENING_BRACKET : '[' -> pushMode(DEFAULT_MODE);
CLOSING_BRACKET : ']' -> popMode, popMode; // pop twice, once to clear mode of current cmd and once to exit DEFAULT_MODE
NOT : 'not';
NULL : 'null';
NULLS : 'nulls';
OR : 'or';
RP : ')';
TRUE : 'true';
EQ : '==';
NEQ : '!=';
LT : '<';
LTE : '<=';
GT : '>';
GTE : '>=';
PLUS : '+';
MINUS : '-';
ASTERISK : '*';
SLASH : '/';
PERCENT : '%';
ROUND_FUNCTION_MATH : 'round';
AVG_FUNCTION_MATH : 'avg';
SUM_FUNCTION_MATH : 'sum';
MIN_FUNCTION_MATH : 'min';
MAX_FUNCTION_MATH : 'max';
UNQUOTED_IDENTIFIER
: (LETTER | '_') (LETTER | DIGIT | '_')*
;
QUOTED_IDENTIFIER
: '`' ( ~'`' | '``' )* '`'
;
EXPR_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
;
EXPR_MULTILINE_COMMENT
: MULTILINE_COMMENT -> channel(HIDDEN)
;
EXPR_WS
: WS -> channel(HIDDEN)
;
mode SOURCE_IDENTIFIERS;
SRC_PIPE : '|' -> type(PIPE), popMode;
SRC_CLOSING_BRACKET : ']' -> popMode, popMode, type(CLOSING_BRACKET);
SRC_COMMA : ',' -> type(COMMA);
SRC_ASSIGN : '=' -> type(ASSIGN);
SRC_UNQUOTED_IDENTIFIER
: SRC_UNQUOTED_IDENTIFIER_PART+
;
fragment SRC_UNQUOTED_IDENTIFIER_PART
: ~[=`|,[\]/ \t\r\n]+
| '/' ~[*/] // allow single / but not followed by another / or * which would start a comment
;
SRC_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER
;
SRC_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
;
SRC_MULTILINE_COMMENT
: MULTILINE_COMMENT -> channel(HIDDEN)
;
SRC_WS
: WS -> channel(HIDDEN)
;
UNKNOWN_CMD : ~[ \r\n\t[\]/]+ -> pushMode(EXPRESSION);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,104 @@
EVAL=1
EXPLAIN=2
FROM=3
ROW=4
STATS=5
WHERE=6
SORT=7
LIMIT=8
PROJECT=9
LINE_COMMENT=10
MULTILINE_COMMENT=11
WS=12
PIPE=13
STRING=14
INTEGER_LITERAL=15
DECIMAL_LITERAL=16
BY=17
AND=18
ASC=19
ASSIGN=20
COMMA=21
DESC=22
DOT=23
FALSE=24
FIRST=25
LAST=26
LP=27
OPENING_BRACKET=28
CLOSING_BRACKET=29
NOT=30
NULL=31
NULLS=32
OR=33
RP=34
TRUE=35
EQ=36
NEQ=37
LT=38
LTE=39
GT=40
GTE=41
PLUS=42
MINUS=43
ASTERISK=44
SLASH=45
PERCENT=46
ROUND_FUNCTION_MATH=47
AVG_FUNCTION_MATH=48
SUM_FUNCTION_MATH=49
MIN_FUNCTION_MATH=50
MAX_FUNCTION_MATH=51
UNQUOTED_IDENTIFIER=52
QUOTED_IDENTIFIER=53
EXPR_LINE_COMMENT=54
EXPR_MULTILINE_COMMENT=55
EXPR_WS=56
SRC_UNQUOTED_IDENTIFIER=57
SRC_QUOTED_IDENTIFIER=58
SRC_LINE_COMMENT=59
SRC_MULTILINE_COMMENT=60
SRC_WS=61
UNKNOWN_CMD=62
'eval'=1
'explain'=2
'from'=3
'row'=4
'stats'=5
'where'=6
'sort'=7
'limit'=8
'project'=9
'by'=17
'and'=18
'asc'=19
'desc'=22
'.'=23
'false'=24
'first'=25
'last'=26
'('=27
'['=28
']'=29
'not'=30
'null'=31
'nulls'=32
'or'=33
')'=34
'true'=35
'=='=36
'!='=37
'<'=38
'<='=39
'>'=40
'>='=41
'+'=42
'-'=43
'*'=44
'/'=45
'%'=46
'round'=47
'avg'=48
'sum'=49
'min'=50
'max'=51

View file

@ -0,0 +1,457 @@
// @ts-nocheck
// Generated from src/esql/antlr/esql_lexer.g4 by ANTLR 4.7.3-SNAPSHOT
import { ATN } from "antlr4ts/atn/ATN";
import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
import { CharStream } from "antlr4ts/CharStream";
import { Lexer } from "antlr4ts/Lexer";
import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator";
import { NotNull } from "antlr4ts/Decorators";
import { Override } from "antlr4ts/Decorators";
import { RuleContext } from "antlr4ts/RuleContext";
import { Vocabulary } from "antlr4ts/Vocabulary";
import { VocabularyImpl } from "antlr4ts/VocabularyImpl";
import * as Utils from "antlr4ts/misc/Utils";
export class esql_lexer extends Lexer {
public static readonly EVAL = 1;
public static readonly EXPLAIN = 2;
public static readonly FROM = 3;
public static readonly ROW = 4;
public static readonly STATS = 5;
public static readonly WHERE = 6;
public static readonly SORT = 7;
public static readonly LIMIT = 8;
public static readonly PROJECT = 9;
public static readonly LINE_COMMENT = 10;
public static readonly MULTILINE_COMMENT = 11;
public static readonly WS = 12;
public static readonly PIPE = 13;
public static readonly STRING = 14;
public static readonly INTEGER_LITERAL = 15;
public static readonly DECIMAL_LITERAL = 16;
public static readonly BY = 17;
public static readonly AND = 18;
public static readonly ASC = 19;
public static readonly ASSIGN = 20;
public static readonly COMMA = 21;
public static readonly DESC = 22;
public static readonly DOT = 23;
public static readonly FALSE = 24;
public static readonly FIRST = 25;
public static readonly LAST = 26;
public static readonly LP = 27;
public static readonly OPENING_BRACKET = 28;
public static readonly CLOSING_BRACKET = 29;
public static readonly NOT = 30;
public static readonly NULL = 31;
public static readonly NULLS = 32;
public static readonly OR = 33;
public static readonly RP = 34;
public static readonly TRUE = 35;
public static readonly EQ = 36;
public static readonly NEQ = 37;
public static readonly LT = 38;
public static readonly LTE = 39;
public static readonly GT = 40;
public static readonly GTE = 41;
public static readonly PLUS = 42;
public static readonly MINUS = 43;
public static readonly ASTERISK = 44;
public static readonly SLASH = 45;
public static readonly PERCENT = 46;
public static readonly ROUND_FUNCTION_MATH = 47;
public static readonly AVG_FUNCTION_MATH = 48;
public static readonly SUM_FUNCTION_MATH = 49;
public static readonly MIN_FUNCTION_MATH = 50;
public static readonly MAX_FUNCTION_MATH = 51;
public static readonly UNQUOTED_IDENTIFIER = 52;
public static readonly QUOTED_IDENTIFIER = 53;
public static readonly EXPR_LINE_COMMENT = 54;
public static readonly EXPR_MULTILINE_COMMENT = 55;
public static readonly EXPR_WS = 56;
public static readonly SRC_UNQUOTED_IDENTIFIER = 57;
public static readonly SRC_QUOTED_IDENTIFIER = 58;
public static readonly SRC_LINE_COMMENT = 59;
public static readonly SRC_MULTILINE_COMMENT = 60;
public static readonly SRC_WS = 61;
public static readonly UNKNOWN_CMD = 62;
public static readonly EXPRESSION = 1;
public static readonly SOURCE_IDENTIFIERS = 2;
// tslint:disable:no-trailing-whitespace
public static readonly channelNames: string[] = [
"DEFAULT_TOKEN_CHANNEL", "HIDDEN",
];
// tslint:disable:no-trailing-whitespace
public static readonly modeNames: string[] = [
"DEFAULT_MODE", "EXPRESSION", "SOURCE_IDENTIFIERS",
];
public static readonly ruleNames: string[] = [
"EVAL", "EXPLAIN", "FROM", "ROW", "STATS", "WHERE", "SORT", "LIMIT", "PROJECT",
"LINE_COMMENT", "MULTILINE_COMMENT", "WS", "PIPE", "DIGIT", "LETTER",
"ESCAPE_SEQUENCE", "UNESCAPED_CHARS", "EXPONENT", "STRING", "INTEGER_LITERAL",
"DECIMAL_LITERAL", "BY", "AND", "ASC", "ASSIGN", "COMMA", "DESC", "DOT",
"FALSE", "FIRST", "LAST", "LP", "OPENING_BRACKET", "CLOSING_BRACKET",
"NOT", "NULL", "NULLS", "OR", "RP", "TRUE", "EQ", "NEQ", "LT", "LTE",
"GT", "GTE", "PLUS", "MINUS", "ASTERISK", "SLASH", "PERCENT", "ROUND_FUNCTION_MATH",
"AVG_FUNCTION_MATH", "SUM_FUNCTION_MATH", "MIN_FUNCTION_MATH", "MAX_FUNCTION_MATH",
"UNQUOTED_IDENTIFIER", "QUOTED_IDENTIFIER", "EXPR_LINE_COMMENT", "EXPR_MULTILINE_COMMENT",
"EXPR_WS", "SRC_PIPE", "SRC_CLOSING_BRACKET", "SRC_COMMA", "SRC_ASSIGN",
"SRC_UNQUOTED_IDENTIFIER", "SRC_UNQUOTED_IDENTIFIER_PART", "SRC_QUOTED_IDENTIFIER",
"SRC_LINE_COMMENT", "SRC_MULTILINE_COMMENT", "SRC_WS", "UNKNOWN_CMD",
];
private static readonly _LITERAL_NAMES: Array<string | undefined> = [
undefined, "'eval'", "'explain'", "'from'", "'row'", "'stats'", "'where'",
"'sort'", "'limit'", "'project'", undefined, undefined, undefined, undefined,
undefined, undefined, undefined, "'by'", "'and'", "'asc'", undefined,
undefined, "'desc'", "'.'", "'false'", "'first'", "'last'", "'('", "'['",
"']'", "'not'", "'null'", "'nulls'", "'or'", "')'", "'true'", "'=='",
"'!='", "'<'", "'<='", "'>'", "'>='", "'+'", "'-'", "'*'", "'/'", "'%'",
"'round'", "'avg'", "'sum'", "'min'", "'max'",
];
private static readonly _SYMBOLIC_NAMES: Array<string | undefined> = [
undefined, "EVAL", "EXPLAIN", "FROM", "ROW", "STATS", "WHERE", "SORT",
"LIMIT", "PROJECT", "LINE_COMMENT", "MULTILINE_COMMENT", "WS", "PIPE",
"STRING", "INTEGER_LITERAL", "DECIMAL_LITERAL", "BY", "AND", "ASC", "ASSIGN",
"COMMA", "DESC", "DOT", "FALSE", "FIRST", "LAST", "LP", "OPENING_BRACKET",
"CLOSING_BRACKET", "NOT", "NULL", "NULLS", "OR", "RP", "TRUE", "EQ", "NEQ",
"LT", "LTE", "GT", "GTE", "PLUS", "MINUS", "ASTERISK", "SLASH", "PERCENT",
"ROUND_FUNCTION_MATH", "AVG_FUNCTION_MATH", "SUM_FUNCTION_MATH", "MIN_FUNCTION_MATH",
"MAX_FUNCTION_MATH", "UNQUOTED_IDENTIFIER", "QUOTED_IDENTIFIER", "EXPR_LINE_COMMENT",
"EXPR_MULTILINE_COMMENT", "EXPR_WS", "SRC_UNQUOTED_IDENTIFIER", "SRC_QUOTED_IDENTIFIER",
"SRC_LINE_COMMENT", "SRC_MULTILINE_COMMENT", "SRC_WS", "UNKNOWN_CMD",
];
public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(esql_lexer._LITERAL_NAMES, esql_lexer._SYMBOLIC_NAMES, []);
// @Override
// @NotNull
public get vocabulary(): Vocabulary {
return esql_lexer.VOCABULARY;
}
// tslint:enable:no-trailing-whitespace
constructor(input: CharStream) {
super(input);
this._interp = new LexerATNSimulator(esql_lexer._ATN, this);
}
// @Override
public get grammarFileName(): string { return "esql_lexer.g4"; }
// @Override
public get ruleNames(): string[] { return esql_lexer.ruleNames; }
// @Override
public get serializedATN(): string { return esql_lexer._serializedATN; }
// @Override
public get channelNames(): string[] { return esql_lexer.channelNames; }
// @Override
public get modeNames(): string[] { return esql_lexer.modeNames; }
private static readonly _serializedATNSegments: number = 2;
private static readonly _serializedATNSegment0: string =
"\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02@\u023D\b\x01" +
"\b\x01\b\x01\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04" +
"\x06\t\x06\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f" +
"\t\f\x04\r\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11" +
"\x04\x12\t\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16" +
"\x04\x17\t\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\x04\x1B\t\x1B" +
"\x04\x1C\t\x1C\x04\x1D\t\x1D\x04\x1E\t\x1E\x04\x1F\t\x1F\x04 \t \x04!" +
"\t!\x04\"\t\"\x04#\t#\x04$\t$\x04%\t%\x04&\t&\x04\'\t\'\x04(\t(\x04)\t" +
")\x04*\t*\x04+\t+\x04,\t,\x04-\t-\x04.\t.\x04/\t/\x040\t0\x041\t1\x04" +
"2\t2\x043\t3\x044\t4\x045\t5\x046\t6\x047\t7\x048\t8\x049\t9\x04:\t:\x04" +
";\t;\x04<\t<\x04=\t=\x04>\t>\x04?\t?\x04@\t@\x04A\tA\x04B\tB\x04C\tC\x04" +
"D\tD\x04E\tE\x04F\tF\x04G\tG\x04H\tH\x04I\tI\x03\x02\x03\x02\x03\x02\x03" +
"\x02\x03\x02\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" +
"\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03" +
"\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03\x05\x03\x05\x03\x05\x03\x05\x03" +
"\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03\x07\x03" +
"\x07\x03\x07\x03\x07\x03\x07\x03\x07\x03\x07\x03\x07\x03\b\x03\b\x03\b" +
"\x03\b\x03\b\x03\b\x03\b\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03\t\x03" +
"\t\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\n\x03\v\x03" +
"\v\x03\v\x03\v\x07\v\xE1\n\v\f\v\x0E\v\xE4\v\v\x03\v\x05\v\xE7\n\v\x03" +
"\v\x05\v\xEA\n\v\x03\v\x03\v\x03\f\x03\f\x03\f\x03\f\x03\f\x07\f\xF3\n" +
"\f\f\f\x0E\f\xF6\v\f\x03\f\x03\f\x03\f\x03\f\x03\f\x03\r\x06\r\xFE\n\r" +
"\r\r\x0E\r\xFF\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0E\x03\x0E\x03\x0F\x03" +
"\x0F\x03\x10\x03\x10\x03\x11\x03\x11\x03\x11\x03\x12\x03\x12\x03\x13\x03" +
"\x13\x05\x13\u0113\n\x13\x03\x13\x06\x13\u0116\n\x13\r\x13\x0E\x13\u0117" +
"\x03\x14\x03\x14\x03\x14\x07\x14\u011D\n\x14\f\x14\x0E\x14\u0120\v\x14" +
"\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x07\x14\u0128\n\x14\f" +
"\x14\x0E\x14\u012B\v\x14\x03\x14\x03\x14\x03\x14\x03\x14\x03\x14\x05\x14" +
"\u0132\n\x14\x03\x14\x05\x14\u0135\n\x14\x05\x14\u0137\n\x14\x03\x15\x06" +
"\x15\u013A\n\x15\r\x15\x0E\x15\u013B\x03\x16\x06\x16\u013F\n\x16\r\x16" +
"\x0E\x16\u0140\x03\x16\x03\x16\x07\x16\u0145\n\x16\f\x16\x0E\x16\u0148" +
"\v\x16\x03\x16\x03\x16\x06\x16\u014C\n\x16\r\x16\x0E\x16\u014D\x03\x16" +
"\x06\x16\u0151\n\x16\r\x16\x0E\x16\u0152\x03\x16\x03\x16\x07\x16\u0157" +
"\n\x16\f\x16\x0E\x16\u015A\v\x16\x05\x16\u015C\n\x16\x03\x16\x03\x16\x03" +
"\x16\x03\x16\x06\x16\u0162\n\x16\r\x16\x0E\x16\u0163\x03\x16\x03\x16\x05" +
"\x16\u0168\n\x16\x03\x17\x03\x17\x03\x17\x03\x18\x03\x18\x03\x18\x03\x18" +
"\x03\x19\x03\x19\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1B\x03\x1B\x03\x1C" +
"\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1E" +
"\x03\x1E\x03\x1E\x03\x1E\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F" +
"\x03 \x03 \x03 \x03 \x03 \x03!\x03!\x03\"\x03\"\x03\"\x03\"\x03#\x03#" +
"\x03#\x03#\x03#\x03$\x03$\x03$\x03$\x03%\x03%\x03%\x03%\x03%\x03&\x03" +
"&\x03&\x03&\x03&\x03&\x03\'\x03\'\x03\'\x03(\x03(\x03)\x03)\x03)\x03)" +
"\x03)\x03*\x03*\x03*\x03+\x03+\x03+\x03,\x03,\x03-\x03-\x03-\x03.\x03" +
".\x03/\x03/\x03/\x030\x030\x031\x031\x032\x032\x033\x033\x034\x034\x03" +
"5\x035\x035\x035\x035\x035\x036\x036\x036\x036\x037\x037\x037\x037\x03" +
"8\x038\x038\x038\x039\x039\x039\x039\x03:\x03:\x05:\u01E7\n:\x03:\x03" +
":\x03:\x07:\u01EC\n:\f:\x0E:\u01EF\v:\x03;\x03;\x03;\x03;\x07;\u01F5\n" +
";\f;\x0E;\u01F8\v;\x03;\x03;\x03<\x03<\x03<\x03<\x03=\x03=\x03=\x03=\x03" +
">\x03>\x03>\x03>\x03?\x03?\x03?\x03?\x03?\x03@\x03@\x03@\x03@\x03@\x03" +
"@\x03A\x03A\x03A\x03A\x03B\x03B\x03B\x03B\x03C\x06C\u021C\nC\rC\x0EC\u021D" +
"\x03D\x06D\u0221\nD\rD\x0ED\u0222\x03D\x03D\x05D\u0227\nD\x03E\x03E\x03" +
"F\x03F\x03F\x03F\x03G\x03G\x03G\x03G\x03H\x03H\x03H\x03H\x03I\x06I\u0238" +
"\nI\rI\x0EI\u0239\x03I\x03I\x04\xF4\u0129\x02\x02J\x05\x02\x03\x07\x02" +
"\x04\t\x02\x05\v\x02\x06\r\x02\x07\x0F\x02\b\x11\x02\t\x13\x02\n\x15\x02" +
"\v\x17\x02\f\x19\x02\r\x1B\x02\x0E\x1D\x02\x0F\x1F\x02\x02!\x02\x02#\x02" +
"\x02%\x02\x02\'\x02\x02)\x02\x10+\x02\x11-\x02\x12/\x02\x131\x02\x143" +
"\x02\x155\x02\x167\x02\x179\x02\x18;\x02\x19=\x02\x1A?\x02\x1BA\x02\x1C" +
"C\x02\x1DE\x02\x1EG\x02\x1FI\x02 K\x02!M\x02\"O\x02#Q\x02$S\x02%U\x02" +
"&W\x02\'Y\x02([\x02)]\x02*_\x02+a\x02,c\x02-e\x02.g\x02/i\x020k\x021m" +
"\x022o\x023q\x024s\x025u\x026w\x027y\x028{\x029}\x02:\x7F\x02\x02\x81" +
"\x02\x02\x83\x02\x02\x85\x02\x02\x87\x02;\x89\x02\x02\x8B\x02<\x8D\x02" +
"=\x8F\x02>\x91\x02?\x93\x02@\x05\x02\x03\x04\x0E\x04\x02\f\f\x0F\x0F\x05" +
"\x02\v\f\x0F\x0F\"\"\x03\x022;\x04\x02C\\c|\x07\x02$$^^ppttvv\x06\x02" +
"\f\f\x0F\x0F$$^^\x04\x02GGgg\x04\x02--//\x03\x02bb\f\x02\v\f\x0F\x0F\"" +
"\"..11??]]__bb~~\x04\x02,,11\b\x02\v\f\x0F\x0F\"\"11]]__\x02\u0257\x02" +
"\x05\x03\x02\x02\x02\x02\x07\x03\x02\x02\x02\x02\t\x03\x02\x02\x02\x02" +
"\v\x03\x02\x02\x02\x02\r\x03\x02\x02\x02\x02\x0F\x03\x02\x02\x02\x02\x11" +
"\x03\x02\x02\x02\x02\x13\x03\x02\x02\x02\x02\x15\x03\x02\x02\x02\x02\x17" +
"\x03\x02\x02\x02\x02\x19\x03\x02\x02\x02\x02\x1B\x03\x02\x02\x02\x03\x1D" +
"\x03\x02\x02\x02\x03)\x03\x02\x02\x02\x03+\x03\x02\x02\x02\x03-\x03\x02" +
"\x02\x02\x03/\x03\x02\x02\x02\x031\x03\x02\x02\x02\x033\x03\x02\x02\x02" +
"\x035\x03\x02\x02\x02\x037\x03\x02\x02\x02\x039\x03\x02\x02\x02\x03;\x03" +
"\x02\x02\x02\x03=\x03\x02\x02\x02\x03?\x03\x02\x02\x02\x03A\x03\x02\x02" +
"\x02\x03C\x03\x02\x02\x02\x03E\x03\x02\x02\x02\x03G\x03\x02\x02\x02\x03" +
"I\x03\x02\x02\x02\x03K\x03\x02\x02\x02\x03M\x03\x02\x02\x02\x03O\x03\x02" +
"\x02\x02\x03Q\x03\x02\x02\x02\x03S\x03\x02\x02\x02\x03U\x03\x02\x02\x02" +
"\x03W\x03\x02\x02\x02\x03Y\x03\x02\x02\x02\x03[\x03\x02\x02\x02\x03]\x03" +
"\x02\x02\x02\x03_\x03\x02\x02\x02\x03a\x03\x02\x02\x02\x03c\x03\x02\x02" +
"\x02\x03e\x03\x02\x02\x02\x03g\x03\x02\x02\x02\x03i\x03\x02\x02\x02\x03" +
"k\x03\x02\x02\x02\x03m\x03\x02\x02\x02\x03o\x03\x02\x02\x02\x03q\x03\x02" +
"\x02\x02\x03s\x03\x02\x02\x02\x03u\x03\x02\x02\x02\x03w\x03\x02\x02\x02" +
"\x03y\x03\x02\x02\x02\x03{\x03\x02\x02\x02\x03}\x03\x02\x02\x02\x04\x7F" +
"\x03\x02\x02\x02\x04\x81\x03\x02\x02\x02\x04\x83\x03\x02\x02\x02\x04\x85" +
"\x03\x02\x02\x02\x04\x87\x03\x02\x02\x02\x04\x8B\x03\x02\x02\x02\x04\x8D" +
"\x03\x02\x02\x02\x04\x8F\x03\x02\x02\x02\x04\x91\x03\x02\x02\x02\x04\x93" +
"\x03\x02\x02\x02\x05\x95\x03\x02\x02\x02\x07\x9C\x03\x02\x02\x02\t\xA6" +
"\x03\x02\x02\x02\v\xAD\x03\x02\x02\x02\r\xB3\x03\x02\x02\x02\x0F\xBB\x03" +
"\x02\x02\x02\x11\xC3\x03\x02\x02\x02\x13\xCA\x03\x02\x02\x02\x15\xD2\x03" +
"\x02\x02\x02\x17\xDC\x03\x02\x02\x02\x19\xED\x03\x02\x02\x02\x1B\xFD\x03" +
"\x02\x02\x02\x1D\u0103\x03\x02\x02\x02\x1F\u0107\x03\x02\x02\x02!\u0109" +
"\x03\x02\x02\x02#\u010B\x03\x02\x02\x02%\u010E\x03\x02\x02\x02\'\u0110" +
"\x03\x02\x02\x02)\u0136\x03\x02\x02\x02+\u0139\x03\x02\x02\x02-\u0167" +
"\x03\x02\x02\x02/\u0169\x03\x02\x02\x021\u016C\x03\x02\x02\x023\u0170" +
"\x03\x02\x02\x025\u0174\x03\x02\x02\x027\u0176\x03\x02\x02\x029\u0178" +
"\x03\x02\x02\x02;\u017D\x03\x02\x02\x02=\u017F\x03\x02\x02\x02?\u0185" +
"\x03\x02\x02\x02A\u018B\x03\x02\x02\x02C\u0190\x03\x02\x02\x02E\u0192" +
"\x03\x02\x02\x02G\u0196\x03\x02\x02\x02I\u019B\x03\x02\x02\x02K\u019F" +
"\x03\x02\x02\x02M\u01A4\x03\x02\x02\x02O\u01AA\x03\x02\x02\x02Q\u01AD" +
"\x03\x02\x02\x02S\u01AF\x03\x02\x02\x02U\u01B4\x03\x02\x02\x02W\u01B7" +
"\x03\x02\x02\x02Y\u01BA\x03\x02\x02\x02[\u01BC\x03\x02\x02\x02]\u01BF" +
"\x03\x02\x02\x02_\u01C1\x03\x02\x02\x02a\u01C4\x03\x02\x02\x02c\u01C6" +
"\x03\x02\x02\x02e\u01C8\x03\x02\x02\x02g\u01CA\x03\x02\x02\x02i\u01CC" +
"\x03\x02\x02\x02k\u01CE\x03\x02\x02\x02m\u01D4\x03\x02\x02\x02o\u01D8" +
"\x03\x02\x02\x02q\u01DC\x03\x02\x02\x02s\u01E0\x03\x02\x02\x02u\u01E6" +
"\x03\x02\x02\x02w\u01F0\x03\x02\x02\x02y\u01FB\x03\x02\x02\x02{\u01FF" +
"\x03\x02\x02\x02}\u0203\x03\x02\x02\x02\x7F\u0207\x03\x02\x02\x02\x81" +
"\u020C\x03\x02\x02\x02\x83\u0212\x03\x02\x02\x02\x85\u0216\x03\x02\x02" +
"\x02\x87\u021B\x03\x02\x02\x02\x89\u0226\x03\x02\x02\x02\x8B\u0228\x03" +
"\x02\x02\x02\x8D\u022A\x03\x02\x02\x02\x8F\u022E\x03\x02\x02\x02\x91\u0232" +
"\x03\x02\x02\x02\x93\u0237\x03\x02\x02\x02\x95\x96\x07g\x02\x02\x96\x97" +
"\x07x\x02\x02\x97\x98\x07c\x02\x02\x98\x99\x07n\x02\x02\x99\x9A\x03\x02" +
"\x02\x02\x9A\x9B\b\x02\x02\x02\x9B\x06\x03\x02\x02\x02\x9C\x9D\x07g\x02" +
"\x02\x9D\x9E\x07z\x02\x02\x9E\x9F\x07r\x02\x02\x9F\xA0\x07n\x02\x02\xA0" +
"\xA1\x07c\x02\x02\xA1\xA2\x07k\x02\x02\xA2\xA3\x07p\x02\x02\xA3\xA4\x03" +
"\x02\x02\x02\xA4\xA5\b\x03\x02\x02\xA5\b\x03\x02\x02\x02\xA6\xA7\x07h" +
"\x02\x02\xA7\xA8\x07t\x02\x02\xA8\xA9\x07q\x02\x02\xA9\xAA\x07o\x02\x02" +
"\xAA\xAB\x03\x02\x02\x02\xAB\xAC\b\x04\x03\x02\xAC\n\x03\x02\x02\x02\xAD" +
"\xAE\x07t\x02\x02\xAE\xAF\x07q\x02\x02\xAF\xB0\x07y\x02\x02\xB0\xB1\x03" +
"\x02\x02\x02\xB1\xB2\b\x05\x02\x02\xB2\f\x03\x02\x02\x02\xB3\xB4\x07u" +
"\x02\x02\xB4\xB5\x07v\x02\x02\xB5\xB6\x07c\x02\x02\xB6\xB7\x07v\x02\x02" +
"\xB7\xB8\x07u\x02\x02\xB8\xB9\x03\x02\x02\x02\xB9\xBA\b\x06\x02\x02\xBA" +
"\x0E\x03\x02\x02\x02\xBB\xBC\x07y\x02\x02\xBC\xBD\x07j\x02\x02\xBD\xBE" +
"\x07g\x02\x02\xBE\xBF\x07t\x02\x02\xBF\xC0\x07g\x02\x02\xC0\xC1\x03\x02" +
"\x02\x02\xC1\xC2\b\x07\x02\x02\xC2\x10\x03\x02\x02\x02\xC3\xC4\x07u\x02" +
"\x02\xC4\xC5\x07q\x02\x02\xC5\xC6\x07t\x02\x02\xC6\xC7\x07v\x02\x02\xC7" +
"\xC8\x03\x02\x02\x02\xC8\xC9\b\b\x02\x02\xC9\x12\x03\x02\x02\x02\xCA\xCB" +
"\x07n\x02\x02\xCB\xCC\x07k\x02\x02\xCC\xCD\x07o\x02\x02\xCD\xCE\x07k\x02" +
"\x02\xCE\xCF\x07v\x02\x02\xCF\xD0\x03\x02\x02\x02\xD0\xD1\b\t\x02\x02" +
"\xD1\x14\x03\x02\x02\x02\xD2\xD3\x07r\x02\x02\xD3\xD4\x07t\x02\x02\xD4" +
"\xD5\x07q\x02\x02\xD5\xD6\x07l\x02\x02\xD6\xD7\x07g\x02\x02\xD7\xD8\x07" +
"e\x02\x02\xD8\xD9\x07v\x02\x02\xD9\xDA\x03\x02\x02\x02\xDA\xDB\b\n\x03" +
"\x02\xDB\x16\x03\x02\x02\x02\xDC\xDD\x071\x02\x02\xDD\xDE\x071\x02\x02" +
"\xDE\xE2\x03\x02\x02\x02\xDF\xE1\n\x02\x02\x02\xE0\xDF\x03\x02\x02\x02" +
"\xE1\xE4\x03\x02\x02\x02\xE2\xE0\x03\x02\x02\x02\xE2\xE3\x03\x02\x02\x02" +
"\xE3\xE6\x03\x02\x02\x02\xE4\xE2\x03\x02\x02\x02\xE5\xE7\x07\x0F\x02\x02" +
"\xE6\xE5\x03\x02\x02\x02\xE6\xE7\x03\x02\x02\x02\xE7\xE9\x03\x02\x02\x02" +
"\xE8\xEA\x07\f\x02\x02\xE9\xE8\x03\x02\x02\x02\xE9\xEA\x03\x02\x02\x02" +
"\xEA\xEB\x03\x02\x02\x02\xEB\xEC\b\v\x04\x02\xEC\x18\x03\x02\x02\x02\xED" +
"\xEE\x071\x02\x02\xEE\xEF\x07,\x02\x02\xEF\xF4\x03\x02\x02\x02\xF0\xF3" +
"\x05\x19\f\x02\xF1\xF3\v\x02\x02\x02\xF2\xF0\x03\x02\x02\x02\xF2\xF1\x03" +
"\x02\x02\x02\xF3\xF6\x03\x02\x02\x02\xF4\xF5\x03\x02\x02\x02\xF4\xF2\x03" +
"\x02\x02\x02\xF5\xF7\x03\x02\x02\x02\xF6\xF4\x03\x02\x02\x02\xF7\xF8\x07" +
",\x02\x02\xF8\xF9\x071\x02\x02\xF9\xFA\x03\x02\x02\x02\xFA\xFB\b\f\x04" +
"\x02\xFB\x1A\x03\x02\x02\x02\xFC\xFE\t\x03\x02\x02\xFD\xFC\x03\x02\x02" +
"\x02\xFE\xFF\x03\x02\x02\x02\xFF\xFD\x03\x02\x02\x02\xFF\u0100\x03\x02" +
"\x02\x02\u0100\u0101\x03\x02\x02\x02\u0101\u0102\b\r\x04\x02\u0102\x1C" +
"\x03\x02\x02\x02\u0103\u0104\x07~\x02\x02\u0104\u0105\x03\x02\x02\x02" +
"\u0105\u0106\b\x0E\x05\x02\u0106\x1E\x03\x02\x02\x02\u0107\u0108\t\x04" +
"\x02\x02\u0108 \x03\x02\x02\x02\u0109\u010A\t\x05\x02\x02\u010A\"\x03" +
"\x02\x02\x02\u010B\u010C\x07^\x02\x02\u010C\u010D\t\x06\x02\x02\u010D" +
"$\x03\x02\x02\x02\u010E\u010F\n\x07\x02\x02\u010F&\x03\x02\x02\x02\u0110" +
"\u0112\t\b\x02\x02\u0111\u0113\t\t\x02\x02\u0112\u0111\x03\x02\x02\x02" +
"\u0112\u0113\x03\x02\x02\x02\u0113\u0115\x03\x02\x02\x02\u0114\u0116\x05" +
"\x1F\x0F\x02\u0115\u0114\x03\x02\x02\x02\u0116\u0117\x03\x02\x02\x02\u0117" +
"\u0115\x03\x02\x02\x02\u0117\u0118\x03\x02\x02\x02\u0118(\x03\x02\x02" +
"\x02\u0119\u011E\x07$\x02\x02\u011A\u011D\x05#\x11\x02\u011B\u011D\x05" +
"%\x12\x02\u011C\u011A\x03\x02\x02\x02\u011C\u011B\x03\x02\x02\x02\u011D" +
"\u0120\x03\x02\x02\x02\u011E\u011C\x03\x02\x02\x02\u011E\u011F\x03\x02" +
"\x02\x02\u011F\u0121\x03\x02\x02\x02\u0120\u011E\x03\x02\x02\x02\u0121" +
"\u0137\x07$\x02\x02\u0122\u0123\x07$\x02\x02\u0123\u0124\x07$\x02\x02" +
"\u0124\u0125\x07$\x02\x02\u0125\u0129\x03\x02\x02\x02\u0126\u0128\n\x02" +
"\x02\x02\u0127\u0126\x03\x02\x02\x02\u0128\u012B\x03\x02\x02\x02\u0129" +
"\u012A\x03\x02\x02\x02\u0129\u0127\x03\x02\x02\x02\u012A\u012C\x03\x02" +
"\x02\x02\u012B\u0129\x03\x02\x02\x02\u012C\u012D\x07$\x02\x02\u012D\u012E" +
"\x07$\x02\x02\u012E\u012F\x07$\x02\x02\u012F\u0131\x03\x02\x02\x02\u0130" +
"\u0132\x07$\x02\x02\u0131\u0130\x03\x02\x02\x02\u0131\u0132\x03\x02\x02" +
"\x02\u0132\u0134\x03\x02\x02\x02\u0133\u0135\x07$\x02\x02\u0134\u0133" +
"\x03\x02\x02\x02\u0134\u0135\x03\x02\x02\x02\u0135\u0137\x03\x02\x02\x02" +
"\u0136\u0119\x03\x02\x02\x02\u0136\u0122\x03\x02\x02\x02\u0137*\x03\x02" +
"\x02\x02\u0138\u013A\x05\x1F\x0F\x02\u0139\u0138\x03\x02\x02\x02\u013A" +
"\u013B\x03\x02\x02\x02\u013B\u0139\x03\x02\x02\x02\u013B\u013C\x03\x02" +
"\x02\x02\u013C,\x03\x02\x02\x02\u013D\u013F\x05\x1F\x0F\x02\u013E\u013D" +
"\x03\x02\x02\x02\u013F\u0140\x03\x02\x02\x02\u0140\u013E\x03\x02\x02\x02" +
"\u0140\u0141\x03\x02\x02\x02\u0141\u0142\x03\x02\x02\x02\u0142\u0146\x05" +
";\x1D\x02\u0143\u0145\x05\x1F\x0F\x02\u0144\u0143\x03\x02\x02\x02\u0145" +
"\u0148\x03\x02\x02\x02\u0146\u0144\x03\x02\x02\x02\u0146\u0147\x03\x02" +
"\x02\x02\u0147\u0168\x03\x02\x02\x02\u0148\u0146\x03\x02\x02\x02\u0149" +
"\u014B\x05;\x1D\x02\u014A\u014C\x05\x1F\x0F\x02\u014B\u014A\x03\x02\x02" +
"\x02\u014C\u014D\x03\x02\x02\x02\u014D\u014B\x03\x02\x02\x02\u014D\u014E" +
"\x03\x02\x02\x02\u014E\u0168\x03\x02\x02\x02\u014F\u0151\x05\x1F\x0F\x02" +
"\u0150\u014F\x03\x02\x02\x02\u0151\u0152\x03\x02\x02\x02\u0152\u0150\x03" +
"\x02\x02\x02\u0152\u0153\x03\x02\x02\x02\u0153\u015B\x03\x02\x02\x02\u0154" +
"\u0158\x05;\x1D\x02\u0155\u0157\x05\x1F\x0F\x02\u0156\u0155\x03\x02\x02" +
"\x02\u0157\u015A\x03\x02\x02\x02\u0158\u0156\x03\x02\x02\x02\u0158\u0159" +
"\x03\x02\x02\x02\u0159\u015C\x03\x02\x02\x02\u015A\u0158\x03\x02\x02\x02" +
"\u015B\u0154\x03\x02\x02\x02\u015B\u015C\x03\x02\x02\x02\u015C\u015D\x03" +
"\x02\x02\x02\u015D\u015E\x05\'\x13\x02\u015E\u0168\x03\x02\x02\x02\u015F" +
"\u0161\x05;\x1D\x02\u0160\u0162\x05\x1F\x0F\x02\u0161\u0160\x03\x02\x02" +
"\x02\u0162\u0163\x03\x02\x02\x02\u0163\u0161\x03\x02\x02\x02\u0163\u0164" +
"\x03\x02\x02\x02\u0164\u0165\x03\x02\x02\x02\u0165\u0166\x05\'\x13\x02" +
"\u0166\u0168\x03\x02\x02\x02\u0167\u013E\x03\x02\x02\x02\u0167\u0149\x03" +
"\x02\x02\x02\u0167\u0150\x03\x02\x02\x02\u0167\u015F\x03\x02\x02\x02\u0168" +
".\x03\x02\x02\x02\u0169\u016A\x07d\x02\x02\u016A\u016B\x07{\x02\x02\u016B" +
"0\x03\x02\x02\x02\u016C\u016D\x07c\x02\x02\u016D\u016E\x07p\x02\x02\u016E" +
"\u016F\x07f\x02\x02\u016F2\x03\x02\x02\x02\u0170\u0171\x07c\x02\x02\u0171" +
"\u0172\x07u\x02\x02\u0172\u0173\x07e\x02\x02\u01734\x03\x02\x02\x02\u0174" +
"\u0175\x07?\x02\x02\u01756\x03\x02\x02\x02\u0176\u0177\x07.\x02\x02\u0177" +
"8\x03\x02\x02\x02\u0178\u0179\x07f\x02\x02\u0179\u017A\x07g\x02\x02\u017A" +
"\u017B\x07u\x02\x02\u017B\u017C\x07e\x02\x02\u017C:\x03\x02\x02\x02\u017D" +
"\u017E\x070\x02\x02\u017E<\x03\x02\x02\x02\u017F\u0180\x07h\x02\x02\u0180" +
"\u0181\x07c\x02\x02\u0181\u0182\x07n\x02\x02\u0182\u0183\x07u\x02\x02" +
"\u0183\u0184\x07g\x02\x02\u0184>\x03\x02\x02\x02\u0185\u0186\x07h\x02" +
"\x02\u0186\u0187\x07k\x02\x02\u0187\u0188\x07t\x02\x02\u0188\u0189\x07" +
"u\x02\x02\u0189\u018A\x07v\x02\x02\u018A@\x03\x02\x02\x02\u018B\u018C" +
"\x07n\x02\x02\u018C\u018D\x07c\x02\x02\u018D\u018E\x07u\x02\x02\u018E" +
"\u018F\x07v\x02\x02\u018FB\x03\x02\x02\x02\u0190\u0191\x07*\x02\x02\u0191" +
"D\x03\x02\x02\x02\u0192\u0193\x07]\x02\x02\u0193\u0194\x03\x02\x02\x02" +
"\u0194\u0195\b\"\x06\x02\u0195F\x03\x02\x02\x02\u0196\u0197\x07_\x02\x02" +
"\u0197\u0198\x03\x02\x02\x02\u0198\u0199\b#\x05\x02\u0199\u019A\b#\x05" +
"\x02\u019AH\x03\x02\x02\x02\u019B\u019C\x07p\x02\x02\u019C\u019D\x07q" +
"\x02\x02\u019D\u019E\x07v\x02\x02\u019EJ\x03\x02\x02\x02\u019F\u01A0\x07" +
"p\x02\x02\u01A0\u01A1\x07w\x02\x02\u01A1\u01A2\x07n\x02\x02\u01A2\u01A3" +
"\x07n\x02\x02\u01A3L\x03\x02\x02\x02\u01A4\u01A5\x07p\x02\x02\u01A5\u01A6" +
"\x07w\x02\x02\u01A6\u01A7\x07n\x02\x02\u01A7\u01A8\x07n\x02\x02\u01A8" +
"\u01A9\x07u\x02\x02\u01A9N\x03\x02\x02\x02\u01AA\u01AB\x07q\x02\x02\u01AB" +
"\u01AC\x07t\x02\x02\u01ACP\x03\x02\x02\x02\u01AD\u01AE\x07+\x02\x02\u01AE" +
"R\x03\x02\x02\x02\u01AF\u01B0\x07v\x02\x02\u01B0\u01B1\x07t\x02\x02\u01B1" +
"\u01B2\x07w\x02\x02\u01B2\u01B3\x07g\x02\x02\u01B3T\x03\x02\x02\x02\u01B4" +
"\u01B5\x07?\x02\x02\u01B5\u01B6\x07?\x02\x02\u01B6V\x03\x02\x02\x02\u01B7" +
"\u01B8\x07#\x02\x02\u01B8\u01B9\x07?\x02\x02\u01B9X\x03\x02\x02\x02\u01BA" +
"\u01BB\x07>\x02\x02\u01BBZ\x03\x02\x02\x02\u01BC\u01BD\x07>\x02\x02\u01BD" +
"\u01BE\x07?\x02\x02\u01BE\\\x03\x02\x02\x02\u01BF\u01C0\x07@\x02\x02\u01C0" +
"^\x03\x02\x02\x02\u01C1\u01C2\x07@\x02\x02\u01C2\u01C3\x07?\x02\x02\u01C3" +
"`\x03\x02\x02\x02\u01C4\u01C5\x07-\x02\x02\u01C5b\x03\x02\x02\x02\u01C6" +
"\u01C7\x07/\x02\x02\u01C7d\x03\x02\x02\x02\u01C8\u01C9\x07,\x02\x02\u01C9" +
"f\x03\x02\x02\x02\u01CA\u01CB\x071\x02\x02\u01CBh\x03\x02\x02\x02\u01CC" +
"\u01CD\x07\'\x02\x02\u01CDj\x03\x02\x02\x02\u01CE\u01CF\x07t\x02\x02\u01CF" +
"\u01D0\x07q\x02\x02\u01D0\u01D1\x07w\x02\x02\u01D1\u01D2\x07p\x02\x02" +
"\u01D2\u01D3\x07f\x02\x02\u01D3l\x03\x02\x02\x02\u01D4\u01D5\x07c\x02" +
"\x02\u01D5\u01D6\x07x\x02\x02\u01D6\u01D7\x07i\x02\x02\u01D7n\x03\x02" +
"\x02\x02\u01D8\u01D9\x07u\x02\x02\u01D9\u01DA\x07w\x02\x02\u01DA\u01DB" +
"\x07o\x02\x02\u01DBp\x03\x02\x02\x02\u01DC\u01DD\x07o\x02\x02\u01DD\u01DE" +
"\x07k\x02\x02\u01DE\u01DF\x07p\x02\x02\u01DFr\x03\x02\x02\x02\u01E0\u01E1" +
"\x07o\x02\x02\u01E1\u01E2\x07c\x02\x02\u01E2\u01E3\x07z\x02\x02\u01E3" +
"t\x03\x02\x02\x02\u01E4\u01E7\x05!\x10\x02\u01E5\u01E7\x07a\x02\x02\u01E6" +
"\u01E4\x03\x02\x02\x02\u01E6\u01E5\x03\x02\x02\x02\u01E7\u01ED\x03\x02" +
"\x02\x02\u01E8\u01EC\x05!\x10\x02\u01E9\u01EC\x05\x1F\x0F\x02\u01EA\u01EC" +
"\x07a\x02\x02\u01EB\u01E8\x03\x02\x02\x02\u01EB\u01E9\x03\x02\x02\x02" +
"\u01EB\u01EA\x03\x02\x02\x02\u01EC\u01EF\x03\x02\x02\x02\u01ED\u01EB\x03" +
"\x02\x02\x02\u01ED\u01EE\x03\x02\x02\x02\u01EEv\x03\x02\x02\x02\u01EF" +
"\u01ED\x03\x02\x02\x02\u01F0\u01F6\x07b\x02\x02\u01F1\u01F5\n\n\x02\x02" +
"\u01F2\u01F3\x07b\x02\x02\u01F3\u01F5\x07b\x02\x02\u01F4\u01F1\x03\x02" +
"\x02\x02\u01F4\u01F2\x03\x02\x02\x02\u01F5\u01F8\x03\x02\x02\x02\u01F6" +
"\u01F4\x03\x02\x02\x02\u01F6\u01F7\x03\x02\x02\x02\u01F7\u01F9\x03\x02" +
"\x02\x02\u01F8\u01F6\x03\x02\x02\x02\u01F9\u01FA\x07b\x02\x02\u01FAx\x03" +
"\x02\x02\x02\u01FB\u01FC\x05\x17\v\x02\u01FC\u01FD\x03\x02\x02\x02\u01FD" +
"\u01FE\b<\x04\x02\u01FEz\x03\x02\x02\x02\u01FF\u0200\x05\x19\f\x02\u0200" +
"\u0201\x03\x02\x02\x02\u0201\u0202\b=\x04\x02\u0202|\x03\x02\x02\x02\u0203" +
"\u0204\x05\x1B\r\x02\u0204\u0205\x03\x02\x02\x02\u0205\u0206\b>\x04\x02" +
"\u0206~\x03\x02\x02\x02\u0207\u0208\x07~\x02\x02\u0208\u0209\x03\x02\x02" +
"\x02\u0209\u020A\b?\x07\x02\u020A\u020B\b?\x05\x02\u020B\x80\x03\x02\x02" +
"\x02\u020C\u020D\x07_\x02\x02\u020D\u020E\x03\x02\x02\x02\u020E\u020F" +
"\b@\x05\x02\u020F\u0210\b@\x05\x02\u0210\u0211\b@\b\x02\u0211\x82\x03" +
"\x02\x02\x02\u0212\u0213\x07.\x02\x02\u0213\u0214\x03\x02\x02\x02\u0214" +
"\u0215\bA\t\x02\u0215\x84\x03\x02\x02\x02\u0216\u0217\x07?\x02\x02\u0217" +
"\u0218\x03\x02\x02\x02\u0218\u0219\bB\n\x02\u0219\x86\x03\x02\x02\x02" +
"\u021A\u021C\x05\x89D\x02\u021B\u021A\x03\x02\x02\x02\u021C\u021D\x03" +
"\x02\x02\x02\u021D\u021B\x03\x02\x02\x02\u021D\u021E\x03\x02\x02\x02\u021E" +
"\x88\x03\x02\x02\x02\u021F\u0221\n\v\x02\x02\u0220\u021F\x03\x02\x02\x02" +
"\u0221\u0222\x03\x02\x02\x02\u0222\u0220\x03\x02\x02\x02\u0222\u0223\x03" +
"\x02\x02\x02\u0223\u0227\x03\x02\x02\x02\u0224\u0225\x071\x02\x02\u0225" +
"\u0227\n\f\x02\x02\u0226\u0220\x03\x02\x02\x02\u0226\u0224\x03\x02\x02" +
"\x02\u0227\x8A\x03\x02\x02\x02\u0228\u0229\x05w;\x02\u0229\x8C\x03\x02" +
"\x02\x02\u022A\u022B\x05\x17\v";
private static readonly _serializedATNSegment1: string =
"\x02\u022B\u022C\x03\x02\x02\x02\u022C\u022D\bF\x04\x02\u022D\x8E\x03" +
"\x02\x02\x02\u022E\u022F\x05\x19\f\x02\u022F\u0230\x03\x02\x02\x02\u0230" +
"\u0231\bG\x04\x02\u0231\x90\x03\x02\x02\x02\u0232\u0233\x05\x1B\r\x02" +
"\u0233\u0234\x03\x02\x02\x02\u0234\u0235\bH\x04\x02\u0235\x92\x03\x02" +
"\x02\x02\u0236\u0238\n\r\x02\x02\u0237\u0236\x03\x02\x02\x02\u0238\u0239" +
"\x03\x02\x02\x02\u0239\u0237\x03\x02\x02\x02\u0239\u023A\x03\x02\x02\x02" +
"\u023A\u023B\x03\x02\x02\x02\u023B\u023C\bI\x02\x02\u023C\x94\x03\x02" +
"\x02\x02%\x02\x03\x04\xE2\xE6\xE9\xF2\xF4\xFF\u0112\u0117\u011C\u011E" +
"\u0129\u0131\u0134\u0136\u013B\u0140\u0146\u014D\u0152\u0158\u015B\u0163" +
"\u0167\u01E6\u01EB\u01ED\u01F4\u01F6\u021D\u0222\u0226\u0239\v\x07\x03" +
"\x02\x07\x04\x02\x02\x03\x02\x06\x02\x02\x07\x02\x02\t\x0F\x02\t\x1F\x02" +
"\t\x17\x02\t\x16\x02";
public static readonly _serializedATN: string = Utils.join(
[
esql_lexer._serializedATNSegment0,
esql_lexer._serializedATNSegment1,
],
"",
);
public static __ATN: ATN;
public static get _ATN(): ATN {
if (!esql_lexer.__ATN) {
esql_lexer.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(esql_lexer._serializedATN));
}
return esql_lexer.__ATN;
}
}

View file

@ -0,0 +1,177 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
parser grammar esql_parser;
options {tokenVocab=esql_lexer;}
singleStatement
: query EOF
;
query
: sourceCommand #singleCommandQuery
| query PIPE processingCommand #compositeQuery
;
sourceCommand
: explainCommand
| fromCommand
| rowCommand
;
processingCommand
: evalCommand
| limitCommand
| projectCommand
| sortCommand
| statsCommand
| whereCommand
;
whereCommand
: WHERE booleanExpression
;
booleanExpression
: NOT booleanExpression #logicalNot
| valueExpression #booleanDefault
| left=booleanExpression operator=AND right=booleanExpression #logicalBinary
| left=booleanExpression operator=OR right=booleanExpression #logicalBinary
;
valueExpression
: functionIdentifier LP (functionExpressionArgument (COMMA functionExpressionArgument)*)? RP #valueFunctionExpression
| operatorExpression #valueExpressionDefault
| left=operatorExpression comparisonOperator right=operatorExpression #comparison
;
operatorExpression
: primaryExpression #operatorExpressionDefault
| operator=(MINUS | PLUS) operatorExpression #arithmeticUnary
| left=operatorExpression operator=(ASTERISK | SLASH | PERCENT) right=operatorExpression #arithmeticBinary
| left=operatorExpression operator=(PLUS | MINUS) right=operatorExpression #arithmeticBinary
;
primaryExpression
: constant #constantDefault
| qualifiedName #dereference
| LP booleanExpression RP #parenthesizedExpression
| identifier LP (booleanExpression (COMMA booleanExpression)*)? RP #functionExpression
;
rowCommand
: ROW fields
;
fields
: field (COMMA field)*
;
field
: qualifiedName ASSIGN valueExpression
| booleanExpression
| qualifiedName ASSIGN booleanExpression
;
fromCommand
: FROM sourceIdentifier (COMMA sourceIdentifier)*
;
evalCommand
: EVAL fields
;
statsCommand
: STATS fields (BY qualifiedNames)?
;
sourceIdentifier
: SRC_UNQUOTED_IDENTIFIER
| SRC_QUOTED_IDENTIFIER
;
functionExpressionArgument
: qualifiedName
| string
;
qualifiedName
: identifier (DOT identifier)*
;
qualifiedNames
: qualifiedName (COMMA qualifiedName)*
;
identifier
: UNQUOTED_IDENTIFIER
| QUOTED_IDENTIFIER
;
functionIdentifier
: ROUND_FUNCTION_MATH
| AVG_FUNCTION_MATH
| SUM_FUNCTION_MATH
| MIN_FUNCTION_MATH
| MAX_FUNCTION_MATH
;
constant
: NULL #nullLiteral
| number #numericLiteral
| booleanValue #booleanLiteral
| string #stringLiteral
;
limitCommand
: LIMIT INTEGER_LITERAL
;
sortCommand
: SORT orderExpression (COMMA orderExpression)*
;
orderExpression
: booleanExpression ordering=(ASC | DESC)? (NULLS nullOrdering=(FIRST | LAST))?
;
projectCommand
: PROJECT projectClause (COMMA projectClause)*
;
projectClause
: sourceIdentifier
| newName=sourceIdentifier ASSIGN oldName=sourceIdentifier
;
booleanValue
: TRUE | FALSE
;
number
: DECIMAL_LITERAL #decimalLiteral
| INTEGER_LITERAL #integerLiteral
;
string
: STRING
;
comparisonOperator
: EQ | NEQ | LT | LTE | GT | GTE
;
explainCommand
: EXPLAIN subqueryExpression
;
subqueryExpression
: OPENING_BRACKET query CLOSING_BRACKET
;

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,104 @@
EVAL=1
EXPLAIN=2
FROM=3
ROW=4
STATS=5
WHERE=6
SORT=7
LIMIT=8
PROJECT=9
LINE_COMMENT=10
MULTILINE_COMMENT=11
WS=12
PIPE=13
STRING=14
INTEGER_LITERAL=15
DECIMAL_LITERAL=16
BY=17
AND=18
ASC=19
ASSIGN=20
COMMA=21
DESC=22
DOT=23
FALSE=24
FIRST=25
LAST=26
LP=27
OPENING_BRACKET=28
CLOSING_BRACKET=29
NOT=30
NULL=31
NULLS=32
OR=33
RP=34
TRUE=35
EQ=36
NEQ=37
LT=38
LTE=39
GT=40
GTE=41
PLUS=42
MINUS=43
ASTERISK=44
SLASH=45
PERCENT=46
ROUND_FUNCTION_MATH=47
AVG_FUNCTION_MATH=48
SUM_FUNCTION_MATH=49
MIN_FUNCTION_MATH=50
MAX_FUNCTION_MATH=51
UNQUOTED_IDENTIFIER=52
QUOTED_IDENTIFIER=53
EXPR_LINE_COMMENT=54
EXPR_MULTILINE_COMMENT=55
EXPR_WS=56
SRC_UNQUOTED_IDENTIFIER=57
SRC_QUOTED_IDENTIFIER=58
SRC_LINE_COMMENT=59
SRC_MULTILINE_COMMENT=60
SRC_WS=61
UNKNOWN_CMD=62
'eval'=1
'explain'=2
'from'=3
'row'=4
'stats'=5
'where'=6
'sort'=7
'limit'=8
'project'=9
'by'=17
'and'=18
'asc'=19
'desc'=22
'.'=23
'false'=24
'first'=25
'last'=26
'('=27
'['=28
']'=29
'not'=30
'null'=31
'nulls'=32
'or'=33
')'=34
'true'=35
'=='=36
'!='=37
'<'=38
'<='=39
'>'=40
'>='=41
'+'=42
'-'=43
'*'=44
'/'=45
'%'=46
'round'=47
'avg'=48
'sum'=49
'min'=50
'max'=51

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,704 @@
// @ts-nocheck
// Generated from src/esql/antlr/esql_parser.g4 by ANTLR 4.7.3-SNAPSHOT
import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener";
import { ValueFunctionExpressionContext } from "./esql_parser";
import { ValueExpressionDefaultContext } from "./esql_parser";
import { ComparisonContext } from "./esql_parser";
import { NullLiteralContext } from "./esql_parser";
import { NumericLiteralContext } from "./esql_parser";
import { BooleanLiteralContext } from "./esql_parser";
import { StringLiteralContext } from "./esql_parser";
import { DecimalLiteralContext } from "./esql_parser";
import { IntegerLiteralContext } from "./esql_parser";
import { ConstantDefaultContext } from "./esql_parser";
import { DereferenceContext } from "./esql_parser";
import { ParenthesizedExpressionContext } from "./esql_parser";
import { FunctionExpressionContext } from "./esql_parser";
import { SingleCommandQueryContext } from "./esql_parser";
import { CompositeQueryContext } from "./esql_parser";
import { LogicalNotContext } from "./esql_parser";
import { BooleanDefaultContext } from "./esql_parser";
import { LogicalBinaryContext } from "./esql_parser";
import { OperatorExpressionDefaultContext } from "./esql_parser";
import { ArithmeticUnaryContext } from "./esql_parser";
import { ArithmeticBinaryContext } from "./esql_parser";
import { SingleStatementContext } from "./esql_parser";
import { QueryContext } from "./esql_parser";
import { SourceCommandContext } from "./esql_parser";
import { ProcessingCommandContext } from "./esql_parser";
import { WhereCommandContext } from "./esql_parser";
import { BooleanExpressionContext } from "./esql_parser";
import { ValueExpressionContext } from "./esql_parser";
import { OperatorExpressionContext } from "./esql_parser";
import { PrimaryExpressionContext } from "./esql_parser";
import { RowCommandContext } from "./esql_parser";
import { FieldsContext } from "./esql_parser";
import { FieldContext } from "./esql_parser";
import { FromCommandContext } from "./esql_parser";
import { EvalCommandContext } from "./esql_parser";
import { StatsCommandContext } from "./esql_parser";
import { SourceIdentifierContext } from "./esql_parser";
import { FunctionExpressionArgumentContext } from "./esql_parser";
import { QualifiedNameContext } from "./esql_parser";
import { QualifiedNamesContext } from "./esql_parser";
import { IdentifierContext } from "./esql_parser";
import { FunctionIdentifierContext } from "./esql_parser";
import { ConstantContext } from "./esql_parser";
import { LimitCommandContext } from "./esql_parser";
import { SortCommandContext } from "./esql_parser";
import { OrderExpressionContext } from "./esql_parser";
import { ProjectCommandContext } from "./esql_parser";
import { ProjectClauseContext } from "./esql_parser";
import { BooleanValueContext } from "./esql_parser";
import { NumberContext } from "./esql_parser";
import { StringContext } from "./esql_parser";
import { ComparisonOperatorContext } from "./esql_parser";
import { ExplainCommandContext } from "./esql_parser";
import { SubqueryExpressionContext } from "./esql_parser";
/**
* This interface defines a complete listener for a parse tree produced by
* `esql_parser`.
*/
export interface esql_parserListener extends ParseTreeListener {
/**
* Enter a parse tree produced by the `valueFunctionExpression`
* labeled alternative in `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
enterValueFunctionExpression?: (ctx: ValueFunctionExpressionContext) => void;
/**
* Exit a parse tree produced by the `valueFunctionExpression`
* labeled alternative in `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
exitValueFunctionExpression?: (ctx: ValueFunctionExpressionContext) => void;
/**
* Enter a parse tree produced by the `valueExpressionDefault`
* labeled alternative in `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
enterValueExpressionDefault?: (ctx: ValueExpressionDefaultContext) => void;
/**
* Exit a parse tree produced by the `valueExpressionDefault`
* labeled alternative in `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
exitValueExpressionDefault?: (ctx: ValueExpressionDefaultContext) => void;
/**
* Enter a parse tree produced by the `comparison`
* labeled alternative in `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
enterComparison?: (ctx: ComparisonContext) => void;
/**
* Exit a parse tree produced by the `comparison`
* labeled alternative in `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
exitComparison?: (ctx: ComparisonContext) => void;
/**
* Enter a parse tree produced by the `nullLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
enterNullLiteral?: (ctx: NullLiteralContext) => void;
/**
* Exit a parse tree produced by the `nullLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
exitNullLiteral?: (ctx: NullLiteralContext) => void;
/**
* Enter a parse tree produced by the `numericLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
enterNumericLiteral?: (ctx: NumericLiteralContext) => void;
/**
* Exit a parse tree produced by the `numericLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
exitNumericLiteral?: (ctx: NumericLiteralContext) => void;
/**
* Enter a parse tree produced by the `booleanLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
enterBooleanLiteral?: (ctx: BooleanLiteralContext) => void;
/**
* Exit a parse tree produced by the `booleanLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
exitBooleanLiteral?: (ctx: BooleanLiteralContext) => void;
/**
* Enter a parse tree produced by the `stringLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
enterStringLiteral?: (ctx: StringLiteralContext) => void;
/**
* Exit a parse tree produced by the `stringLiteral`
* labeled alternative in `esql_parser.constant`.
* @param ctx the parse tree
*/
exitStringLiteral?: (ctx: StringLiteralContext) => void;
/**
* Enter a parse tree produced by the `decimalLiteral`
* labeled alternative in `esql_parser.number`.
* @param ctx the parse tree
*/
enterDecimalLiteral?: (ctx: DecimalLiteralContext) => void;
/**
* Exit a parse tree produced by the `decimalLiteral`
* labeled alternative in `esql_parser.number`.
* @param ctx the parse tree
*/
exitDecimalLiteral?: (ctx: DecimalLiteralContext) => void;
/**
* Enter a parse tree produced by the `integerLiteral`
* labeled alternative in `esql_parser.number`.
* @param ctx the parse tree
*/
enterIntegerLiteral?: (ctx: IntegerLiteralContext) => void;
/**
* Exit a parse tree produced by the `integerLiteral`
* labeled alternative in `esql_parser.number`.
* @param ctx the parse tree
*/
exitIntegerLiteral?: (ctx: IntegerLiteralContext) => void;
/**
* Enter a parse tree produced by the `constantDefault`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
enterConstantDefault?: (ctx: ConstantDefaultContext) => void;
/**
* Exit a parse tree produced by the `constantDefault`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
exitConstantDefault?: (ctx: ConstantDefaultContext) => void;
/**
* Enter a parse tree produced by the `dereference`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
enterDereference?: (ctx: DereferenceContext) => void;
/**
* Exit a parse tree produced by the `dereference`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
exitDereference?: (ctx: DereferenceContext) => void;
/**
* Enter a parse tree produced by the `parenthesizedExpression`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
enterParenthesizedExpression?: (ctx: ParenthesizedExpressionContext) => void;
/**
* Exit a parse tree produced by the `parenthesizedExpression`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
exitParenthesizedExpression?: (ctx: ParenthesizedExpressionContext) => void;
/**
* Enter a parse tree produced by the `functionExpression`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
enterFunctionExpression?: (ctx: FunctionExpressionContext) => void;
/**
* Exit a parse tree produced by the `functionExpression`
* labeled alternative in `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
exitFunctionExpression?: (ctx: FunctionExpressionContext) => void;
/**
* Enter a parse tree produced by the `singleCommandQuery`
* labeled alternative in `esql_parser.query`.
* @param ctx the parse tree
*/
enterSingleCommandQuery?: (ctx: SingleCommandQueryContext) => void;
/**
* Exit a parse tree produced by the `singleCommandQuery`
* labeled alternative in `esql_parser.query`.
* @param ctx the parse tree
*/
exitSingleCommandQuery?: (ctx: SingleCommandQueryContext) => void;
/**
* Enter a parse tree produced by the `compositeQuery`
* labeled alternative in `esql_parser.query`.
* @param ctx the parse tree
*/
enterCompositeQuery?: (ctx: CompositeQueryContext) => void;
/**
* Exit a parse tree produced by the `compositeQuery`
* labeled alternative in `esql_parser.query`.
* @param ctx the parse tree
*/
exitCompositeQuery?: (ctx: CompositeQueryContext) => void;
/**
* Enter a parse tree produced by the `logicalNot`
* labeled alternative in `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
enterLogicalNot?: (ctx: LogicalNotContext) => void;
/**
* Exit a parse tree produced by the `logicalNot`
* labeled alternative in `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
exitLogicalNot?: (ctx: LogicalNotContext) => void;
/**
* Enter a parse tree produced by the `booleanDefault`
* labeled alternative in `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
enterBooleanDefault?: (ctx: BooleanDefaultContext) => void;
/**
* Exit a parse tree produced by the `booleanDefault`
* labeled alternative in `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
exitBooleanDefault?: (ctx: BooleanDefaultContext) => void;
/**
* Enter a parse tree produced by the `logicalBinary`
* labeled alternative in `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
enterLogicalBinary?: (ctx: LogicalBinaryContext) => void;
/**
* Exit a parse tree produced by the `logicalBinary`
* labeled alternative in `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
exitLogicalBinary?: (ctx: LogicalBinaryContext) => void;
/**
* Enter a parse tree produced by the `operatorExpressionDefault`
* labeled alternative in `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
enterOperatorExpressionDefault?: (ctx: OperatorExpressionDefaultContext) => void;
/**
* Exit a parse tree produced by the `operatorExpressionDefault`
* labeled alternative in `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
exitOperatorExpressionDefault?: (ctx: OperatorExpressionDefaultContext) => void;
/**
* Enter a parse tree produced by the `arithmeticUnary`
* labeled alternative in `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
enterArithmeticUnary?: (ctx: ArithmeticUnaryContext) => void;
/**
* Exit a parse tree produced by the `arithmeticUnary`
* labeled alternative in `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
exitArithmeticUnary?: (ctx: ArithmeticUnaryContext) => void;
/**
* Enter a parse tree produced by the `arithmeticBinary`
* labeled alternative in `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
enterArithmeticBinary?: (ctx: ArithmeticBinaryContext) => void;
/**
* Exit a parse tree produced by the `arithmeticBinary`
* labeled alternative in `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
exitArithmeticBinary?: (ctx: ArithmeticBinaryContext) => void;
/**
* Enter a parse tree produced by `esql_parser.singleStatement`.
* @param ctx the parse tree
*/
enterSingleStatement?: (ctx: SingleStatementContext) => void;
/**
* Exit a parse tree produced by `esql_parser.singleStatement`.
* @param ctx the parse tree
*/
exitSingleStatement?: (ctx: SingleStatementContext) => void;
/**
* Enter a parse tree produced by `esql_parser.query`.
* @param ctx the parse tree
*/
enterQuery?: (ctx: QueryContext) => void;
/**
* Exit a parse tree produced by `esql_parser.query`.
* @param ctx the parse tree
*/
exitQuery?: (ctx: QueryContext) => void;
/**
* Enter a parse tree produced by `esql_parser.sourceCommand`.
* @param ctx the parse tree
*/
enterSourceCommand?: (ctx: SourceCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.sourceCommand`.
* @param ctx the parse tree
*/
exitSourceCommand?: (ctx: SourceCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.processingCommand`.
* @param ctx the parse tree
*/
enterProcessingCommand?: (ctx: ProcessingCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.processingCommand`.
* @param ctx the parse tree
*/
exitProcessingCommand?: (ctx: ProcessingCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.whereCommand`.
* @param ctx the parse tree
*/
enterWhereCommand?: (ctx: WhereCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.whereCommand`.
* @param ctx the parse tree
*/
exitWhereCommand?: (ctx: WhereCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
enterBooleanExpression?: (ctx: BooleanExpressionContext) => void;
/**
* Exit a parse tree produced by `esql_parser.booleanExpression`.
* @param ctx the parse tree
*/
exitBooleanExpression?: (ctx: BooleanExpressionContext) => void;
/**
* Enter a parse tree produced by `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
enterValueExpression?: (ctx: ValueExpressionContext) => void;
/**
* Exit a parse tree produced by `esql_parser.valueExpression`.
* @param ctx the parse tree
*/
exitValueExpression?: (ctx: ValueExpressionContext) => void;
/**
* Enter a parse tree produced by `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
enterOperatorExpression?: (ctx: OperatorExpressionContext) => void;
/**
* Exit a parse tree produced by `esql_parser.operatorExpression`.
* @param ctx the parse tree
*/
exitOperatorExpression?: (ctx: OperatorExpressionContext) => void;
/**
* Enter a parse tree produced by `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
enterPrimaryExpression?: (ctx: PrimaryExpressionContext) => void;
/**
* Exit a parse tree produced by `esql_parser.primaryExpression`.
* @param ctx the parse tree
*/
exitPrimaryExpression?: (ctx: PrimaryExpressionContext) => void;
/**
* Enter a parse tree produced by `esql_parser.rowCommand`.
* @param ctx the parse tree
*/
enterRowCommand?: (ctx: RowCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.rowCommand`.
* @param ctx the parse tree
*/
exitRowCommand?: (ctx: RowCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.fields`.
* @param ctx the parse tree
*/
enterFields?: (ctx: FieldsContext) => void;
/**
* Exit a parse tree produced by `esql_parser.fields`.
* @param ctx the parse tree
*/
exitFields?: (ctx: FieldsContext) => void;
/**
* Enter a parse tree produced by `esql_parser.field`.
* @param ctx the parse tree
*/
enterField?: (ctx: FieldContext) => void;
/**
* Exit a parse tree produced by `esql_parser.field`.
* @param ctx the parse tree
*/
exitField?: (ctx: FieldContext) => void;
/**
* Enter a parse tree produced by `esql_parser.fromCommand`.
* @param ctx the parse tree
*/
enterFromCommand?: (ctx: FromCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.fromCommand`.
* @param ctx the parse tree
*/
exitFromCommand?: (ctx: FromCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.evalCommand`.
* @param ctx the parse tree
*/
enterEvalCommand?: (ctx: EvalCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.evalCommand`.
* @param ctx the parse tree
*/
exitEvalCommand?: (ctx: EvalCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.statsCommand`.
* @param ctx the parse tree
*/
enterStatsCommand?: (ctx: StatsCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.statsCommand`.
* @param ctx the parse tree
*/
exitStatsCommand?: (ctx: StatsCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.sourceIdentifier`.
* @param ctx the parse tree
*/
enterSourceIdentifier?: (ctx: SourceIdentifierContext) => void;
/**
* Exit a parse tree produced by `esql_parser.sourceIdentifier`.
* @param ctx the parse tree
*/
exitSourceIdentifier?: (ctx: SourceIdentifierContext) => void;
/**
* Enter a parse tree produced by `esql_parser.functionExpressionArgument`.
* @param ctx the parse tree
*/
enterFunctionExpressionArgument?: (ctx: FunctionExpressionArgumentContext) => void;
/**
* Exit a parse tree produced by `esql_parser.functionExpressionArgument`.
* @param ctx the parse tree
*/
exitFunctionExpressionArgument?: (ctx: FunctionExpressionArgumentContext) => void;
/**
* Enter a parse tree produced by `esql_parser.qualifiedName`.
* @param ctx the parse tree
*/
enterQualifiedName?: (ctx: QualifiedNameContext) => void;
/**
* Exit a parse tree produced by `esql_parser.qualifiedName`.
* @param ctx the parse tree
*/
exitQualifiedName?: (ctx: QualifiedNameContext) => void;
/**
* Enter a parse tree produced by `esql_parser.qualifiedNames`.
* @param ctx the parse tree
*/
enterQualifiedNames?: (ctx: QualifiedNamesContext) => void;
/**
* Exit a parse tree produced by `esql_parser.qualifiedNames`.
* @param ctx the parse tree
*/
exitQualifiedNames?: (ctx: QualifiedNamesContext) => void;
/**
* Enter a parse tree produced by `esql_parser.identifier`.
* @param ctx the parse tree
*/
enterIdentifier?: (ctx: IdentifierContext) => void;
/**
* Exit a parse tree produced by `esql_parser.identifier`.
* @param ctx the parse tree
*/
exitIdentifier?: (ctx: IdentifierContext) => void;
/**
* Enter a parse tree produced by `esql_parser.functionIdentifier`.
* @param ctx the parse tree
*/
enterFunctionIdentifier?: (ctx: FunctionIdentifierContext) => void;
/**
* Exit a parse tree produced by `esql_parser.functionIdentifier`.
* @param ctx the parse tree
*/
exitFunctionIdentifier?: (ctx: FunctionIdentifierContext) => void;
/**
* Enter a parse tree produced by `esql_parser.constant`.
* @param ctx the parse tree
*/
enterConstant?: (ctx: ConstantContext) => void;
/**
* Exit a parse tree produced by `esql_parser.constant`.
* @param ctx the parse tree
*/
exitConstant?: (ctx: ConstantContext) => void;
/**
* Enter a parse tree produced by `esql_parser.limitCommand`.
* @param ctx the parse tree
*/
enterLimitCommand?: (ctx: LimitCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.limitCommand`.
* @param ctx the parse tree
*/
exitLimitCommand?: (ctx: LimitCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.sortCommand`.
* @param ctx the parse tree
*/
enterSortCommand?: (ctx: SortCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.sortCommand`.
* @param ctx the parse tree
*/
exitSortCommand?: (ctx: SortCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.orderExpression`.
* @param ctx the parse tree
*/
enterOrderExpression?: (ctx: OrderExpressionContext) => void;
/**
* Exit a parse tree produced by `esql_parser.orderExpression`.
* @param ctx the parse tree
*/
exitOrderExpression?: (ctx: OrderExpressionContext) => void;
/**
* Enter a parse tree produced by `esql_parser.projectCommand`.
* @param ctx the parse tree
*/
enterProjectCommand?: (ctx: ProjectCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.projectCommand`.
* @param ctx the parse tree
*/
exitProjectCommand?: (ctx: ProjectCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.projectClause`.
* @param ctx the parse tree
*/
enterProjectClause?: (ctx: ProjectClauseContext) => void;
/**
* Exit a parse tree produced by `esql_parser.projectClause`.
* @param ctx the parse tree
*/
exitProjectClause?: (ctx: ProjectClauseContext) => void;
/**
* Enter a parse tree produced by `esql_parser.booleanValue`.
* @param ctx the parse tree
*/
enterBooleanValue?: (ctx: BooleanValueContext) => void;
/**
* Exit a parse tree produced by `esql_parser.booleanValue`.
* @param ctx the parse tree
*/
exitBooleanValue?: (ctx: BooleanValueContext) => void;
/**
* Enter a parse tree produced by `esql_parser.number`.
* @param ctx the parse tree
*/
enterNumber?: (ctx: NumberContext) => void;
/**
* Exit a parse tree produced by `esql_parser.number`.
* @param ctx the parse tree
*/
exitNumber?: (ctx: NumberContext) => void;
/**
* Enter a parse tree produced by `esql_parser.string`.
* @param ctx the parse tree
*/
enterString?: (ctx: StringContext) => void;
/**
* Exit a parse tree produced by `esql_parser.string`.
* @param ctx the parse tree
*/
exitString?: (ctx: StringContext) => void;
/**
* Enter a parse tree produced by `esql_parser.comparisonOperator`.
* @param ctx the parse tree
*/
enterComparisonOperator?: (ctx: ComparisonOperatorContext) => void;
/**
* Exit a parse tree produced by `esql_parser.comparisonOperator`.
* @param ctx the parse tree
*/
exitComparisonOperator?: (ctx: ComparisonOperatorContext) => void;
/**
* Enter a parse tree produced by `esql_parser.explainCommand`.
* @param ctx the parse tree
*/
enterExplainCommand?: (ctx: ExplainCommandContext) => void;
/**
* Exit a parse tree produced by `esql_parser.explainCommand`.
* @param ctx the parse tree
*/
exitExplainCommand?: (ctx: ExplainCommandContext) => void;
/**
* Enter a parse tree produced by `esql_parser.subqueryExpression`.
* @param ctx the parse tree
*/
enterSubqueryExpression?: (ctx: SubqueryExpressionContext) => void;
/**
* Exit a parse tree produced by `esql_parser.subqueryExpression`.
* @param ctx the parse tree
*/
exitSubqueryExpression?: (ctx: SubqueryExpressionContext) => void;
}

View file

@ -6,8 +6,7 @@
* Side Public License, v 1.
*/
import { LangModuleType } from '../types';
import { ID } from './constants';
import { lexerRules } from './lexer_rules';
export { ESQL_LANG_ID, ESQL_THEME_ID } from './lib/constants';
export { ESQLLang } from './language';
export const EsqlLang: LangModuleType = { ID, lexerRules };
export { buildESQlTheme } from './lib/monaco/esql_theme';

View file

@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { monaco } from '../monaco_imports';
import { ESQL_LANG_ID } from './lib/constants';
import type { CustomLangModuleType } from '../types';
import type { ESQLWorker } from './worker/esql_worker';
import { DiagnosticsAdapter } from '../common/diagnostics_adapter';
import { WorkerProxyService } from '../common/worker_proxy';
export const ESQLLang: CustomLangModuleType = {
ID: ESQL_LANG_ID,
async onLanguage() {
const { ESQLTokensProvider } = await import('./lib/monaco');
const workerProxyService = new WorkerProxyService<ESQLWorker>();
workerProxyService.setup(ESQL_LANG_ID);
monaco.languages.setTokensProvider(ESQL_LANG_ID, new ESQLTokensProvider());
new DiagnosticsAdapter(ESQL_LANG_ID, (...uris) => workerProxyService.getWorker(uris));
},
};

View file

@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { CommonTokenStream, CodePointCharStream } from 'antlr4ts';
import { esql_lexer as ESQLLexer } from '../antlr/esql_lexer';
import { esql_parser as ESQLParser } from '../antlr/esql_parser';
import type { ANTLREErrorListener } from '../../common/error_listener';
export const getParser = (inputStream: CodePointCharStream, errorListener: ANTLREErrorListener) => {
const lexer = getLexer(inputStream, errorListener);
const tokenStream = new CommonTokenStream(lexer);
const parser = new ESQLParser(tokenStream);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return parser;
};
export const getLexer = (inputStream: CodePointCharStream, errorListener: ANTLREErrorListener) => {
const lexer = new ESQLLexer(inputStream);
lexer.removeErrorListeners();
lexer.addErrorListener(errorListener);
return lexer;
};

View file

@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export const ESQL_LANG_ID = 'esql';
export const ESQL_THEME_ID = 'esqlTheme';
export const ESQL_TOKEN_POSTFIX = '.esql';

View file

@ -0,0 +1,21 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { monaco } from '../../../monaco_imports';
import { ESQLState } from './esql_state';
/** @internal **/
export class ESQLLineTokens implements monaco.languages.ILineTokens {
endState: monaco.languages.IState;
tokens: monaco.languages.IToken[];
constructor(tokens: monaco.languages.IToken[]) {
this.endState = new ESQLState();
this.tokens = tokens;
}
}

View file

@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { monaco } from '../../../monaco_imports';
/** @internal **/
export class ESQLState implements monaco.languages.IState {
clone(): monaco.languages.IState {
return new ESQLState();
}
equals(other: monaco.languages.IState): boolean {
return false;
}
}

View file

@ -0,0 +1,145 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { euiThemeVars, darkMode } from '@kbn/ui-theme';
import { ESQL_TOKEN_POSTFIX } from '../constants';
import { monaco } from '../../../monaco_imports';
const buildRuleGroup = (tokens: string[], color: string, isBold: boolean = false) =>
tokens.map((i) => ({
token: i + ESQL_TOKEN_POSTFIX,
foreground: color,
fontStyle: isBold ? 'bold' : '',
}));
export const buildESQlTheme = (): monaco.editor.IStandaloneThemeData => ({
base: darkMode ? 'vs-dark' : 'vs',
inherit: true,
rules: [
// base
...buildRuleGroup(
[
'explain',
'row',
'limit',
'project',
'ws',
'assign',
'comma',
'dot',
'first',
'last',
'opening_bracket',
'closing_bracket',
'quoted_identifier',
'src_ws',
'unquoted_identifier',
],
euiThemeVars.euiTextColor
),
// commands
...buildRuleGroup(
[
'from',
'stats',
'eval',
'sort',
'by',
'where',
'unknown_cmd',
'expr_ws',
'row',
'limit',
'asc',
'desc',
],
euiThemeVars.euiColorPrimaryText
),
// math functions
...buildRuleGroup(
[
'round_function_math',
'avg_function_math',
'sum_function_math',
'min_function_math',
'max_function_math',
],
euiThemeVars.euiColorPrimaryText
),
// values
...buildRuleGroup(
[
'pipe',
'true',
'not',
'null',
'nulls',
'false',
'src_unquoted_identifier',
'src_quoted_identifier',
'string',
],
euiThemeVars.euiTextColor
),
// values #2
...buildRuleGroup(
[
'true',
'not',
'null',
'nulls',
'false',
'not',
'null',
'percent',
'integer_literal',
'decimal_literal',
],
euiThemeVars.euiTextColor
),
// operators
...buildRuleGroup(
[
'or',
'and',
'rp',
'eq',
'neq',
'lp',
'lt',
'lte',
'gt',
'gte',
'plus',
'minus',
'asterisk',
'slash',
],
euiThemeVars.euiTextSubduedColor
),
// comments
...buildRuleGroup(
[
'line_comment',
'multiline_comment',
'expr_line_comment',
'expr_multiline_comment',
'src_line_comment',
'src_multiline_comment',
],
euiThemeVars.euiColorMediumShade
),
],
colors: {},
});

View file

@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { monaco } from '../../../monaco_imports';
import { ESQL_TOKEN_POSTFIX } from '../constants';
/** @internal **/
export class ESQLToken implements monaco.languages.IToken {
scopes: string;
constructor(ruleName: string, public startIndex: number, public stopIndex?: number) {
this.scopes = ruleName.toLowerCase() + ESQL_TOKEN_POSTFIX;
}
}

View file

@ -0,0 +1,68 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { CharStreams, Token } from 'antlr4ts';
import { monaco } from '../../../monaco_imports';
import { ANTLREErrorListener } from '../../../common/error_listener';
import { ESQLToken } from './esql_token';
import { ESQLLineTokens } from './esql_line_tokens';
import { ESQLState } from './esql_state';
import { getLexer } from '../antlr_facade';
import { ESQL_TOKEN_POSTFIX } from '../constants';
const EOF = -1;
export class ESQLTokensProvider implements monaco.languages.TokensProvider {
getInitialState(): monaco.languages.IState {
return new ESQLState();
}
tokenize(line: string, state: monaco.languages.IState): monaco.languages.ILineTokens {
const errorStartingPoints: number[] = [];
const errorListener = new ANTLREErrorListener();
const inputStream = CharStreams.fromString(line);
const lexer = getLexer(inputStream, errorListener);
let done = false;
const myTokens: monaco.languages.IToken[] = [];
do {
let token: Token | null;
try {
token = lexer.nextToken();
} catch (e) {
token = null;
}
if (token == null) {
done = true;
} else {
if (token.type === EOF) {
done = true;
} else {
const tokenTypeName = lexer.vocabulary.getSymbolicName(token.type);
if (tokenTypeName) {
const myToken = new ESQLToken(tokenTypeName, token.startIndex, token.stopIndex);
myTokens.push(myToken);
}
}
}
} while (!done);
for (const e of errorStartingPoints) {
myTokens.push(new ESQLToken('error' + ESQL_TOKEN_POSTFIX, e));
}
myTokens.sort((a, b) => a.startIndex - b.startIndex);
return new ESQLLineTokens(myTokens);
}
}

View file

@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export { ESQLTokensProvider } from './esql_tokens_provider';

View file

@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
// This module is intended to be run inside of a webworker
/* eslint-disable @kbn/eslint/module_migration */
import '@babel/runtime/regenerator';
// @ts-ignore
import * as worker from 'monaco-editor/esm/vs/editor/editor.worker';
import { monaco } from '../../monaco_imports';
import { ESQLWorker } from './esql_worker';
self.onmessage = () => {
worker.initialize((ctx: monaco.worker.IWorkerContext, createData: any) => {
return new ESQLWorker(ctx);
});
};

View file

@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { CharStreams } from 'antlr4ts';
import { monaco } from '../../monaco_imports';
import type { BaseWorkerDefinition } from '../../types';
import { getParser } from '../lib/antlr_facade';
import { ANTLREErrorListener } from '../../common/error_listener';
export class ESQLWorker implements BaseWorkerDefinition {
private readonly _ctx: monaco.worker.IWorkerContext;
constructor(ctx: monaco.worker.IWorkerContext) {
this._ctx = ctx;
}
private getTextDocument(modelUri: string): string | undefined {
const model = this._ctx.getMirrorModels().find((m) => m.uri.toString() === modelUri);
return model?.getValue();
}
public async getSyntaxErrors(modelUri: string) {
const code = this.getTextDocument(modelUri);
if (code) {
const inputStream = CharStreams.fromString(code);
const errorListener = new ANTLREErrorListener();
const parser = getParser(inputStream, errorListener);
parser.singleStatement();
return errorListener.getErrors();
}
}
}

View file

@ -6,18 +6,32 @@
* Side Public License, v 1.
*/
import { monaco } from './monaco_imports';
import { LangModuleType } from './types';
import type { LangModuleType, CustomLangModuleType } from './types';
function registerLanguage(language: LangModuleType) {
export function registerLanguage(language: LangModuleType | CustomLangModuleType) {
const { ID, lexerRules, languageConfiguration } = language;
monaco.languages.register({ id: ID });
monaco.languages.onLanguage(ID, () => {
monaco.languages.setMonarchTokensProvider(ID, lexerRules);
monaco.languages.onLanguage(ID, async () => {
if (lexerRules) {
monaco.languages.setMonarchTokensProvider(ID, lexerRules);
}
if (languageConfiguration) {
monaco.languages.setLanguageConfiguration(ID, languageConfiguration);
}
if ('onLanguage' in language) {
await language.onLanguage();
}
});
}
export { registerLanguage };
export function registerTheme(id: string, themeData: monaco.editor.IStandaloneThemeData) {
try {
monaco.editor.defineTheme(id, themeData);
} catch (e) {
// nothing to be here
}
}

View file

@ -8,8 +8,8 @@
import { monaco } from '../monaco_imports';
import { EditorStateService } from './lib';
import { PainlessCompletionResult, PainlessCompletionKind } from './types';
import { PainlessWorker } from './worker';
import type { PainlessCompletionResult, PainlessCompletionKind } from './types';
import type { PainlessWorker } from './worker';
const getCompletionKind = (kind: PainlessCompletionKind): monaco.languages.CompletionItemKind => {
const monacoItemKind = monaco.languages.CompletionItemKind;

View file

@ -9,7 +9,7 @@
import { ID } from './constants';
import { lexerRules, languageConfiguration } from './lexer_rules';
import { getSuggestionProvider, getSyntaxErrors, validation$ } from './language';
import { CompleteLangModuleType } from '../types';
import type { CompleteLangModuleType } from '../types';
export const PainlessLang: CompleteLangModuleType = {
ID,

View file

@ -7,21 +7,20 @@
*/
import { Observable, of } from 'rxjs';
import { monaco } from '../monaco_imports';
import { WorkerProxyService, EditorStateService } from './lib';
import { LangValidation, SyntaxErrors } from '../types';
import { ID } from './constants';
import { PainlessContext, PainlessAutocompleteField } from './types';
import { PainlessWorker } from './worker';
import { PainlessCompletionAdapter } from './completion_adapter';
import { DiagnosticsAdapter } from './diagnostics_adapter';
const workerProxyService = new WorkerProxyService();
import type { LangValidation, SyntaxErrors } from '../types';
import type { PainlessContext, PainlessAutocompleteField } from './types';
import type { PainlessWorker } from './worker';
import { EditorStateService } from './lib';
import { PainlessCompletionAdapter } from './completion_adapter';
import { DiagnosticsAdapter } from '../common/diagnostics_adapter';
import { WorkerProxyService } from '../common/worker_proxy';
const workerProxyService = new WorkerProxyService<PainlessWorker>();
const editorStateService = new EditorStateService();
export type WorkerAccessor = (...uris: monaco.Uri[]) => Promise<PainlessWorker>;
const worker: WorkerAccessor = (...uris: monaco.Uri[]): Promise<PainlessWorker> => {
const worker = (...uris: monaco.Uri[]): Promise<PainlessWorker> => {
return workerProxyService.getWorker(uris);
};
@ -46,7 +45,7 @@ export const validation$: () => Observable<LangValidation> = () =>
of<LangValidation>({ isValid: true, isValidating: false, errors: [] });
monaco.languages.onLanguage(ID, async () => {
workerProxyService.setup();
workerProxyService.setup(ID);
diagnosticsAdapter = new DiagnosticsAdapter(worker);
diagnosticsAdapter = new DiagnosticsAdapter(ID, worker);
});

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { PainlessContext, PainlessAutocompleteField } from '../types';
import type { PainlessContext, PainlessAutocompleteField } from '../types';
export interface EditorState {
context: PainlessContext;

View file

@ -6,6 +6,5 @@
* Side Public License, v 1.
*/
export type { EditorState } from './editor_state';
export { EditorStateService } from './editor_state';
export { WorkerProxyService } from './worker_proxy';
export type { EditorState } from './editor_state';

View file

@ -7,5 +7,3 @@
*/
export { PainlessWorker } from './painless_worker';
export type { PainlessError } from './lib';

View file

@ -7,7 +7,4 @@
*/
export { getAutocompleteSuggestions } from './autocomplete';
export type { PainlessError } from './error_listener';
export { parseAndGetSyntaxErrors } from './parser';

View file

@ -8,18 +8,19 @@
import { CommonTokenStream, CharStreams } from 'antlr4ts';
import { painless_parser as PainlessParser, SourceContext } from '../../antlr/painless_parser';
import { PainlessError, PainlessErrorListener } from './error_listener';
import { PainlessLexerEnhanced } from './lexer';
import { EditorError } from '../../../types';
import { ANTLREErrorListener } from '../../../common/error_listener';
const parse = (
code: string
): {
source: SourceContext;
errors: PainlessError[];
errors: EditorError[];
} => {
const inputStream = CharStreams.fromString(code);
const lexer = new PainlessLexerEnhanced(inputStream);
const painlessLangErrorListener = new PainlessErrorListener();
const painlessLangErrorListener = new ANTLREErrorListener();
const tokenStream = new CommonTokenStream(lexer);
const parser = new PainlessParser(tokenStream);
@ -29,7 +30,7 @@ const parse = (
lexer.addErrorListener(painlessLangErrorListener);
parser.addErrorListener(painlessLangErrorListener);
const errors: PainlessError[] = painlessLangErrorListener.getErrors();
const errors: EditorError[] = painlessLangErrorListener.getErrors();
return {
source: parser.source(),
@ -37,7 +38,7 @@ const parse = (
};
};
export const parseAndGetSyntaxErrors = (code: string): PainlessError[] => {
export const parseAndGetSyntaxErrors = (code: string): EditorError[] => {
const { errors } = parse(code);
return errors;
};

View file

@ -7,10 +7,16 @@
*/
import { monaco } from '../../monaco_imports';
import { PainlessCompletionResult, PainlessContext, PainlessAutocompleteField } from '../types';
import type {
PainlessCompletionResult,
PainlessContext,
PainlessAutocompleteField,
} from '../types';
import type { BaseWorkerDefinition } from '../../types';
import { getAutocompleteSuggestions, parseAndGetSyntaxErrors } from './lib';
export class PainlessWorker {
export class PainlessWorker implements BaseWorkerDefinition {
private _ctx: monaco.worker.IWorkerContext;
constructor(ctx: monaco.worker.IWorkerContext) {

View file

@ -8,39 +8,58 @@
import { XJsonLang } from './xjson';
import { PainlessLang } from './painless';
import { EsqlLang } from './esql';
import { SQLLang } from './sql';
import { monaco } from './monaco_imports';
import { registerLanguage } from './helpers';
import { ESQL_THEME_ID, ESQLLang, buildESQlTheme } from './esql';
import jsonWorkerSrc from '!!raw-loader!../../target_workers/json.editor.worker.js';
import xJsonWorkerSrc from '!!raw-loader!../../target_workers/xjson.editor.worker.js';
import defaultWorkerSrc from '!!raw-loader!../../target_workers/default.editor.worker.js';
import painlessWorkerSrc from '!!raw-loader!../../target_workers/painless.editor.worker.js';
import { registerLanguage, registerTheme } from './helpers';
import { createWorkersRegistry } from './workers_registry';
export const DEFAULT_WORKER_ID = 'default';
const workerRegistry = createWorkersRegistry(DEFAULT_WORKER_ID);
workerRegistry.register(
DEFAULT_WORKER_ID,
async () => await import('!!raw-loader!../../target_workers/default.editor.worker.js')
);
workerRegistry.register(
XJsonLang.ID,
async () => await import('!!raw-loader!../../target_workers/xjson.editor.worker.js')
);
workerRegistry.register(
PainlessLang.ID,
async () => await import('!!raw-loader!../../target_workers/painless.editor.worker.js')
);
workerRegistry.register(
ESQLLang.ID,
async () => await import('!!raw-loader!../../target_workers/esql.editor.worker.js')
);
workerRegistry.register(
monaco.languages.json.jsonDefaults.languageId,
async () => await import('!!raw-loader!../../target_workers/json.editor.worker.js')
);
/**
* Register languages and lexer rules
*/
registerLanguage(XJsonLang);
registerLanguage(PainlessLang);
registerLanguage(EsqlLang);
registerLanguage(SQLLang);
registerLanguage(ESQLLang);
/**
* Create web workers by language ID
* Register custom themes
*/
const mapLanguageIdToWorker: { [key: string]: any } = {
[XJsonLang.ID]: xJsonWorkerSrc,
[PainlessLang.ID]: painlessWorkerSrc,
[monaco.languages.json.jsonDefaults.languageId]: jsonWorkerSrc,
};
registerTheme(ESQL_THEME_ID, buildESQlTheme());
// @ts-ignore
window.MonacoEnvironment = {
// needed for functional tests so that we can get value from 'editor'
monaco,
getWorker: (module: string, languageId: string) => {
const workerSrc = mapLanguageIdToWorker[languageId] || defaultWorkerSrc;
const blob = new Blob([workerSrc], { type: 'application/javascript' });
return new Worker(URL.createObjectURL(blob));
},
getWorker: workerRegistry.getWorker,
};

View file

@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
export const ID = 'esql';
export const ID = 'sql';

View file

@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { LangModuleType } from '../types';
import { ID } from './constants';
import { lexerRules } from './lexer_rules';
export const SQLLang: LangModuleType = { ID, lexerRules };

View file

@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
export { lexerRules } from './esql';
export { lexerRules } from './sql';

View file

@ -5,16 +5,15 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { Observable } from 'rxjs';
import { monaco } from './monaco_imports';
export interface LangModuleType {
ID: string;
lexerRules: monaco.languages.IMonarchLanguage;
lexerRules?: monaco.languages.IMonarchLanguage;
languageConfiguration?: monaco.languages.LanguageConfiguration;
getSuggestionProvider?: Function;
getSyntaxErrors?: Function;
}
export interface CompleteLangModuleType extends LangModuleType {
@ -24,6 +23,10 @@ export interface CompleteLangModuleType extends LangModuleType {
validation$: () => Observable<LangValidation>;
}
export interface CustomLangModuleType extends LangModuleType {
onLanguage: () => void;
}
export interface EditorError {
startLineNumber: number;
startColumn: number;
@ -41,3 +44,7 @@ export interface LangValidation {
export interface SyntaxErrors {
[modelId: string]: EditorError[];
}
export interface BaseWorkerDefinition {
getSyntaxErrors: (modelUri: string) => Promise<EditorError[] | undefined>;
}

View file

@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export const createWorkersRegistry = (defaultWorkerId: string) => {
const registry = new Map<string, () => Promise<any>>();
return {
register: (languageId: string, getWorkerSrc: () => Promise<any>) => {
registry.set(languageId, getWorkerSrc);
},
getWorker: async (module: string, languageId: string) => {
const getWorkerSrc = registry.get(languageId) || registry.get(defaultWorkerId);
if (getWorkerSrc) {
const src = await getWorkerSrc();
const blob = new Blob([src.default], { type: 'application/javascript' });
return new Worker(URL.createObjectURL(blob));
} else {
throw new Error(`Worker for ${languageId} is not registered`);
}
},
};
};
export type WorkersRegistry = ReturnType<typeof createWorkersRegistry>;

View file

@ -47,4 +47,4 @@ const getWorkerConfig = (language) => ({
},
});
module.exports = ['default', 'json', 'painless', 'xjson'].map(getWorkerConfig);
module.exports = ['default', 'json', 'painless', 'xjson', 'esql'].map(getWorkerConfig);

View file

@ -443,7 +443,7 @@ export const CodeEditor: React.FC<Props> = ({
</div>
) : null}
<MonacoEditor
theme={transparentBackground ? 'euiColorsTransparent' : 'euiColors'}
theme={options?.theme ?? (transparentBackground ? 'euiColorsTransparent' : 'euiColors')}
language={languageId}
value={value}
onChange={onChange}

View file

@ -8,7 +8,7 @@
import React, { useRef, memo, useEffect, useState, useCallback } from 'react';
import classNames from 'classnames';
import { EsqlLang, monaco } from '@kbn/monaco';
import { SQLLang, monaco } from '@kbn/monaco';
import type { AggregateQuery } from '@kbn/es-query';
import { getAggregateQueryMode } from '@kbn/es-query';
import {
@ -72,7 +72,7 @@ const languageId = (language: string) => {
switch (language) {
case 'sql':
default: {
return EsqlLang.ID;
return SQLLang.ID;
}
}
};

View file

@ -7,7 +7,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { EsqlLang } from '@kbn/monaco';
import { SQLLang } from '@kbn/monaco';
import { EuiFormRow, EuiLink, EuiText } from '@elastic/eui';
import { CodeEditorField } from '@kbn/kibana-react-plugin/public';
import { getSimpleArg, setSimpleArg } from '../../../public/lib/arg_helpers';
@ -78,7 +78,7 @@ class EssqlDatasource extends PureComponent {
}
>
<CodeEditorField
languageId={EsqlLang.ID}
languageId={SQLLang.ID}
value={this.getQuery()}
onChange={this.onChange}
className="canvasTextArea__code"