diff --git a/src/plugins/data/public/antlr/dql/code_completion.ts b/src/plugins/data/public/antlr/dql/code_completion.ts new file mode 100644 index 000000000000..c9ee422d9643 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/code_completion.ts @@ -0,0 +1,82 @@ +import { CharStream, CommonTokenStream } from 'antlr4ng'; +import { DQLLexer } from './generated/DQLLexer'; +import { DQLParser, FieldContext } from './generated/DQLParser'; +import { DQLParserVisitor } from './generated/DQLParserVisitor'; +import { CodeCompletionCore } from 'antlr4-c3'; +import { findCursorTokenIndex } from '../opensearch_sql/cursor'; +import { QuerySuggestion, QuerySuggestionField } from '../../autocomplete'; + +const findFieldSuggestions = (indexPatterns) => { + const fieldNames: string[] = indexPatterns[0].fields + .filter((idxField: { readFromDocValues: boolean }) => idxField.readFromDocValues) + .map((idxField: { displayName: string }) => { + return idxField.displayName; + }); + + const fieldSuggestions: { text: string; type: string }[] = fieldNames.map((field: string) => { + return { text: field, type: 'text' }; + }); + + return fieldSuggestions; +}; + +export const getSuggestions = async ({ + selectionStart, + selectionEnd, + query, + language, + indexPatterns, +}) => { + const inputStream = CharStream.fromString(query); + const lexer = new DQLLexer(inputStream); + const tokenStream = new CommonTokenStream(lexer); + const parser = new DQLParser(tokenStream); + const tree = parser.query(); + + // find token index + const cursorIndex = + findCursorTokenIndex(tokenStream, { line: 1, column: selectionStart }, DQLParser.WS) ?? 0; + + const core = new CodeCompletionCore(parser); + + // specify preferred rules to appear in candidate collection + core.preferredRules = new Set([DQLParser.RULE_field]); + + // specify tokens to ignore + core.ignoredTokens = new Set([ + DQLParser.EOF, + DQLParser.LPAREN, + DQLParser.RPAREN, + DQLParser.DOT, + DQLParser.EQ, + DQLParser.GE, + DQLParser.GT, + DQLParser.LE, + DQLParser.LT, + DQLParser.NUMBER, + DQLParser.PHRASE, + ]); + + // gets candidates at specified token index + const candidates = core.collectCandidates(cursorIndex); + + let completions = []; + + // check to see if field rule is a candidate. if so, suggest field names + if (candidates.rules.has(DQLParser.RULE_field)) { + completions.push(...findFieldSuggestions(indexPatterns)); + } + + // suggest other candidates, mainly keywords + [...candidates.tokens.keys()].forEach((token: number) => { + // ignore identifier, already handled with field rule + if (token === DQLParser.IDENTIFIER) { + return; + } + + const tokenSymbolName = parser.vocabulary.getSymbolicName(token)?.toLowerCase(); + completions.push({ text: tokenSymbolName, type: 'function' }); + }); + + return completions; +}; diff --git a/src/plugins/data/public/antlr/dql/generated/DQLLexer.interp b/src/plugins/data/public/antlr/dql/generated/DQLLexer.interp new file mode 100644 index 000000000000..370011ad4a31 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLLexer.interp @@ -0,0 +1,62 @@ +token literal names: +null +null +null +null +'>' +'<' +'>=' +'<=' +':' +'(' +')' +'.' +null +null +null +null + +token symbolic names: +null +OR +AND +NOT +GT +LT +GE +LE +EQ +LPAREN +RPAREN +DOT +PHRASE +NUMBER +IDENTIFIER +WS + +rule names: +OR +AND +NOT +GT +LT +GE +LE +EQ +LPAREN +RPAREN +DOT +PHRASE +NUMBER +IDENTIFIER +WS + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 15, 99, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 5, 11, 63, 8, 11, 10, 11, 12, 11, 66, 9, 11, 1, 11, 1, 11, 1, 12, 3, 12, 71, 8, 12, 1, 12, 4, 12, 74, 8, 12, 11, 12, 12, 12, 75, 1, 12, 1, 12, 4, 12, 80, 8, 12, 11, 12, 12, 12, 81, 3, 12, 84, 8, 12, 1, 13, 1, 13, 5, 13, 88, 8, 13, 10, 13, 12, 13, 91, 9, 13, 1, 14, 4, 14, 94, 8, 14, 11, 14, 12, 14, 95, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 1, 0, 11, 2, 0, 79, 79, 111, 111, 2, 0, 82, 82, 114, 114, 2, 0, 65, 65, 97, 97, 2, 0, 78, 78, 110, 110, 2, 0, 68, 68, 100, 100, 2, 0, 84, 84, 116, 116, 2, 0, 34, 34, 92, 92, 1, 0, 48, 57, 4, 0, 42, 42, 65, 90, 95, 95, 97, 122, 5, 0, 42, 42, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 105, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 1, 31, 1, 0, 0, 0, 3, 34, 1, 0, 0, 0, 5, 38, 1, 0, 0, 0, 7, 42, 1, 0, 0, 0, 9, 44, 1, 0, 0, 0, 11, 46, 1, 0, 0, 0, 13, 49, 1, 0, 0, 0, 15, 52, 1, 0, 0, 0, 17, 54, 1, 0, 0, 0, 19, 56, 1, 0, 0, 0, 21, 58, 1, 0, 0, 0, 23, 60, 1, 0, 0, 0, 25, 70, 1, 0, 0, 0, 27, 85, 1, 0, 0, 0, 29, 93, 1, 0, 0, 0, 31, 32, 7, 0, 0, 0, 32, 33, 7, 1, 0, 0, 33, 2, 1, 0, 0, 0, 34, 35, 7, 2, 0, 0, 35, 36, 7, 3, 0, 0, 36, 37, 7, 4, 0, 0, 37, 4, 1, 0, 0, 0, 38, 39, 7, 3, 0, 0, 39, 40, 7, 0, 0, 0, 40, 41, 7, 5, 0, 0, 41, 6, 1, 0, 0, 0, 42, 43, 5, 62, 0, 0, 43, 8, 1, 0, 0, 0, 44, 45, 5, 60, 0, 0, 45, 10, 1, 0, 0, 0, 46, 47, 5, 62, 0, 0, 47, 48, 5, 61, 0, 0, 48, 12, 1, 0, 0, 0, 49, 50, 5, 60, 0, 0, 50, 51, 5, 61, 0, 0, 51, 14, 1, 0, 0, 0, 52, 53, 5, 58, 0, 0, 53, 16, 1, 0, 0, 0, 54, 55, 5, 40, 0, 0, 55, 18, 1, 0, 0, 0, 56, 57, 5, 41, 0, 0, 57, 20, 1, 0, 0, 0, 58, 59, 5, 46, 0, 0, 59, 22, 1, 0, 0, 0, 60, 64, 5, 34, 0, 0, 61, 63, 8, 6, 0, 0, 62, 61, 1, 0, 0, 0, 63, 66, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 67, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 67, 68, 5, 34, 0, 0, 68, 24, 1, 0, 0, 0, 69, 71, 5, 45, 0, 0, 70, 69, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 73, 1, 0, 0, 0, 72, 74, 7, 7, 0, 0, 73, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 73, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 83, 1, 0, 0, 0, 77, 79, 5, 46, 0, 0, 78, 80, 7, 7, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 84, 1, 0, 0, 0, 83, 77, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 26, 1, 0, 0, 0, 85, 89, 7, 8, 0, 0, 86, 88, 7, 9, 0, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 28, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 94, 7, 10, 0, 0, 93, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 98, 6, 14, 0, 0, 98, 30, 1, 0, 0, 0, 8, 0, 64, 70, 75, 81, 83, 89, 95, 1, 0, 1, 0] \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/generated/DQLLexer.tokens b/src/plugins/data/public/antlr/dql/generated/DQLLexer.tokens new file mode 100644 index 000000000000..3210060bf7d1 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLLexer.tokens @@ -0,0 +1,23 @@ +OR=1 +AND=2 +NOT=3 +GT=4 +LT=5 +GE=6 +LE=7 +EQ=8 +LPAREN=9 +RPAREN=10 +DOT=11 +PHRASE=12 +NUMBER=13 +IDENTIFIER=14 +WS=15 +'>'=4 +'<'=5 +'>='=6 +'<='=7 +':'=8 +'('=9 +')'=10 +'.'=11 diff --git a/src/plugins/data/public/antlr/dql/generated/DQLLexer.ts b/src/plugins/data/public/antlr/dql/generated/DQLLexer.ts new file mode 100644 index 000000000000..dbeb7cc58d11 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLLexer.ts @@ -0,0 +1,121 @@ +// Generated from grammar/DQLLexer.g4 by ANTLR 4.13.1 + +import * as antlr from "antlr4ng"; +import { Token } from "antlr4ng"; + + +export class DQLLexer extends antlr.Lexer { + public static readonly OR = 1; + public static readonly AND = 2; + public static readonly NOT = 3; + public static readonly GT = 4; + public static readonly LT = 5; + public static readonly GE = 6; + public static readonly LE = 7; + public static readonly EQ = 8; + public static readonly LPAREN = 9; + public static readonly RPAREN = 10; + public static readonly DOT = 11; + public static readonly PHRASE = 12; + public static readonly NUMBER = 13; + public static readonly IDENTIFIER = 14; + public static readonly WS = 15; + + public static readonly channelNames = [ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + ]; + + public static readonly literalNames = [ + null, null, null, null, "'>'", "'<'", "'>='", "'<='", "':'", "'('", + "')'", "'.'" + ]; + + public static readonly symbolicNames = [ + null, "OR", "AND", "NOT", "GT", "LT", "GE", "LE", "EQ", "LPAREN", + "RPAREN", "DOT", "PHRASE", "NUMBER", "IDENTIFIER", "WS" + ]; + + public static readonly modeNames = [ + "DEFAULT_MODE", + ]; + + public static readonly ruleNames = [ + "OR", "AND", "NOT", "GT", "LT", "GE", "LE", "EQ", "LPAREN", "RPAREN", + "DOT", "PHRASE", "NUMBER", "IDENTIFIER", "WS", + ]; + + + public constructor(input: antlr.CharStream) { + super(input); + this.interpreter = new antlr.LexerATNSimulator(this, DQLLexer._ATN, DQLLexer.decisionsToDFA, new antlr.PredictionContextCache()); + } + + public get grammarFileName(): string { return "DQLLexer.g4"; } + + public get literalNames(): (string | null)[] { return DQLLexer.literalNames; } + public get symbolicNames(): (string | null)[] { return DQLLexer.symbolicNames; } + public get ruleNames(): string[] { return DQLLexer.ruleNames; } + + public get serializedATN(): number[] { return DQLLexer._serializedATN; } + + public get channelNames(): string[] { return DQLLexer.channelNames; } + + public get modeNames(): string[] { return DQLLexer.modeNames; } + + public static readonly _serializedATN: number[] = [ + 4,0,15,99,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2, + 6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13, + 7,13,2,14,7,14,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1, + 3,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1, + 10,1,11,1,11,5,11,63,8,11,10,11,12,11,66,9,11,1,11,1,11,1,12,3,12, + 71,8,12,1,12,4,12,74,8,12,11,12,12,12,75,1,12,1,12,4,12,80,8,12, + 11,12,12,12,81,3,12,84,8,12,1,13,1,13,5,13,88,8,13,10,13,12,13,91, + 9,13,1,14,4,14,94,8,14,11,14,12,14,95,1,14,1,14,0,0,15,1,1,3,2,5, + 3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15, + 1,0,11,2,0,79,79,111,111,2,0,82,82,114,114,2,0,65,65,97,97,2,0,78, + 78,110,110,2,0,68,68,100,100,2,0,84,84,116,116,2,0,34,34,92,92,1, + 0,48,57,4,0,42,42,65,90,95,95,97,122,5,0,42,42,48,57,65,90,95,95, + 97,122,3,0,9,10,13,13,32,32,105,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0, + 0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0, + 0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0, + 0,0,27,1,0,0,0,0,29,1,0,0,0,1,31,1,0,0,0,3,34,1,0,0,0,5,38,1,0,0, + 0,7,42,1,0,0,0,9,44,1,0,0,0,11,46,1,0,0,0,13,49,1,0,0,0,15,52,1, + 0,0,0,17,54,1,0,0,0,19,56,1,0,0,0,21,58,1,0,0,0,23,60,1,0,0,0,25, + 70,1,0,0,0,27,85,1,0,0,0,29,93,1,0,0,0,31,32,7,0,0,0,32,33,7,1,0, + 0,33,2,1,0,0,0,34,35,7,2,0,0,35,36,7,3,0,0,36,37,7,4,0,0,37,4,1, + 0,0,0,38,39,7,3,0,0,39,40,7,0,0,0,40,41,7,5,0,0,41,6,1,0,0,0,42, + 43,5,62,0,0,43,8,1,0,0,0,44,45,5,60,0,0,45,10,1,0,0,0,46,47,5,62, + 0,0,47,48,5,61,0,0,48,12,1,0,0,0,49,50,5,60,0,0,50,51,5,61,0,0,51, + 14,1,0,0,0,52,53,5,58,0,0,53,16,1,0,0,0,54,55,5,40,0,0,55,18,1,0, + 0,0,56,57,5,41,0,0,57,20,1,0,0,0,58,59,5,46,0,0,59,22,1,0,0,0,60, + 64,5,34,0,0,61,63,8,6,0,0,62,61,1,0,0,0,63,66,1,0,0,0,64,62,1,0, + 0,0,64,65,1,0,0,0,65,67,1,0,0,0,66,64,1,0,0,0,67,68,5,34,0,0,68, + 24,1,0,0,0,69,71,5,45,0,0,70,69,1,0,0,0,70,71,1,0,0,0,71,73,1,0, + 0,0,72,74,7,7,0,0,73,72,1,0,0,0,74,75,1,0,0,0,75,73,1,0,0,0,75,76, + 1,0,0,0,76,83,1,0,0,0,77,79,5,46,0,0,78,80,7,7,0,0,79,78,1,0,0,0, + 80,81,1,0,0,0,81,79,1,0,0,0,81,82,1,0,0,0,82,84,1,0,0,0,83,77,1, + 0,0,0,83,84,1,0,0,0,84,26,1,0,0,0,85,89,7,8,0,0,86,88,7,9,0,0,87, + 86,1,0,0,0,88,91,1,0,0,0,89,87,1,0,0,0,89,90,1,0,0,0,90,28,1,0,0, + 0,91,89,1,0,0,0,92,94,7,10,0,0,93,92,1,0,0,0,94,95,1,0,0,0,95,93, + 1,0,0,0,95,96,1,0,0,0,96,97,1,0,0,0,97,98,6,14,0,0,98,30,1,0,0,0, + 8,0,64,70,75,81,83,89,95,1,0,1,0 + ]; + + private static __ATN: antlr.ATN; + public static get _ATN(): antlr.ATN { + if (!DQLLexer.__ATN) { + DQLLexer.__ATN = new antlr.ATNDeserializer().deserialize(DQLLexer._serializedATN); + } + + return DQLLexer.__ATN; + } + + + private static readonly vocabulary = new antlr.Vocabulary(DQLLexer.literalNames, DQLLexer.symbolicNames, []); + + public override get vocabulary(): antlr.Vocabulary { + return DQLLexer.vocabulary; + } + + private static readonly decisionsToDFA = DQLLexer._ATN.decisionToState.map( (ds: antlr.DecisionState, index: number) => new antlr.DFA(ds, index) ); +} \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/generated/DQLParser.interp b/src/plugins/data/public/antlr/dql/generated/DQLParser.interp new file mode 100644 index 000000000000..62c1ce8e8240 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLParser.interp @@ -0,0 +1,55 @@ +token literal names: +null +null +null +null +'>' +'<' +'>=' +'<=' +':' +'(' +')' +'.' +null +null +null +null + +token symbolic names: +null +OR +AND +NOT +GT +LT +GE +LE +EQ +LPAREN +RPAREN +DOT +PHRASE +NUMBER +IDENTIFIER +WS + +rule names: +query +orExpression +andExpression +notExpression +primaryExpression +comparisonExpression +fieldExpression +termSearch +groupExpression +groupContent +field +rangeValue +value +comparisonOperator + + +atn: +[4, 1, 15, 102, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43, 8, 2, 10, 2, 12, 2, 46, 9, 2, 1, 3, 1, 3, 1, 3, 3, 3, 51, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 60, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 76, 8, 8, 1, 8, 5, 8, 79, 8, 8, 10, 8, 12, 8, 82, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 3, 9, 88, 8, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 98, 8, 12, 1, 13, 1, 13, 1, 13, 0, 0, 14, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 0, 3, 1, 0, 1, 2, 1, 0, 12, 13, 1, 0, 4, 7, 99, 0, 28, 1, 0, 0, 0, 2, 31, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 50, 1, 0, 0, 0, 8, 59, 1, 0, 0, 0, 10, 61, 1, 0, 0, 0, 12, 65, 1, 0, 0, 0, 14, 69, 1, 0, 0, 0, 16, 71, 1, 0, 0, 0, 18, 87, 1, 0, 0, 0, 20, 89, 1, 0, 0, 0, 22, 91, 1, 0, 0, 0, 24, 97, 1, 0, 0, 0, 26, 99, 1, 0, 0, 0, 28, 29, 3, 2, 1, 0, 29, 30, 5, 0, 0, 1, 30, 1, 1, 0, 0, 0, 31, 36, 3, 4, 2, 0, 32, 33, 5, 1, 0, 0, 33, 35, 3, 4, 2, 0, 34, 32, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 40, 41, 5, 2, 0, 0, 41, 43, 3, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 48, 5, 3, 0, 0, 48, 51, 3, 6, 3, 0, 49, 51, 3, 8, 4, 0, 50, 47, 1, 0, 0, 0, 50, 49, 1, 0, 0, 0, 51, 7, 1, 0, 0, 0, 52, 53, 5, 9, 0, 0, 53, 54, 3, 0, 0, 0, 54, 55, 5, 10, 0, 0, 55, 60, 1, 0, 0, 0, 56, 60, 3, 10, 5, 0, 57, 60, 3, 12, 6, 0, 58, 60, 3, 14, 7, 0, 59, 52, 1, 0, 0, 0, 59, 56, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, 60, 9, 1, 0, 0, 0, 61, 62, 3, 20, 10, 0, 62, 63, 3, 26, 13, 0, 63, 64, 3, 22, 11, 0, 64, 11, 1, 0, 0, 0, 65, 66, 3, 20, 10, 0, 66, 67, 5, 8, 0, 0, 67, 68, 3, 24, 12, 0, 68, 13, 1, 0, 0, 0, 69, 70, 5, 14, 0, 0, 70, 15, 1, 0, 0, 0, 71, 72, 5, 9, 0, 0, 72, 80, 3, 18, 9, 0, 73, 75, 7, 0, 0, 0, 74, 76, 5, 3, 0, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 79, 3, 18, 9, 0, 78, 73, 1, 0, 0, 0, 79, 82, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 83, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 83, 84, 5, 10, 0, 0, 84, 17, 1, 0, 0, 0, 85, 88, 3, 16, 8, 0, 86, 88, 3, 14, 7, 0, 87, 85, 1, 0, 0, 0, 87, 86, 1, 0, 0, 0, 88, 19, 1, 0, 0, 0, 89, 90, 5, 14, 0, 0, 90, 21, 1, 0, 0, 0, 91, 92, 7, 1, 0, 0, 92, 23, 1, 0, 0, 0, 93, 98, 5, 12, 0, 0, 94, 98, 5, 13, 0, 0, 95, 98, 3, 14, 7, 0, 96, 98, 3, 16, 8, 0, 97, 93, 1, 0, 0, 0, 97, 94, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 96, 1, 0, 0, 0, 98, 25, 1, 0, 0, 0, 99, 100, 7, 2, 0, 0, 100, 27, 1, 0, 0, 0, 8, 36, 44, 50, 59, 75, 80, 87, 97] \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/generated/DQLParser.tokens b/src/plugins/data/public/antlr/dql/generated/DQLParser.tokens new file mode 100644 index 000000000000..3210060bf7d1 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLParser.tokens @@ -0,0 +1,23 @@ +OR=1 +AND=2 +NOT=3 +GT=4 +LT=5 +GE=6 +LE=7 +EQ=8 +LPAREN=9 +RPAREN=10 +DOT=11 +PHRASE=12 +NUMBER=13 +IDENTIFIER=14 +WS=15 +'>'=4 +'<'=5 +'>='=6 +'<='=7 +':'=8 +'('=9 +')'=10 +'.'=11 diff --git a/src/plugins/data/public/antlr/dql/generated/DQLParser.ts b/src/plugins/data/public/antlr/dql/generated/DQLParser.ts new file mode 100644 index 000000000000..959e98eb79f4 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLParser.ts @@ -0,0 +1,1189 @@ +// Generated from grammar/DQLParser.g4 by ANTLR 4.13.1 + +import * as antlr from "antlr4ng"; +import { Token } from "antlr4ng"; + +import { DQLParserListener } from "./DQLParserListener.js"; +import { DQLParserVisitor } from "./DQLParserVisitor.js"; + +// for running tests with parameters, TODO: discuss strategy for typed parameters in CI +// eslint-disable-next-line no-unused-vars +type int = number; + + +export class DQLParser extends antlr.Parser { + public static readonly OR = 1; + public static readonly AND = 2; + public static readonly NOT = 3; + public static readonly GT = 4; + public static readonly LT = 5; + public static readonly GE = 6; + public static readonly LE = 7; + public static readonly EQ = 8; + public static readonly LPAREN = 9; + public static readonly RPAREN = 10; + public static readonly DOT = 11; + public static readonly PHRASE = 12; + public static readonly NUMBER = 13; + public static readonly IDENTIFIER = 14; + public static readonly WS = 15; + public static readonly RULE_query = 0; + public static readonly RULE_orExpression = 1; + public static readonly RULE_andExpression = 2; + public static readonly RULE_notExpression = 3; + public static readonly RULE_primaryExpression = 4; + public static readonly RULE_comparisonExpression = 5; + public static readonly RULE_fieldExpression = 6; + public static readonly RULE_termSearch = 7; + public static readonly RULE_groupExpression = 8; + public static readonly RULE_groupContent = 9; + public static readonly RULE_field = 10; + public static readonly RULE_rangeValue = 11; + public static readonly RULE_value = 12; + public static readonly RULE_comparisonOperator = 13; + + public static readonly literalNames = [ + null, null, null, null, "'>'", "'<'", "'>='", "'<='", "':'", "'('", + "')'", "'.'" + ]; + + public static readonly symbolicNames = [ + null, "OR", "AND", "NOT", "GT", "LT", "GE", "LE", "EQ", "LPAREN", + "RPAREN", "DOT", "PHRASE", "NUMBER", "IDENTIFIER", "WS" + ]; + public static readonly ruleNames = [ + "query", "orExpression", "andExpression", "notExpression", "primaryExpression", + "comparisonExpression", "fieldExpression", "termSearch", "groupExpression", + "groupContent", "field", "rangeValue", "value", "comparisonOperator", + ]; + + public get grammarFileName(): string { return "DQLParser.g4"; } + public get literalNames(): (string | null)[] { return DQLParser.literalNames; } + public get symbolicNames(): (string | null)[] { return DQLParser.symbolicNames; } + public get ruleNames(): string[] { return DQLParser.ruleNames; } + public get serializedATN(): number[] { return DQLParser._serializedATN; } + + protected createFailedPredicateException(predicate?: string, message?: string): antlr.FailedPredicateException { + return new antlr.FailedPredicateException(this, predicate, message); + } + + public constructor(input: antlr.TokenStream) { + super(input); + this.interpreter = new antlr.ParserATNSimulator(this, DQLParser._ATN, DQLParser.decisionsToDFA, new antlr.PredictionContextCache()); + } + public query(): QueryContext { + let localContext = new QueryContext(this.context, this.state); + this.enterRule(localContext, 0, DQLParser.RULE_query); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 28; + this.orExpression(); + this.state = 29; + this.match(DQLParser.EOF); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public orExpression(): OrExpressionContext { + let localContext = new OrExpressionContext(this.context, this.state); + this.enterRule(localContext, 2, DQLParser.RULE_orExpression); + let _la: number; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 31; + this.andExpression(); + this.state = 36; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 1) { + { + { + this.state = 32; + this.match(DQLParser.OR); + this.state = 33; + this.andExpression(); + } + } + this.state = 38; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public andExpression(): AndExpressionContext { + let localContext = new AndExpressionContext(this.context, this.state); + this.enterRule(localContext, 4, DQLParser.RULE_andExpression); + let _la: number; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 39; + this.notExpression(); + this.state = 44; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 2) { + { + { + this.state = 40; + this.match(DQLParser.AND); + this.state = 41; + this.notExpression(); + } + } + this.state = 46; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public notExpression(): NotExpressionContext { + let localContext = new NotExpressionContext(this.context, this.state); + this.enterRule(localContext, 6, DQLParser.RULE_notExpression); + try { + this.state = 50; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case DQLParser.NOT: + this.enterOuterAlt(localContext, 1); + { + this.state = 47; + this.match(DQLParser.NOT); + this.state = 48; + this.notExpression(); + } + break; + case DQLParser.LPAREN: + case DQLParser.IDENTIFIER: + this.enterOuterAlt(localContext, 2); + { + this.state = 49; + this.primaryExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public primaryExpression(): PrimaryExpressionContext { + let localContext = new PrimaryExpressionContext(this.context, this.state); + this.enterRule(localContext, 8, DQLParser.RULE_primaryExpression); + try { + this.state = 59; + this.errorHandler.sync(this); + switch (this.interpreter.adaptivePredict(this.tokenStream, 3, this.context) ) { + case 1: + this.enterOuterAlt(localContext, 1); + { + this.state = 52; + this.match(DQLParser.LPAREN); + this.state = 53; + this.query(); + this.state = 54; + this.match(DQLParser.RPAREN); + } + break; + case 2: + this.enterOuterAlt(localContext, 2); + { + this.state = 56; + this.comparisonExpression(); + } + break; + case 3: + this.enterOuterAlt(localContext, 3); + { + this.state = 57; + this.fieldExpression(); + } + break; + case 4: + this.enterOuterAlt(localContext, 4); + { + this.state = 58; + this.termSearch(); + } + break; + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public comparisonExpression(): ComparisonExpressionContext { + let localContext = new ComparisonExpressionContext(this.context, this.state); + this.enterRule(localContext, 10, DQLParser.RULE_comparisonExpression); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 61; + this.field(); + this.state = 62; + this.comparisonOperator(); + this.state = 63; + this.rangeValue(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public fieldExpression(): FieldExpressionContext { + let localContext = new FieldExpressionContext(this.context, this.state); + this.enterRule(localContext, 12, DQLParser.RULE_fieldExpression); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 65; + this.field(); + this.state = 66; + this.match(DQLParser.EQ); + this.state = 67; + this.value(); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public termSearch(): TermSearchContext { + let localContext = new TermSearchContext(this.context, this.state); + this.enterRule(localContext, 14, DQLParser.RULE_termSearch); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 69; + this.match(DQLParser.IDENTIFIER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public groupExpression(): GroupExpressionContext { + let localContext = new GroupExpressionContext(this.context, this.state); + this.enterRule(localContext, 16, DQLParser.RULE_groupExpression); + let _la: number; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 71; + this.match(DQLParser.LPAREN); + this.state = 72; + this.groupContent(); + this.state = 80; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + while (_la === 1 || _la === 2) { + { + { + this.state = 73; + _la = this.tokenStream.LA(1); + if(!(_la === 1 || _la === 2)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + { + this.state = 75; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + if (_la === 3) { + { + this.state = 74; + this.match(DQLParser.NOT); + } + } + + } + this.state = 77; + this.groupContent(); + } + } + this.state = 82; + this.errorHandler.sync(this); + _la = this.tokenStream.LA(1); + } + this.state = 83; + this.match(DQLParser.RPAREN); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public groupContent(): GroupContentContext { + let localContext = new GroupContentContext(this.context, this.state); + this.enterRule(localContext, 18, DQLParser.RULE_groupContent); + try { + this.state = 87; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case DQLParser.LPAREN: + this.enterOuterAlt(localContext, 1); + { + this.state = 85; + this.groupExpression(); + } + break; + case DQLParser.IDENTIFIER: + this.enterOuterAlt(localContext, 2); + { + this.state = 86; + this.termSearch(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public field(): FieldContext { + let localContext = new FieldContext(this.context, this.state); + this.enterRule(localContext, 20, DQLParser.RULE_field); + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 89; + this.match(DQLParser.IDENTIFIER); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public rangeValue(): RangeValueContext { + let localContext = new RangeValueContext(this.context, this.state); + this.enterRule(localContext, 22, DQLParser.RULE_rangeValue); + let _la: number; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 91; + _la = this.tokenStream.LA(1); + if(!(_la === 12 || _la === 13)) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public value(): ValueContext { + let localContext = new ValueContext(this.context, this.state); + this.enterRule(localContext, 24, DQLParser.RULE_value); + try { + this.state = 97; + this.errorHandler.sync(this); + switch (this.tokenStream.LA(1)) { + case DQLParser.PHRASE: + this.enterOuterAlt(localContext, 1); + { + this.state = 93; + this.match(DQLParser.PHRASE); + } + break; + case DQLParser.NUMBER: + this.enterOuterAlt(localContext, 2); + { + this.state = 94; + this.match(DQLParser.NUMBER); + } + break; + case DQLParser.IDENTIFIER: + this.enterOuterAlt(localContext, 3); + { + this.state = 95; + this.termSearch(); + } + break; + case DQLParser.LPAREN: + this.enterOuterAlt(localContext, 4); + { + this.state = 96; + this.groupExpression(); + } + break; + default: + throw new antlr.NoViableAltException(this); + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + public comparisonOperator(): ComparisonOperatorContext { + let localContext = new ComparisonOperatorContext(this.context, this.state); + this.enterRule(localContext, 26, DQLParser.RULE_comparisonOperator); + let _la: number; + try { + this.enterOuterAlt(localContext, 1); + { + this.state = 99; + _la = this.tokenStream.LA(1); + if(!((((_la) & ~0x1F) === 0 && ((1 << _la) & 240) !== 0))) { + this.errorHandler.recoverInline(this); + } + else { + this.errorHandler.reportMatch(this); + this.consume(); + } + } + } + catch (re) { + if (re instanceof antlr.RecognitionException) { + this.errorHandler.reportError(this, re); + this.errorHandler.recover(this, re); + } else { + throw re; + } + } + finally { + this.exitRule(); + } + return localContext; + } + + public static readonly _serializedATN: number[] = [ + 4,1,15,102,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, + 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13, + 1,0,1,0,1,0,1,1,1,1,1,1,5,1,35,8,1,10,1,12,1,38,9,1,1,2,1,2,1,2, + 5,2,43,8,2,10,2,12,2,46,9,2,1,3,1,3,1,3,3,3,51,8,3,1,4,1,4,1,4,1, + 4,1,4,1,4,1,4,3,4,60,8,4,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7, + 1,8,1,8,1,8,1,8,3,8,76,8,8,1,8,5,8,79,8,8,10,8,12,8,82,9,8,1,8,1, + 8,1,9,1,9,3,9,88,8,9,1,10,1,10,1,11,1,11,1,12,1,12,1,12,1,12,3,12, + 98,8,12,1,13,1,13,1,13,0,0,14,0,2,4,6,8,10,12,14,16,18,20,22,24, + 26,0,3,1,0,1,2,1,0,12,13,1,0,4,7,99,0,28,1,0,0,0,2,31,1,0,0,0,4, + 39,1,0,0,0,6,50,1,0,0,0,8,59,1,0,0,0,10,61,1,0,0,0,12,65,1,0,0,0, + 14,69,1,0,0,0,16,71,1,0,0,0,18,87,1,0,0,0,20,89,1,0,0,0,22,91,1, + 0,0,0,24,97,1,0,0,0,26,99,1,0,0,0,28,29,3,2,1,0,29,30,5,0,0,1,30, + 1,1,0,0,0,31,36,3,4,2,0,32,33,5,1,0,0,33,35,3,4,2,0,34,32,1,0,0, + 0,35,38,1,0,0,0,36,34,1,0,0,0,36,37,1,0,0,0,37,3,1,0,0,0,38,36,1, + 0,0,0,39,44,3,6,3,0,40,41,5,2,0,0,41,43,3,6,3,0,42,40,1,0,0,0,43, + 46,1,0,0,0,44,42,1,0,0,0,44,45,1,0,0,0,45,5,1,0,0,0,46,44,1,0,0, + 0,47,48,5,3,0,0,48,51,3,6,3,0,49,51,3,8,4,0,50,47,1,0,0,0,50,49, + 1,0,0,0,51,7,1,0,0,0,52,53,5,9,0,0,53,54,3,0,0,0,54,55,5,10,0,0, + 55,60,1,0,0,0,56,60,3,10,5,0,57,60,3,12,6,0,58,60,3,14,7,0,59,52, + 1,0,0,0,59,56,1,0,0,0,59,57,1,0,0,0,59,58,1,0,0,0,60,9,1,0,0,0,61, + 62,3,20,10,0,62,63,3,26,13,0,63,64,3,22,11,0,64,11,1,0,0,0,65,66, + 3,20,10,0,66,67,5,8,0,0,67,68,3,24,12,0,68,13,1,0,0,0,69,70,5,14, + 0,0,70,15,1,0,0,0,71,72,5,9,0,0,72,80,3,18,9,0,73,75,7,0,0,0,74, + 76,5,3,0,0,75,74,1,0,0,0,75,76,1,0,0,0,76,77,1,0,0,0,77,79,3,18, + 9,0,78,73,1,0,0,0,79,82,1,0,0,0,80,78,1,0,0,0,80,81,1,0,0,0,81,83, + 1,0,0,0,82,80,1,0,0,0,83,84,5,10,0,0,84,17,1,0,0,0,85,88,3,16,8, + 0,86,88,3,14,7,0,87,85,1,0,0,0,87,86,1,0,0,0,88,19,1,0,0,0,89,90, + 5,14,0,0,90,21,1,0,0,0,91,92,7,1,0,0,92,23,1,0,0,0,93,98,5,12,0, + 0,94,98,5,13,0,0,95,98,3,14,7,0,96,98,3,16,8,0,97,93,1,0,0,0,97, + 94,1,0,0,0,97,95,1,0,0,0,97,96,1,0,0,0,98,25,1,0,0,0,99,100,7,2, + 0,0,100,27,1,0,0,0,8,36,44,50,59,75,80,87,97 + ]; + + private static __ATN: antlr.ATN; + public static get _ATN(): antlr.ATN { + if (!DQLParser.__ATN) { + DQLParser.__ATN = new antlr.ATNDeserializer().deserialize(DQLParser._serializedATN); + } + + return DQLParser.__ATN; + } + + + private static readonly vocabulary = new antlr.Vocabulary(DQLParser.literalNames, DQLParser.symbolicNames, []); + + public override get vocabulary(): antlr.Vocabulary { + return DQLParser.vocabulary; + } + + private static readonly decisionsToDFA = DQLParser._ATN.decisionToState.map( (ds: antlr.DecisionState, index: number) => new antlr.DFA(ds, index) ); +} + +export class QueryContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public orExpression(): OrExpressionContext { + return this.getRuleContext(0, OrExpressionContext)!; + } + public EOF(): antlr.TerminalNode { + return this.getToken(DQLParser.EOF, 0)!; + } + public override get ruleIndex(): number { + return DQLParser.RULE_query; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterQuery) { + listener.enterQuery(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitQuery) { + listener.exitQuery(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitQuery) { + return visitor.visitQuery(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class OrExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public andExpression(): AndExpressionContext[]; + public andExpression(i: number): AndExpressionContext | null; + public andExpression(i?: number): AndExpressionContext[] | AndExpressionContext | null { + if (i === undefined) { + return this.getRuleContexts(AndExpressionContext); + } + + return this.getRuleContext(i, AndExpressionContext); + } + public OR(): antlr.TerminalNode[]; + public OR(i: number): antlr.TerminalNode | null; + public OR(i?: number): antlr.TerminalNode | null | antlr.TerminalNode[] { + if (i === undefined) { + return this.getTokens(DQLParser.OR); + } else { + return this.getToken(DQLParser.OR, i); + } + } + public override get ruleIndex(): number { + return DQLParser.RULE_orExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterOrExpression) { + listener.enterOrExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitOrExpression) { + listener.exitOrExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitOrExpression) { + return visitor.visitOrExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class AndExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public notExpression(): NotExpressionContext[]; + public notExpression(i: number): NotExpressionContext | null; + public notExpression(i?: number): NotExpressionContext[] | NotExpressionContext | null { + if (i === undefined) { + return this.getRuleContexts(NotExpressionContext); + } + + return this.getRuleContext(i, NotExpressionContext); + } + public AND(): antlr.TerminalNode[]; + public AND(i: number): antlr.TerminalNode | null; + public AND(i?: number): antlr.TerminalNode | null | antlr.TerminalNode[] { + if (i === undefined) { + return this.getTokens(DQLParser.AND); + } else { + return this.getToken(DQLParser.AND, i); + } + } + public override get ruleIndex(): number { + return DQLParser.RULE_andExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterAndExpression) { + listener.enterAndExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitAndExpression) { + listener.exitAndExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitAndExpression) { + return visitor.visitAndExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class NotExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public NOT(): antlr.TerminalNode | null { + return this.getToken(DQLParser.NOT, 0); + } + public notExpression(): NotExpressionContext | null { + return this.getRuleContext(0, NotExpressionContext); + } + public primaryExpression(): PrimaryExpressionContext | null { + return this.getRuleContext(0, PrimaryExpressionContext); + } + public override get ruleIndex(): number { + return DQLParser.RULE_notExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterNotExpression) { + listener.enterNotExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitNotExpression) { + listener.exitNotExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitNotExpression) { + return visitor.visitNotExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class PrimaryExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public LPAREN(): antlr.TerminalNode | null { + return this.getToken(DQLParser.LPAREN, 0); + } + public query(): QueryContext | null { + return this.getRuleContext(0, QueryContext); + } + public RPAREN(): antlr.TerminalNode | null { + return this.getToken(DQLParser.RPAREN, 0); + } + public comparisonExpression(): ComparisonExpressionContext | null { + return this.getRuleContext(0, ComparisonExpressionContext); + } + public fieldExpression(): FieldExpressionContext | null { + return this.getRuleContext(0, FieldExpressionContext); + } + public termSearch(): TermSearchContext | null { + return this.getRuleContext(0, TermSearchContext); + } + public override get ruleIndex(): number { + return DQLParser.RULE_primaryExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterPrimaryExpression) { + listener.enterPrimaryExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitPrimaryExpression) { + listener.exitPrimaryExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitPrimaryExpression) { + return visitor.visitPrimaryExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ComparisonExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public field(): FieldContext { + return this.getRuleContext(0, FieldContext)!; + } + public comparisonOperator(): ComparisonOperatorContext { + return this.getRuleContext(0, ComparisonOperatorContext)!; + } + public rangeValue(): RangeValueContext { + return this.getRuleContext(0, RangeValueContext)!; + } + public override get ruleIndex(): number { + return DQLParser.RULE_comparisonExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterComparisonExpression) { + listener.enterComparisonExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitComparisonExpression) { + listener.exitComparisonExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitComparisonExpression) { + return visitor.visitComparisonExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class FieldExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public field(): FieldContext { + return this.getRuleContext(0, FieldContext)!; + } + public EQ(): antlr.TerminalNode { + return this.getToken(DQLParser.EQ, 0)!; + } + public value(): ValueContext { + return this.getRuleContext(0, ValueContext)!; + } + public override get ruleIndex(): number { + return DQLParser.RULE_fieldExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterFieldExpression) { + listener.enterFieldExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitFieldExpression) { + listener.exitFieldExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitFieldExpression) { + return visitor.visitFieldExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class TermSearchContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public IDENTIFIER(): antlr.TerminalNode { + return this.getToken(DQLParser.IDENTIFIER, 0)!; + } + public override get ruleIndex(): number { + return DQLParser.RULE_termSearch; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterTermSearch) { + listener.enterTermSearch(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitTermSearch) { + listener.exitTermSearch(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitTermSearch) { + return visitor.visitTermSearch(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class GroupExpressionContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public LPAREN(): antlr.TerminalNode { + return this.getToken(DQLParser.LPAREN, 0)!; + } + public groupContent(): GroupContentContext[]; + public groupContent(i: number): GroupContentContext | null; + public groupContent(i?: number): GroupContentContext[] | GroupContentContext | null { + if (i === undefined) { + return this.getRuleContexts(GroupContentContext); + } + + return this.getRuleContext(i, GroupContentContext); + } + public RPAREN(): antlr.TerminalNode { + return this.getToken(DQLParser.RPAREN, 0)!; + } + public OR(): antlr.TerminalNode[]; + public OR(i: number): antlr.TerminalNode | null; + public OR(i?: number): antlr.TerminalNode | null | antlr.TerminalNode[] { + if (i === undefined) { + return this.getTokens(DQLParser.OR); + } else { + return this.getToken(DQLParser.OR, i); + } + } + public AND(): antlr.TerminalNode[]; + public AND(i: number): antlr.TerminalNode | null; + public AND(i?: number): antlr.TerminalNode | null | antlr.TerminalNode[] { + if (i === undefined) { + return this.getTokens(DQLParser.AND); + } else { + return this.getToken(DQLParser.AND, i); + } + } + public NOT(): antlr.TerminalNode[]; + public NOT(i: number): antlr.TerminalNode | null; + public NOT(i?: number): antlr.TerminalNode | null | antlr.TerminalNode[] { + if (i === undefined) { + return this.getTokens(DQLParser.NOT); + } else { + return this.getToken(DQLParser.NOT, i); + } + } + public override get ruleIndex(): number { + return DQLParser.RULE_groupExpression; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterGroupExpression) { + listener.enterGroupExpression(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitGroupExpression) { + listener.exitGroupExpression(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitGroupExpression) { + return visitor.visitGroupExpression(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class GroupContentContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public groupExpression(): GroupExpressionContext | null { + return this.getRuleContext(0, GroupExpressionContext); + } + public termSearch(): TermSearchContext | null { + return this.getRuleContext(0, TermSearchContext); + } + public override get ruleIndex(): number { + return DQLParser.RULE_groupContent; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterGroupContent) { + listener.enterGroupContent(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitGroupContent) { + listener.exitGroupContent(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitGroupContent) { + return visitor.visitGroupContent(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class FieldContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public IDENTIFIER(): antlr.TerminalNode { + return this.getToken(DQLParser.IDENTIFIER, 0)!; + } + public override get ruleIndex(): number { + return DQLParser.RULE_field; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterField) { + listener.enterField(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitField) { + listener.exitField(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitField) { + return visitor.visitField(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class RangeValueContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public NUMBER(): antlr.TerminalNode | null { + return this.getToken(DQLParser.NUMBER, 0); + } + public PHRASE(): antlr.TerminalNode | null { + return this.getToken(DQLParser.PHRASE, 0); + } + public override get ruleIndex(): number { + return DQLParser.RULE_rangeValue; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterRangeValue) { + listener.enterRangeValue(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitRangeValue) { + listener.exitRangeValue(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitRangeValue) { + return visitor.visitRangeValue(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ValueContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public PHRASE(): antlr.TerminalNode | null { + return this.getToken(DQLParser.PHRASE, 0); + } + public NUMBER(): antlr.TerminalNode | null { + return this.getToken(DQLParser.NUMBER, 0); + } + public termSearch(): TermSearchContext | null { + return this.getRuleContext(0, TermSearchContext); + } + public groupExpression(): GroupExpressionContext | null { + return this.getRuleContext(0, GroupExpressionContext); + } + public override get ruleIndex(): number { + return DQLParser.RULE_value; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterValue) { + listener.enterValue(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitValue) { + listener.exitValue(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitValue) { + return visitor.visitValue(this); + } else { + return visitor.visitChildren(this); + } + } +} + + +export class ComparisonOperatorContext extends antlr.ParserRuleContext { + public constructor(parent: antlr.ParserRuleContext | null, invokingState: number) { + super(parent, invokingState); + } + public GT(): antlr.TerminalNode | null { + return this.getToken(DQLParser.GT, 0); + } + public LT(): antlr.TerminalNode | null { + return this.getToken(DQLParser.LT, 0); + } + public GE(): antlr.TerminalNode | null { + return this.getToken(DQLParser.GE, 0); + } + public LE(): antlr.TerminalNode | null { + return this.getToken(DQLParser.LE, 0); + } + public override get ruleIndex(): number { + return DQLParser.RULE_comparisonOperator; + } + public override enterRule(listener: DQLParserListener): void { + if(listener.enterComparisonOperator) { + listener.enterComparisonOperator(this); + } + } + public override exitRule(listener: DQLParserListener): void { + if(listener.exitComparisonOperator) { + listener.exitComparisonOperator(this); + } + } + public override accept(visitor: DQLParserVisitor): Result | null { + if (visitor.visitComparisonOperator) { + return visitor.visitComparisonOperator(this); + } else { + return visitor.visitChildren(this); + } + } +} diff --git a/src/plugins/data/public/antlr/dql/generated/DQLParserListener.ts b/src/plugins/data/public/antlr/dql/generated/DQLParserListener.ts new file mode 100644 index 000000000000..cb830937af95 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLParserListener.ts @@ -0,0 +1,173 @@ +// Generated from grammar/DQLParser.g4 by ANTLR 4.13.1 + +import { ErrorNode, ParseTreeListener, ParserRuleContext, TerminalNode } from "antlr4ng"; + + +import { QueryContext } from "./DQLParser.js"; +import { OrExpressionContext } from "./DQLParser.js"; +import { AndExpressionContext } from "./DQLParser.js"; +import { NotExpressionContext } from "./DQLParser.js"; +import { PrimaryExpressionContext } from "./DQLParser.js"; +import { ComparisonExpressionContext } from "./DQLParser.js"; +import { FieldExpressionContext } from "./DQLParser.js"; +import { TermSearchContext } from "./DQLParser.js"; +import { GroupExpressionContext } from "./DQLParser.js"; +import { GroupContentContext } from "./DQLParser.js"; +import { FieldContext } from "./DQLParser.js"; +import { RangeValueContext } from "./DQLParser.js"; +import { ValueContext } from "./DQLParser.js"; +import { ComparisonOperatorContext } from "./DQLParser.js"; + + +/** + * This interface defines a complete listener for a parse tree produced by + * `DQLParser`. + */ +export class DQLParserListener implements ParseTreeListener { + /** + * Enter a parse tree produced by `DQLParser.query`. + * @param ctx the parse tree + */ + enterQuery?: (ctx: QueryContext) => void; + /** + * Exit a parse tree produced by `DQLParser.query`. + * @param ctx the parse tree + */ + exitQuery?: (ctx: QueryContext) => void; + /** + * Enter a parse tree produced by `DQLParser.orExpression`. + * @param ctx the parse tree + */ + enterOrExpression?: (ctx: OrExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.orExpression`. + * @param ctx the parse tree + */ + exitOrExpression?: (ctx: OrExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.andExpression`. + * @param ctx the parse tree + */ + enterAndExpression?: (ctx: AndExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.andExpression`. + * @param ctx the parse tree + */ + exitAndExpression?: (ctx: AndExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.notExpression`. + * @param ctx the parse tree + */ + enterNotExpression?: (ctx: NotExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.notExpression`. + * @param ctx the parse tree + */ + exitNotExpression?: (ctx: NotExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.primaryExpression`. + * @param ctx the parse tree + */ + enterPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.primaryExpression`. + * @param ctx the parse tree + */ + exitPrimaryExpression?: (ctx: PrimaryExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.comparisonExpression`. + * @param ctx the parse tree + */ + enterComparisonExpression?: (ctx: ComparisonExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.comparisonExpression`. + * @param ctx the parse tree + */ + exitComparisonExpression?: (ctx: ComparisonExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.fieldExpression`. + * @param ctx the parse tree + */ + enterFieldExpression?: (ctx: FieldExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.fieldExpression`. + * @param ctx the parse tree + */ + exitFieldExpression?: (ctx: FieldExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.termSearch`. + * @param ctx the parse tree + */ + enterTermSearch?: (ctx: TermSearchContext) => void; + /** + * Exit a parse tree produced by `DQLParser.termSearch`. + * @param ctx the parse tree + */ + exitTermSearch?: (ctx: TermSearchContext) => void; + /** + * Enter a parse tree produced by `DQLParser.groupExpression`. + * @param ctx the parse tree + */ + enterGroupExpression?: (ctx: GroupExpressionContext) => void; + /** + * Exit a parse tree produced by `DQLParser.groupExpression`. + * @param ctx the parse tree + */ + exitGroupExpression?: (ctx: GroupExpressionContext) => void; + /** + * Enter a parse tree produced by `DQLParser.groupContent`. + * @param ctx the parse tree + */ + enterGroupContent?: (ctx: GroupContentContext) => void; + /** + * Exit a parse tree produced by `DQLParser.groupContent`. + * @param ctx the parse tree + */ + exitGroupContent?: (ctx: GroupContentContext) => void; + /** + * Enter a parse tree produced by `DQLParser.field`. + * @param ctx the parse tree + */ + enterField?: (ctx: FieldContext) => void; + /** + * Exit a parse tree produced by `DQLParser.field`. + * @param ctx the parse tree + */ + exitField?: (ctx: FieldContext) => void; + /** + * Enter a parse tree produced by `DQLParser.rangeValue`. + * @param ctx the parse tree + */ + enterRangeValue?: (ctx: RangeValueContext) => void; + /** + * Exit a parse tree produced by `DQLParser.rangeValue`. + * @param ctx the parse tree + */ + exitRangeValue?: (ctx: RangeValueContext) => void; + /** + * Enter a parse tree produced by `DQLParser.value`. + * @param ctx the parse tree + */ + enterValue?: (ctx: ValueContext) => void; + /** + * Exit a parse tree produced by `DQLParser.value`. + * @param ctx the parse tree + */ + exitValue?: (ctx: ValueContext) => void; + /** + * Enter a parse tree produced by `DQLParser.comparisonOperator`. + * @param ctx the parse tree + */ + enterComparisonOperator?: (ctx: ComparisonOperatorContext) => void; + /** + * Exit a parse tree produced by `DQLParser.comparisonOperator`. + * @param ctx the parse tree + */ + exitComparisonOperator?: (ctx: ComparisonOperatorContext) => void; + + visitTerminal(node: TerminalNode): void {} + visitErrorNode(node: ErrorNode): void {} + enterEveryRule(node: ParserRuleContext): void {} + exitEveryRule(node: ParserRuleContext): void {} +} + diff --git a/src/plugins/data/public/antlr/dql/generated/DQLParserVisitor.ts b/src/plugins/data/public/antlr/dql/generated/DQLParserVisitor.ts new file mode 100644 index 000000000000..759e316f84da --- /dev/null +++ b/src/plugins/data/public/antlr/dql/generated/DQLParserVisitor.ts @@ -0,0 +1,115 @@ +// Generated from grammar/DQLParser.g4 by ANTLR 4.13.1 + +import { AbstractParseTreeVisitor } from "antlr4ng"; + + +import { QueryContext } from "./DQLParser.js"; +import { OrExpressionContext } from "./DQLParser.js"; +import { AndExpressionContext } from "./DQLParser.js"; +import { NotExpressionContext } from "./DQLParser.js"; +import { PrimaryExpressionContext } from "./DQLParser.js"; +import { ComparisonExpressionContext } from "./DQLParser.js"; +import { FieldExpressionContext } from "./DQLParser.js"; +import { TermSearchContext } from "./DQLParser.js"; +import { GroupExpressionContext } from "./DQLParser.js"; +import { GroupContentContext } from "./DQLParser.js"; +import { FieldContext } from "./DQLParser.js"; +import { RangeValueContext } from "./DQLParser.js"; +import { ValueContext } from "./DQLParser.js"; +import { ComparisonOperatorContext } from "./DQLParser.js"; + + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by `DQLParser`. + * + * @param The return type of the visit operation. Use `void` for + * operations with no return type. + */ +export class DQLParserVisitor extends AbstractParseTreeVisitor { + /** + * Visit a parse tree produced by `DQLParser.query`. + * @param ctx the parse tree + * @return the visitor result + */ + visitQuery?: (ctx: QueryContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.orExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitOrExpression?: (ctx: OrExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.andExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitAndExpression?: (ctx: AndExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.notExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitNotExpression?: (ctx: NotExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.primaryExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitPrimaryExpression?: (ctx: PrimaryExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.comparisonExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitComparisonExpression?: (ctx: ComparisonExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.fieldExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitFieldExpression?: (ctx: FieldExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.termSearch`. + * @param ctx the parse tree + * @return the visitor result + */ + visitTermSearch?: (ctx: TermSearchContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.groupExpression`. + * @param ctx the parse tree + * @return the visitor result + */ + visitGroupExpression?: (ctx: GroupExpressionContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.groupContent`. + * @param ctx the parse tree + * @return the visitor result + */ + visitGroupContent?: (ctx: GroupContentContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.field`. + * @param ctx the parse tree + * @return the visitor result + */ + visitField?: (ctx: FieldContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.rangeValue`. + * @param ctx the parse tree + * @return the visitor result + */ + visitRangeValue?: (ctx: RangeValueContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.value`. + * @param ctx the parse tree + * @return the visitor result + */ + visitValue?: (ctx: ValueContext) => Result; + /** + * Visit a parse tree produced by `DQLParser.comparisonOperator`. + * @param ctx the parse tree + * @return the visitor result + */ + visitComparisonOperator?: (ctx: ComparisonOperatorContext) => Result; +} + diff --git a/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.interp b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.interp new file mode 100644 index 000000000000..370011ad4a31 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.interp @@ -0,0 +1,62 @@ +token literal names: +null +null +null +null +'>' +'<' +'>=' +'<=' +':' +'(' +')' +'.' +null +null +null +null + +token symbolic names: +null +OR +AND +NOT +GT +LT +GE +LE +EQ +LPAREN +RPAREN +DOT +PHRASE +NUMBER +IDENTIFIER +WS + +rule names: +OR +AND +NOT +GT +LT +GE +LE +EQ +LPAREN +RPAREN +DOT +PHRASE +NUMBER +IDENTIFIER +WS + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 15, 99, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 5, 11, 63, 8, 11, 10, 11, 12, 11, 66, 9, 11, 1, 11, 1, 11, 1, 12, 3, 12, 71, 8, 12, 1, 12, 4, 12, 74, 8, 12, 11, 12, 12, 12, 75, 1, 12, 1, 12, 4, 12, 80, 8, 12, 11, 12, 12, 12, 81, 3, 12, 84, 8, 12, 1, 13, 1, 13, 5, 13, 88, 8, 13, 10, 13, 12, 13, 91, 9, 13, 1, 14, 4, 14, 94, 8, 14, 11, 14, 12, 14, 95, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 1, 0, 11, 2, 0, 79, 79, 111, 111, 2, 0, 82, 82, 114, 114, 2, 0, 65, 65, 97, 97, 2, 0, 78, 78, 110, 110, 2, 0, 68, 68, 100, 100, 2, 0, 84, 84, 116, 116, 2, 0, 34, 34, 92, 92, 1, 0, 48, 57, 4, 0, 42, 42, 65, 90, 95, 95, 97, 122, 5, 0, 42, 42, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 105, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 1, 31, 1, 0, 0, 0, 3, 34, 1, 0, 0, 0, 5, 38, 1, 0, 0, 0, 7, 42, 1, 0, 0, 0, 9, 44, 1, 0, 0, 0, 11, 46, 1, 0, 0, 0, 13, 49, 1, 0, 0, 0, 15, 52, 1, 0, 0, 0, 17, 54, 1, 0, 0, 0, 19, 56, 1, 0, 0, 0, 21, 58, 1, 0, 0, 0, 23, 60, 1, 0, 0, 0, 25, 70, 1, 0, 0, 0, 27, 85, 1, 0, 0, 0, 29, 93, 1, 0, 0, 0, 31, 32, 7, 0, 0, 0, 32, 33, 7, 1, 0, 0, 33, 2, 1, 0, 0, 0, 34, 35, 7, 2, 0, 0, 35, 36, 7, 3, 0, 0, 36, 37, 7, 4, 0, 0, 37, 4, 1, 0, 0, 0, 38, 39, 7, 3, 0, 0, 39, 40, 7, 0, 0, 0, 40, 41, 7, 5, 0, 0, 41, 6, 1, 0, 0, 0, 42, 43, 5, 62, 0, 0, 43, 8, 1, 0, 0, 0, 44, 45, 5, 60, 0, 0, 45, 10, 1, 0, 0, 0, 46, 47, 5, 62, 0, 0, 47, 48, 5, 61, 0, 0, 48, 12, 1, 0, 0, 0, 49, 50, 5, 60, 0, 0, 50, 51, 5, 61, 0, 0, 51, 14, 1, 0, 0, 0, 52, 53, 5, 58, 0, 0, 53, 16, 1, 0, 0, 0, 54, 55, 5, 40, 0, 0, 55, 18, 1, 0, 0, 0, 56, 57, 5, 41, 0, 0, 57, 20, 1, 0, 0, 0, 58, 59, 5, 46, 0, 0, 59, 22, 1, 0, 0, 0, 60, 64, 5, 34, 0, 0, 61, 63, 8, 6, 0, 0, 62, 61, 1, 0, 0, 0, 63, 66, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 67, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 67, 68, 5, 34, 0, 0, 68, 24, 1, 0, 0, 0, 69, 71, 5, 45, 0, 0, 70, 69, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 73, 1, 0, 0, 0, 72, 74, 7, 7, 0, 0, 73, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 73, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 83, 1, 0, 0, 0, 77, 79, 5, 46, 0, 0, 78, 80, 7, 7, 0, 0, 79, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 84, 1, 0, 0, 0, 83, 77, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 26, 1, 0, 0, 0, 85, 89, 7, 8, 0, 0, 86, 88, 7, 9, 0, 0, 87, 86, 1, 0, 0, 0, 88, 91, 1, 0, 0, 0, 89, 87, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 28, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 92, 94, 7, 10, 0, 0, 93, 92, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 98, 6, 14, 0, 0, 98, 30, 1, 0, 0, 0, 8, 0, 64, 70, 75, 81, 83, 89, 95, 1, 0, 1, 0] \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.java b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.java new file mode 100644 index 000000000000..c486c68bd632 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.java @@ -0,0 +1,178 @@ +// Generated from /Users/paulstn/Documents/opensearch-2.15.0/OpenSearch-Dashboards/src/plugins/data/public/antlr/dql/grammar/DQLLexer.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class DQLLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, NOT=3, GT=4, LT=5, GE=6, LE=7, EQ=8, LPAREN=9, RPAREN=10, + DOT=11, PHRASE=12, NUMBER=13, IDENTIFIER=14, WS=15; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "OR", "AND", "NOT", "GT", "LT", "GE", "LE", "EQ", "LPAREN", "RPAREN", + "DOT", "PHRASE", "NUMBER", "IDENTIFIER", "WS" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, null, null, null, "'>'", "'<'", "'>='", "'<='", "':'", "'('", "')'", + "'.'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "OR", "AND", "NOT", "GT", "LT", "GE", "LE", "EQ", "LPAREN", "RPAREN", + "DOT", "PHRASE", "NUMBER", "IDENTIFIER", "WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public DQLLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "DQLLexer.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000\u000fc\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ + "\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+ + "\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+ + "\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+ + "\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0001"+ + "\u0000\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001"+ + "\u0003\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0001"+ + "\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0001\b"+ + "\u0001\t\u0001\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0005\u000b?"+ + "\b\u000b\n\u000b\f\u000bB\t\u000b\u0001\u000b\u0001\u000b\u0001\f\u0003"+ + "\fG\b\f\u0001\f\u0004\fJ\b\f\u000b\f\f\fK\u0001\f\u0001\f\u0004\fP\b\f"+ + "\u000b\f\f\fQ\u0003\fT\b\f\u0001\r\u0001\r\u0005\rX\b\r\n\r\f\r[\t\r\u0001"+ + "\u000e\u0004\u000e^\b\u000e\u000b\u000e\f\u000e_\u0001\u000e\u0001\u000e"+ + "\u0000\u0000\u000f\u0001\u0001\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005"+ + "\u000b\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019"+ + "\r\u001b\u000e\u001d\u000f\u0001\u0000\u000b\u0002\u0000OOoo\u0002\u0000"+ + "RRrr\u0002\u0000AAaa\u0002\u0000NNnn\u0002\u0000DDdd\u0002\u0000TTtt\u0002"+ + "\u0000\"\"\\\\\u0001\u000009\u0004\u0000**AZ__az\u0005\u0000**09AZ__a"+ + "z\u0003\u0000\t\n\r\r i\u0000\u0001\u0001\u0000\u0000\u0000\u0000\u0003"+ + "\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0000\u0007"+ + "\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001"+ + "\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000"+ + "\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000"+ + "\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000"+ + "\u0000\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000"+ + "\u0000\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0001\u001f\u0001\u0000"+ + "\u0000\u0000\u0003\"\u0001\u0000\u0000\u0000\u0005&\u0001\u0000\u0000"+ + "\u0000\u0007*\u0001\u0000\u0000\u0000\t,\u0001\u0000\u0000\u0000\u000b"+ + ".\u0001\u0000\u0000\u0000\r1\u0001\u0000\u0000\u0000\u000f4\u0001\u0000"+ + "\u0000\u0000\u00116\u0001\u0000\u0000\u0000\u00138\u0001\u0000\u0000\u0000"+ + "\u0015:\u0001\u0000\u0000\u0000\u0017<\u0001\u0000\u0000\u0000\u0019F"+ + "\u0001\u0000\u0000\u0000\u001bU\u0001\u0000\u0000\u0000\u001d]\u0001\u0000"+ + "\u0000\u0000\u001f \u0007\u0000\u0000\u0000 !\u0007\u0001\u0000\u0000"+ + "!\u0002\u0001\u0000\u0000\u0000\"#\u0007\u0002\u0000\u0000#$\u0007\u0003"+ + "\u0000\u0000$%\u0007\u0004\u0000\u0000%\u0004\u0001\u0000\u0000\u0000"+ + "&\'\u0007\u0003\u0000\u0000\'(\u0007\u0000\u0000\u0000()\u0007\u0005\u0000"+ + "\u0000)\u0006\u0001\u0000\u0000\u0000*+\u0005>\u0000\u0000+\b\u0001\u0000"+ + "\u0000\u0000,-\u0005<\u0000\u0000-\n\u0001\u0000\u0000\u0000./\u0005>"+ + "\u0000\u0000/0\u0005=\u0000\u00000\f\u0001\u0000\u0000\u000012\u0005<"+ + "\u0000\u000023\u0005=\u0000\u00003\u000e\u0001\u0000\u0000\u000045\u0005"+ + ":\u0000\u00005\u0010\u0001\u0000\u0000\u000067\u0005(\u0000\u00007\u0012"+ + "\u0001\u0000\u0000\u000089\u0005)\u0000\u00009\u0014\u0001\u0000\u0000"+ + "\u0000:;\u0005.\u0000\u0000;\u0016\u0001\u0000\u0000\u0000<@\u0005\"\u0000"+ + "\u0000=?\b\u0006\u0000\u0000>=\u0001\u0000\u0000\u0000?B\u0001\u0000\u0000"+ + "\u0000@>\u0001\u0000\u0000\u0000@A\u0001\u0000\u0000\u0000AC\u0001\u0000"+ + "\u0000\u0000B@\u0001\u0000\u0000\u0000CD\u0005\"\u0000\u0000D\u0018\u0001"+ + "\u0000\u0000\u0000EG\u0005-\u0000\u0000FE\u0001\u0000\u0000\u0000FG\u0001"+ + "\u0000\u0000\u0000GI\u0001\u0000\u0000\u0000HJ\u0007\u0007\u0000\u0000"+ + "IH\u0001\u0000\u0000\u0000JK\u0001\u0000\u0000\u0000KI\u0001\u0000\u0000"+ + "\u0000KL\u0001\u0000\u0000\u0000LS\u0001\u0000\u0000\u0000MO\u0005.\u0000"+ + "\u0000NP\u0007\u0007\u0000\u0000ON\u0001\u0000\u0000\u0000PQ\u0001\u0000"+ + "\u0000\u0000QO\u0001\u0000\u0000\u0000QR\u0001\u0000\u0000\u0000RT\u0001"+ + "\u0000\u0000\u0000SM\u0001\u0000\u0000\u0000ST\u0001\u0000\u0000\u0000"+ + "T\u001a\u0001\u0000\u0000\u0000UY\u0007\b\u0000\u0000VX\u0007\t\u0000"+ + "\u0000WV\u0001\u0000\u0000\u0000X[\u0001\u0000\u0000\u0000YW\u0001\u0000"+ + "\u0000\u0000YZ\u0001\u0000\u0000\u0000Z\u001c\u0001\u0000\u0000\u0000"+ + "[Y\u0001\u0000\u0000\u0000\\^\u0007\n\u0000\u0000]\\\u0001\u0000\u0000"+ + "\u0000^_\u0001\u0000\u0000\u0000_]\u0001\u0000\u0000\u0000_`\u0001\u0000"+ + "\u0000\u0000`a\u0001\u0000\u0000\u0000ab\u0006\u000e\u0000\u0000b\u001e"+ + "\u0001\u0000\u0000\u0000\b\u0000@FKQSY_\u0001\u0000\u0001\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.tokens b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.tokens new file mode 100644 index 000000000000..3210060bf7d1 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLLexer.tokens @@ -0,0 +1,23 @@ +OR=1 +AND=2 +NOT=3 +GT=4 +LT=5 +GE=6 +LE=7 +EQ=8 +LPAREN=9 +RPAREN=10 +DOT=11 +PHRASE=12 +NUMBER=13 +IDENTIFIER=14 +WS=15 +'>'=4 +'<'=5 +'>='=6 +'<='=7 +':'=8 +'('=9 +')'=10 +'.'=11 diff --git a/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.interp b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.interp new file mode 100644 index 000000000000..b9af1477ac89 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.interp @@ -0,0 +1,57 @@ +token literal names: +null +null +null +null +'>' +'<' +'>=' +'<=' +':' +'(' +')' +'.' +null +null +null +null +null + +token symbolic names: +null +OR +AND +NOT +GT +LT +GE +LE +EQ +LPAREN +RPAREN +DOT +PHRASE +NUMBER +DATESTRING +IDENTIFIER +WS + +rule names: +query +orExpression +andExpression +notExpression +primaryExpression +comparisonExpression +fieldExpression +termSearch +groupExpression +groupContent +field +rangeValue +value +comparisonOperator + + +atn: +[4, 1, 16, 102, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43, 8, 2, 10, 2, 12, 2, 46, 9, 2, 1, 3, 1, 3, 1, 3, 3, 3, 51, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 60, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 76, 8, 8, 1, 8, 5, 8, 79, 8, 8, 10, 8, 12, 8, 82, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 3, 9, 88, 8, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 98, 8, 12, 1, 13, 1, 13, 1, 13, 0, 0, 14, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 0, 3, 1, 0, 1, 2, 1, 0, 12, 13, 1, 0, 4, 7, 99, 0, 28, 1, 0, 0, 0, 2, 31, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 50, 1, 0, 0, 0, 8, 59, 1, 0, 0, 0, 10, 61, 1, 0, 0, 0, 12, 65, 1, 0, 0, 0, 14, 69, 1, 0, 0, 0, 16, 71, 1, 0, 0, 0, 18, 87, 1, 0, 0, 0, 20, 89, 1, 0, 0, 0, 22, 91, 1, 0, 0, 0, 24, 97, 1, 0, 0, 0, 26, 99, 1, 0, 0, 0, 28, 29, 3, 2, 1, 0, 29, 30, 5, 0, 0, 1, 30, 1, 1, 0, 0, 0, 31, 36, 3, 4, 2, 0, 32, 33, 5, 1, 0, 0, 33, 35, 3, 4, 2, 0, 34, 32, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 40, 41, 5, 2, 0, 0, 41, 43, 3, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 48, 5, 3, 0, 0, 48, 51, 3, 6, 3, 0, 49, 51, 3, 8, 4, 0, 50, 47, 1, 0, 0, 0, 50, 49, 1, 0, 0, 0, 51, 7, 1, 0, 0, 0, 52, 53, 5, 9, 0, 0, 53, 54, 3, 0, 0, 0, 54, 55, 5, 10, 0, 0, 55, 60, 1, 0, 0, 0, 56, 60, 3, 10, 5, 0, 57, 60, 3, 12, 6, 0, 58, 60, 3, 14, 7, 0, 59, 52, 1, 0, 0, 0, 59, 56, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, 60, 9, 1, 0, 0, 0, 61, 62, 3, 20, 10, 0, 62, 63, 3, 26, 13, 0, 63, 64, 3, 22, 11, 0, 64, 11, 1, 0, 0, 0, 65, 66, 3, 20, 10, 0, 66, 67, 5, 8, 0, 0, 67, 68, 3, 24, 12, 0, 68, 13, 1, 0, 0, 0, 69, 70, 5, 15, 0, 0, 70, 15, 1, 0, 0, 0, 71, 72, 5, 9, 0, 0, 72, 80, 3, 18, 9, 0, 73, 75, 7, 0, 0, 0, 74, 76, 5, 3, 0, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 79, 3, 18, 9, 0, 78, 73, 1, 0, 0, 0, 79, 82, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 83, 1, 0, 0, 0, 82, 80, 1, 0, 0, 0, 83, 84, 5, 10, 0, 0, 84, 17, 1, 0, 0, 0, 85, 88, 3, 16, 8, 0, 86, 88, 3, 14, 7, 0, 87, 85, 1, 0, 0, 0, 87, 86, 1, 0, 0, 0, 88, 19, 1, 0, 0, 0, 89, 90, 5, 15, 0, 0, 90, 21, 1, 0, 0, 0, 91, 92, 7, 1, 0, 0, 92, 23, 1, 0, 0, 0, 93, 98, 5, 12, 0, 0, 94, 98, 5, 13, 0, 0, 95, 98, 3, 14, 7, 0, 96, 98, 3, 16, 8, 0, 97, 93, 1, 0, 0, 0, 97, 94, 1, 0, 0, 0, 97, 95, 1, 0, 0, 0, 97, 96, 1, 0, 0, 0, 98, 25, 1, 0, 0, 0, 99, 100, 7, 2, 0, 0, 100, 27, 1, 0, 0, 0, 8, 36, 44, 50, 59, 75, 80, 87, 97] \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.java b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.java new file mode 100644 index 000000000000..1467436bd0e2 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.java @@ -0,0 +1,868 @@ +// Generated from /Users/paulstn/Documents/opensearch-2.15.0/OpenSearch-Dashboards/src/plugins/data/public/antlr/dql/grammar/DQLParser.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class DQLParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, NOT=3, GT=4, LT=5, GE=6, LE=7, EQ=8, LPAREN=9, RPAREN=10, + DOT=11, PHRASE=12, NUMBER=13, DATESTRING=14, IDENTIFIER=15, WS=16; + public static final int + RULE_query = 0, RULE_orExpression = 1, RULE_andExpression = 2, RULE_notExpression = 3, + RULE_primaryExpression = 4, RULE_comparisonExpression = 5, RULE_fieldExpression = 6, + RULE_termSearch = 7, RULE_groupExpression = 8, RULE_groupContent = 9, + RULE_field = 10, RULE_rangeValue = 11, RULE_value = 12, RULE_comparisonOperator = 13; + private static String[] makeRuleNames() { + return new String[] { + "query", "orExpression", "andExpression", "notExpression", "primaryExpression", + "comparisonExpression", "fieldExpression", "termSearch", "groupExpression", + "groupContent", "field", "rangeValue", "value", "comparisonOperator" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, null, null, null, "'>'", "'<'", "'>='", "'<='", "':'", "'('", "')'", + "'.'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "OR", "AND", "NOT", "GT", "LT", "GE", "LE", "EQ", "LPAREN", "RPAREN", + "DOT", "PHRASE", "NUMBER", "DATESTRING", "IDENTIFIER", "WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "DQLParser.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public DQLParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class QueryContext extends ParserRuleContext { + public OrExpressionContext orExpression() { + return getRuleContext(OrExpressionContext.class,0); + } + public TerminalNode EOF() { return getToken(DQLParser.EOF, 0); } + public QueryContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_query; } + } + + public final QueryContext query() throws RecognitionException { + QueryContext _localctx = new QueryContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_query); + try { + enterOuterAlt(_localctx, 1); + { + setState(28); + orExpression(); + setState(29); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class OrExpressionContext extends ParserRuleContext { + public List andExpression() { + return getRuleContexts(AndExpressionContext.class); + } + public AndExpressionContext andExpression(int i) { + return getRuleContext(AndExpressionContext.class,i); + } + public List OR() { return getTokens(DQLParser.OR); } + public TerminalNode OR(int i) { + return getToken(DQLParser.OR, i); + } + public OrExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_orExpression; } + } + + public final OrExpressionContext orExpression() throws RecognitionException { + OrExpressionContext _localctx = new OrExpressionContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_orExpression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(31); + andExpression(); + setState(36); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==OR) { + { + { + setState(32); + match(OR); + setState(33); + andExpression(); + } + } + setState(38); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class AndExpressionContext extends ParserRuleContext { + public List notExpression() { + return getRuleContexts(NotExpressionContext.class); + } + public NotExpressionContext notExpression(int i) { + return getRuleContext(NotExpressionContext.class,i); + } + public List AND() { return getTokens(DQLParser.AND); } + public TerminalNode AND(int i) { + return getToken(DQLParser.AND, i); + } + public AndExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_andExpression; } + } + + public final AndExpressionContext andExpression() throws RecognitionException { + AndExpressionContext _localctx = new AndExpressionContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_andExpression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(39); + notExpression(); + setState(44); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==AND) { + { + { + setState(40); + match(AND); + setState(41); + notExpression(); + } + } + setState(46); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NotExpressionContext extends ParserRuleContext { + public TerminalNode NOT() { return getToken(DQLParser.NOT, 0); } + public NotExpressionContext notExpression() { + return getRuleContext(NotExpressionContext.class,0); + } + public PrimaryExpressionContext primaryExpression() { + return getRuleContext(PrimaryExpressionContext.class,0); + } + public NotExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_notExpression; } + } + + public final NotExpressionContext notExpression() throws RecognitionException { + NotExpressionContext _localctx = new NotExpressionContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_notExpression); + try { + setState(50); + _errHandler.sync(this); + switch (_input.LA(1)) { + case NOT: + enterOuterAlt(_localctx, 1); + { + setState(47); + match(NOT); + setState(48); + notExpression(); + } + break; + case LPAREN: + case IDENTIFIER: + enterOuterAlt(_localctx, 2); + { + setState(49); + primaryExpression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrimaryExpressionContext extends ParserRuleContext { + public TerminalNode LPAREN() { return getToken(DQLParser.LPAREN, 0); } + public QueryContext query() { + return getRuleContext(QueryContext.class,0); + } + public TerminalNode RPAREN() { return getToken(DQLParser.RPAREN, 0); } + public ComparisonExpressionContext comparisonExpression() { + return getRuleContext(ComparisonExpressionContext.class,0); + } + public FieldExpressionContext fieldExpression() { + return getRuleContext(FieldExpressionContext.class,0); + } + public TermSearchContext termSearch() { + return getRuleContext(TermSearchContext.class,0); + } + public PrimaryExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_primaryExpression; } + } + + public final PrimaryExpressionContext primaryExpression() throws RecognitionException { + PrimaryExpressionContext _localctx = new PrimaryExpressionContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_primaryExpression); + try { + setState(59); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(52); + match(LPAREN); + setState(53); + query(); + setState(54); + match(RPAREN); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(56); + comparisonExpression(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(57); + fieldExpression(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(58); + termSearch(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ComparisonExpressionContext extends ParserRuleContext { + public FieldContext field() { + return getRuleContext(FieldContext.class,0); + } + public ComparisonOperatorContext comparisonOperator() { + return getRuleContext(ComparisonOperatorContext.class,0); + } + public RangeValueContext rangeValue() { + return getRuleContext(RangeValueContext.class,0); + } + public ComparisonExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_comparisonExpression; } + } + + public final ComparisonExpressionContext comparisonExpression() throws RecognitionException { + ComparisonExpressionContext _localctx = new ComparisonExpressionContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_comparisonExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(61); + field(); + setState(62); + comparisonOperator(); + setState(63); + rangeValue(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FieldExpressionContext extends ParserRuleContext { + public FieldContext field() { + return getRuleContext(FieldContext.class,0); + } + public TerminalNode EQ() { return getToken(DQLParser.EQ, 0); } + public ValueContext value() { + return getRuleContext(ValueContext.class,0); + } + public FieldExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_fieldExpression; } + } + + public final FieldExpressionContext fieldExpression() throws RecognitionException { + FieldExpressionContext _localctx = new FieldExpressionContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_fieldExpression); + try { + enterOuterAlt(_localctx, 1); + { + setState(65); + field(); + setState(66); + match(EQ); + setState(67); + value(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TermSearchContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { return getToken(DQLParser.IDENTIFIER, 0); } + public TermSearchContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_termSearch; } + } + + public final TermSearchContext termSearch() throws RecognitionException { + TermSearchContext _localctx = new TermSearchContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_termSearch); + try { + enterOuterAlt(_localctx, 1); + { + setState(69); + match(IDENTIFIER); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class GroupExpressionContext extends ParserRuleContext { + public TerminalNode LPAREN() { return getToken(DQLParser.LPAREN, 0); } + public List groupContent() { + return getRuleContexts(GroupContentContext.class); + } + public GroupContentContext groupContent(int i) { + return getRuleContext(GroupContentContext.class,i); + } + public TerminalNode RPAREN() { return getToken(DQLParser.RPAREN, 0); } + public List OR() { return getTokens(DQLParser.OR); } + public TerminalNode OR(int i) { + return getToken(DQLParser.OR, i); + } + public List AND() { return getTokens(DQLParser.AND); } + public TerminalNode AND(int i) { + return getToken(DQLParser.AND, i); + } + public List NOT() { return getTokens(DQLParser.NOT); } + public TerminalNode NOT(int i) { + return getToken(DQLParser.NOT, i); + } + public GroupExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_groupExpression; } + } + + public final GroupExpressionContext groupExpression() throws RecognitionException { + GroupExpressionContext _localctx = new GroupExpressionContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_groupExpression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(71); + match(LPAREN); + setState(72); + groupContent(); + setState(80); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==OR || _la==AND) { + { + { + setState(73); + _la = _input.LA(1); + if ( !(_la==OR || _la==AND) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + { + setState(75); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==NOT) { + { + setState(74); + match(NOT); + } + } + + } + setState(77); + groupContent(); + } + } + setState(82); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(83); + match(RPAREN); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class GroupContentContext extends ParserRuleContext { + public GroupExpressionContext groupExpression() { + return getRuleContext(GroupExpressionContext.class,0); + } + public TermSearchContext termSearch() { + return getRuleContext(TermSearchContext.class,0); + } + public GroupContentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_groupContent; } + } + + public final GroupContentContext groupContent() throws RecognitionException { + GroupContentContext _localctx = new GroupContentContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_groupContent); + try { + setState(87); + _errHandler.sync(this); + switch (_input.LA(1)) { + case LPAREN: + enterOuterAlt(_localctx, 1); + { + setState(85); + groupExpression(); + } + break; + case IDENTIFIER: + enterOuterAlt(_localctx, 2); + { + setState(86); + termSearch(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FieldContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { return getToken(DQLParser.IDENTIFIER, 0); } + public FieldContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_field; } + } + + public final FieldContext field() throws RecognitionException { + FieldContext _localctx = new FieldContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_field); + try { + enterOuterAlt(_localctx, 1); + { + setState(89); + match(IDENTIFIER); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class RangeValueContext extends ParserRuleContext { + public TerminalNode NUMBER() { return getToken(DQLParser.NUMBER, 0); } + public TerminalNode PHRASE() { return getToken(DQLParser.PHRASE, 0); } + public RangeValueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_rangeValue; } + } + + public final RangeValueContext rangeValue() throws RecognitionException { + RangeValueContext _localctx = new RangeValueContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_rangeValue); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(91); + _la = _input.LA(1); + if ( !(_la==PHRASE || _la==NUMBER) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueContext extends ParserRuleContext { + public TerminalNode PHRASE() { return getToken(DQLParser.PHRASE, 0); } + public TerminalNode NUMBER() { return getToken(DQLParser.NUMBER, 0); } + public TermSearchContext termSearch() { + return getRuleContext(TermSearchContext.class,0); + } + public GroupExpressionContext groupExpression() { + return getRuleContext(GroupExpressionContext.class,0); + } + public ValueContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_value; } + } + + public final ValueContext value() throws RecognitionException { + ValueContext _localctx = new ValueContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_value); + try { + setState(97); + _errHandler.sync(this); + switch (_input.LA(1)) { + case PHRASE: + enterOuterAlt(_localctx, 1); + { + setState(93); + match(PHRASE); + } + break; + case NUMBER: + enterOuterAlt(_localctx, 2); + { + setState(94); + match(NUMBER); + } + break; + case IDENTIFIER: + enterOuterAlt(_localctx, 3); + { + setState(95); + termSearch(); + } + break; + case LPAREN: + enterOuterAlt(_localctx, 4); + { + setState(96); + groupExpression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ComparisonOperatorContext extends ParserRuleContext { + public TerminalNode GT() { return getToken(DQLParser.GT, 0); } + public TerminalNode LT() { return getToken(DQLParser.LT, 0); } + public TerminalNode GE() { return getToken(DQLParser.GE, 0); } + public TerminalNode LE() { return getToken(DQLParser.LE, 0); } + public ComparisonOperatorContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_comparisonOperator; } + } + + public final ComparisonOperatorContext comparisonOperator() throws RecognitionException { + ComparisonOperatorContext _localctx = new ComparisonOperatorContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_comparisonOperator); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(99); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 240L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\u0004\u0001\u0010f\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ + "\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ + "\f\u0007\f\u0002\r\u0007\r\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0005\u0001#\b\u0001\n\u0001\f\u0001&\t\u0001"+ + "\u0001\u0002\u0001\u0002\u0001\u0002\u0005\u0002+\b\u0002\n\u0002\f\u0002"+ + ".\t\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0003\u00033\b\u0003\u0001"+ + "\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+ + "\u0004\u0003\u0004<\b\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0001"+ + "\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001"+ + "\u0007\u0001\b\u0001\b\u0001\b\u0001\b\u0003\bL\b\b\u0001\b\u0005\bO\b"+ + "\b\n\b\f\bR\t\b\u0001\b\u0001\b\u0001\t\u0001\t\u0003\tX\b\t\u0001\n\u0001"+ + "\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0003\fb\b"+ + "\f\u0001\r\u0001\r\u0001\r\u0000\u0000\u000e\u0000\u0002\u0004\u0006\b"+ + "\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a\u0000\u0003\u0001\u0000"+ + "\u0001\u0002\u0001\u0000\f\r\u0001\u0000\u0004\u0007c\u0000\u001c\u0001"+ + "\u0000\u0000\u0000\u0002\u001f\u0001\u0000\u0000\u0000\u0004\'\u0001\u0000"+ + "\u0000\u0000\u00062\u0001\u0000\u0000\u0000\b;\u0001\u0000\u0000\u0000"+ + "\n=\u0001\u0000\u0000\u0000\fA\u0001\u0000\u0000\u0000\u000eE\u0001\u0000"+ + "\u0000\u0000\u0010G\u0001\u0000\u0000\u0000\u0012W\u0001\u0000\u0000\u0000"+ + "\u0014Y\u0001\u0000\u0000\u0000\u0016[\u0001\u0000\u0000\u0000\u0018a"+ + "\u0001\u0000\u0000\u0000\u001ac\u0001\u0000\u0000\u0000\u001c\u001d\u0003"+ + "\u0002\u0001\u0000\u001d\u001e\u0005\u0000\u0000\u0001\u001e\u0001\u0001"+ + "\u0000\u0000\u0000\u001f$\u0003\u0004\u0002\u0000 !\u0005\u0001\u0000"+ + "\u0000!#\u0003\u0004\u0002\u0000\" \u0001\u0000\u0000\u0000#&\u0001\u0000"+ + "\u0000\u0000$\"\u0001\u0000\u0000\u0000$%\u0001\u0000\u0000\u0000%\u0003"+ + "\u0001\u0000\u0000\u0000&$\u0001\u0000\u0000\u0000\',\u0003\u0006\u0003"+ + "\u0000()\u0005\u0002\u0000\u0000)+\u0003\u0006\u0003\u0000*(\u0001\u0000"+ + "\u0000\u0000+.\u0001\u0000\u0000\u0000,*\u0001\u0000\u0000\u0000,-\u0001"+ + "\u0000\u0000\u0000-\u0005\u0001\u0000\u0000\u0000.,\u0001\u0000\u0000"+ + "\u0000/0\u0005\u0003\u0000\u000003\u0003\u0006\u0003\u000013\u0003\b\u0004"+ + "\u00002/\u0001\u0000\u0000\u000021\u0001\u0000\u0000\u00003\u0007\u0001"+ + "\u0000\u0000\u000045\u0005\t\u0000\u000056\u0003\u0000\u0000\u000067\u0005"+ + "\n\u0000\u00007<\u0001\u0000\u0000\u00008<\u0003\n\u0005\u00009<\u0003"+ + "\f\u0006\u0000:<\u0003\u000e\u0007\u0000;4\u0001\u0000\u0000\u0000;8\u0001"+ + "\u0000\u0000\u0000;9\u0001\u0000\u0000\u0000;:\u0001\u0000\u0000\u0000"+ + "<\t\u0001\u0000\u0000\u0000=>\u0003\u0014\n\u0000>?\u0003\u001a\r\u0000"+ + "?@\u0003\u0016\u000b\u0000@\u000b\u0001\u0000\u0000\u0000AB\u0003\u0014"+ + "\n\u0000BC\u0005\b\u0000\u0000CD\u0003\u0018\f\u0000D\r\u0001\u0000\u0000"+ + "\u0000EF\u0005\u000f\u0000\u0000F\u000f\u0001\u0000\u0000\u0000GH\u0005"+ + "\t\u0000\u0000HP\u0003\u0012\t\u0000IK\u0007\u0000\u0000\u0000JL\u0005"+ + "\u0003\u0000\u0000KJ\u0001\u0000\u0000\u0000KL\u0001\u0000\u0000\u0000"+ + "LM\u0001\u0000\u0000\u0000MO\u0003\u0012\t\u0000NI\u0001\u0000\u0000\u0000"+ + "OR\u0001\u0000\u0000\u0000PN\u0001\u0000\u0000\u0000PQ\u0001\u0000\u0000"+ + "\u0000QS\u0001\u0000\u0000\u0000RP\u0001\u0000\u0000\u0000ST\u0005\n\u0000"+ + "\u0000T\u0011\u0001\u0000\u0000\u0000UX\u0003\u0010\b\u0000VX\u0003\u000e"+ + "\u0007\u0000WU\u0001\u0000\u0000\u0000WV\u0001\u0000\u0000\u0000X\u0013"+ + "\u0001\u0000\u0000\u0000YZ\u0005\u000f\u0000\u0000Z\u0015\u0001\u0000"+ + "\u0000\u0000[\\\u0007\u0001\u0000\u0000\\\u0017\u0001\u0000\u0000\u0000"+ + "]b\u0005\f\u0000\u0000^b\u0005\r\u0000\u0000_b\u0003\u000e\u0007\u0000"+ + "`b\u0003\u0010\b\u0000a]\u0001\u0000\u0000\u0000a^\u0001\u0000\u0000\u0000"+ + "a_\u0001\u0000\u0000\u0000a`\u0001\u0000\u0000\u0000b\u0019\u0001\u0000"+ + "\u0000\u0000cd\u0007\u0002\u0000\u0000d\u001b\u0001\u0000\u0000\u0000"+ + "\b$,2;KPWa"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.tokens b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.tokens new file mode 100644 index 000000000000..00fa5d537f7b --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/.antlr/DQLParser.tokens @@ -0,0 +1,24 @@ +OR=1 +AND=2 +NOT=3 +GT=4 +LT=5 +GE=6 +LE=7 +EQ=8 +LPAREN=9 +RPAREN=10 +DOT=11 +PHRASE=12 +NUMBER=13 +DATESTRING=14 +IDENTIFIER=15 +WS=16 +'>'=4 +'<'=5 +'>='=6 +'<='=7 +':'=8 +'('=9 +')'=10 +'.'=11 diff --git a/src/plugins/data/public/antlr/dql/grammar/DQLLexer.g4 b/src/plugins/data/public/antlr/dql/grammar/DQLLexer.g4 new file mode 100644 index 000000000000..65af7662e999 --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/DQLLexer.g4 @@ -0,0 +1,26 @@ +lexer grammar DQLLexer; + +// Keywords +OR: [oO] [rR]; +AND: [aA] [nN] [dD]; +NOT: [nN] [oO] [tT]; + +// Operators +GT: '>'; +LT: '<'; +GE: '>='; +LE: '<='; +EQ: ':'; + +// Delimiters +LPAREN: '('; +RPAREN: ')'; +DOT: '.'; + +// Literals +PHRASE: '"' (~["\\])* '"'; +NUMBER: '-'? [0-9]+ ('.' [0-9]+)?; +IDENTIFIER: [a-zA-Z_*][a-zA-Z0-9_*]*; + +// SKIP +WS: [ \t\r\n]+ -> channel(HIDDEN); \ No newline at end of file diff --git a/src/plugins/data/public/antlr/dql/grammar/DQLParser.g4 b/src/plugins/data/public/antlr/dql/grammar/DQLParser.g4 new file mode 100644 index 000000000000..6a94185e28cf --- /dev/null +++ b/src/plugins/data/public/antlr/dql/grammar/DQLParser.g4 @@ -0,0 +1,25 @@ +parser grammar DQLParser; + +options { + tokenVocab = DQLLexer; +} + +query: orExpression EOF; +orExpression: andExpression (OR andExpression)*; +andExpression: notExpression (AND notExpression)*; +notExpression: NOT notExpression | primaryExpression; +primaryExpression: + LPAREN query RPAREN + | comparisonExpression + | fieldExpression + | termSearch; +comparisonExpression: field comparisonOperator rangeValue; +fieldExpression: field EQ value; +termSearch: IDENTIFIER; +groupExpression: + LPAREN groupContent ((OR | AND) (NOT?) groupContent)* RPAREN; +groupContent: groupExpression | termSearch; +field: IDENTIFIER; +rangeValue: NUMBER | PHRASE; +value: PHRASE | NUMBER | termSearch | groupExpression; +comparisonOperator: GT | LT | GE | LE; \ No newline at end of file diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts index 3d4d4ebb8f7a..2b149ad0cc7e 100644 --- a/src/plugins/data/public/plugin.ts +++ b/src/plugins/data/public/plugin.ts @@ -94,6 +94,8 @@ import { registerDefaultDataSource } from './data_sources/register_default_datas import { DefaultDslDataSource } from './data_sources/default_datasource'; import { DEFAULT_DATA_SOURCE_TYPE } from './data_sources/constants'; import { getSuggestions as getSQLSuggestions } from './antlr/opensearch_sql/code_completion'; +import { getSuggestions as getPPLSuggestions } from './antlr/opensearch_ppl/code_completion'; +import { getSuggestions as getDQLSuggestions } from './antlr/dql/code_completion'; declare module '../../ui_actions/public' { export interface ActionContextMapping { @@ -167,7 +169,9 @@ export class DataPublicPlugin const uiService = this.uiService.setup(core, {}); const ac = this.autocomplete.setup(core); - ac.addQuerySuggestionProvider('SQL', getSQLSuggestions); + ac.addQuerySuggestionProvider('PPL', getPPLSuggestions); + ac.addQuerySuggestionProvider('SQL', getDQLSuggestions); + ac.addQuerySuggestionProvider('kuery', getDQLSuggestions); return { // TODO: MQL diff --git a/src/plugins/data/public/ui/query_editor/query_editor.tsx b/src/plugins/data/public/ui/query_editor/query_editor.tsx index 7fd4929b5c94..744d1e1bb135 100644 --- a/src/plugins/data/public/ui/query_editor/query_editor.tsx +++ b/src/plugins/data/public/ui/query_editor/query_editor.tsx @@ -21,7 +21,7 @@ import { QueryEditorBtnCollapse } from './query_editor_btn_collapse'; import { SimpleDataSet } from '../../../common'; import { createDQLEditor, createDefaultEditor } from './editors'; -const LANGUAGE_ID = 'SQL'; +const LANGUAGE_ID = 'kuery'; monaco.languages.register({ id: LANGUAGE_ID }); export interface QueryEditorProps { @@ -230,7 +230,6 @@ export default class QueryEditorUI extends Component { } this.initPersistedLog(); - // this.fetchIndexPatterns().then(this.updateSuggestions); } public componentDidUpdate(prevProps: Props) {