diff --git a/frontend/src/components/QueryBuilderV2/QueryBuilderV2.tsx b/frontend/src/components/QueryBuilderV2/QueryBuilderV2.tsx index 9c1f3e277f0b..0dda2ffec93b 100644 --- a/frontend/src/components/QueryBuilderV2/QueryBuilderV2.tsx +++ b/frontend/src/components/QueryBuilderV2/QueryBuilderV2.tsx @@ -1,5 +1,11 @@ +import QueryWhereClause from './WhereClause/WhereClause'; + function QueryBuilderV2(): JSX.Element { - return
QueryBuilderV2
; + return ( +
+ +
+ ); } export default QueryBuilderV2; diff --git a/frontend/src/components/QueryBuilderV2/WhereClause/WhereClause.styles.scss b/frontend/src/components/QueryBuilderV2/WhereClause/WhereClause.styles.scss new file mode 100644 index 000000000000..c3e58d70861e --- /dev/null +++ b/frontend/src/components/QueryBuilderV2/WhereClause/WhereClause.styles.scss @@ -0,0 +1,88 @@ +.where-clause { + width: 100%; + border: 1px solid #d9d9d9; + border-radius: 2px; + background-color: #fff; + + &-header { + padding: 8px 12px; + border-bottom: 1px solid #f0f0f0; + } + + &-content { + padding: 12px; + + .query-input { + width: 100%; + margin-bottom: 8px; + font-family: monospace; + + &.error { + border-color: #ff4d4f; + } + + &.valid { + border-color: #52c41a; + } + } + + .error-alert, + .success-alert { + margin-bottom: 8px; + } + + .query-examples { + margin-top: 8px; + + ul { + margin: 8px 0; + padding-left: 0; + list-style-type: none; + + li { + margin: 4px 0; + } + } + } + } +} + +.condition-builder { + display: flex; + align-items: center; + margin-bottom: 16px; +} + +.conditions-list { + display: flex; + flex-direction: column; + gap: 8px; +} + +.condition-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 8px; + background: #f5f5f5; + color: #000; + border-radius: 4px; +} + +.where-clause-content { + .query-examples { + ul { + li { + margin: 4px 0; + padding-left: 0; + list-style-type: none; + + color: #000; + + code { + color: #000; + } + } + } + } +} diff --git a/frontend/src/components/QueryBuilderV2/WhereClause/WhereClause.tsx b/frontend/src/components/QueryBuilderV2/WhereClause/WhereClause.tsx new file mode 100644 index 000000000000..14a2c9cae249 --- /dev/null +++ b/frontend/src/components/QueryBuilderV2/WhereClause/WhereClause.tsx @@ -0,0 +1,138 @@ +/* eslint-disable no-nested-ternary */ +import './WhereClause.styles.scss'; + +import { Input, Typography } from 'antd'; +import { useCallback, useEffect, useState } from 'react'; +import { IQueryContext, IValidationResult } from 'types/antlrQueryTypes'; +import { getQueryContextAtCursor, validateQuery } from 'utils/antlrQueryUtils'; + +const { Text } = Typography; + +function QueryWhereClause(): JSX.Element { + const [query, setQuery] = useState(''); + const [cursorPosition, setCursorPosition] = useState(0); + const [isLoading, setIsLoading] = useState(false); + const [queryContext, setQueryContext] = useState(null); + const [validation, setValidation] = useState({ + isValid: false, + message: '', + errors: [], + }); + + console.log({ + cursorPosition, + queryContext, + validation, + isLoading, + }); + + const handleQueryChange = useCallback(async (newQuery: string) => { + setIsLoading(true); + setQuery(newQuery); + + try { + const validationResponse = validateQuery(newQuery); + setValidation(validationResponse); + } catch (error) { + setValidation({ + isValid: false, + message: 'Failed to process query', + errors: [error instanceof Error ? error.message : 'Unknown error'], + }); + } finally { + setIsLoading(false); + } + }, []); + + useEffect(() => { + if (query) { + const context = getQueryContextAtCursor(query, cursorPosition); + setQueryContext(context as IQueryContext); + } + }, [query, cursorPosition]); + + const handleChange = (e: React.ChangeEvent): void => { + const { value, selectionStart } = e.target; + setQuery(value); + setCursorPosition(selectionStart || 0); + handleQueryChange(value); + }; + + const handleCursorMove = (e: React.SyntheticEvent): void => { + const { selectionStart } = e.currentTarget; + setCursorPosition(selectionStart || 0); + }; + + return ( +
+
+ Where +
+
+ + + {queryContext && ( +
+

Current Context

+
+

+ Token: {queryContext.currentToken} +

+

+ Type: {queryContext.tokenType} +

+

+ Context:{' '} + {queryContext.isInValue + ? 'Value' + : queryContext.isInKey + ? 'Key' + : queryContext.isInOperator + ? 'Operator' + : queryContext.isInFunction + ? 'Function' + : 'Unknown'} +

+
+
+ )} + +
+ Examples: +
    +
  • + status = 'error' +
  • +
  • + + service = 'frontend' AND level = 'error' + +
  • +
  • + message LIKE '%timeout%' +
  • +
  • + duration {'>'} 1000 +
  • +
  • + tags IN ['prod', 'frontend'] +
  • +
  • + + NOT (status = 'error' OR level = 'error') + +
  • +
+
+
+
+ ); +} + +export default QueryWhereClause; diff --git a/frontend/src/container/Home/Home2.tsx b/frontend/src/container/Home/Home2.tsx new file mode 100644 index 000000000000..cc76425678d4 --- /dev/null +++ b/frontend/src/container/Home/Home2.tsx @@ -0,0 +1,11 @@ +import QueryBuilderV2 from 'components/QueryBuilderV2/QueryBuilderV2'; + +function Home2(): JSX.Element { + return ( +
+ +
+ ); +} + +export default Home2; diff --git a/frontend/src/pages/HomePage/HomePage.tsx b/frontend/src/pages/HomePage/HomePage.tsx index e3c1ac623f28..0dcf58fbbf87 100644 --- a/frontend/src/pages/HomePage/HomePage.tsx +++ b/frontend/src/pages/HomePage/HomePage.tsx @@ -1,7 +1,7 @@ -import Home from 'container/Home'; +import Home2 from 'container/Home/Home2'; function HomePage(): JSX.Element { - return ; + return ; } export default HomePage; diff --git a/frontend/src/query-grammar/.antlr/FilterQuery.interp b/frontend/src/query-grammar/.antlr/FilterQuery.interp new file mode 100644 index 000000000000..114118d40ad1 --- /dev/null +++ b/frontend/src/query-grammar/.antlr/FilterQuery.interp @@ -0,0 +1,104 @@ +token literal names: +null +'(' +')' +'[' +']' +',' +null +'!=' +'<>' +'<' +'<=' +'>' +'>=' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +LPAREN +RPAREN +LBRACK +RBRACK +COMMA +EQUALS +NOT_EQUALS +NEQ +LT +LE +GT +GE +LIKE +NOT_LIKE +ILIKE +NOT_ILIKE +BETWEEN +NOT_BETWEEN +EXISTS +NOT_EXISTS +REGEXP +NOT_REGEXP +CONTAINS +NOT_CONTAINS +IN +NOT_IN +NOT +AND +OR +HAS +HASANY +HASALL +HASNONE +BOOL +NUMBER +QUOTED_TEXT +KEY +WS + +rule names: +query +expression +orExpression +andExpression +unaryExpression +primary +comparison +inClause +notInClause +valueList +fullText +functionCall +functionParamList +functionParam +array +value +key + + +atn: +[4, 1, 38, 213, 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, 2, 15, 7, 15, 2, 16, 7, 16, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 39, 8, 0, 10, 0, 12, 0, 42, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 5, 2, 51, 8, 2, 10, 2, 12, 2, 54, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 60, 8, 3, 10, 3, 12, 3, 63, 9, 3, 1, 4, 3, 4, 66, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 77, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 151, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 163, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 175, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 180, 8, 9, 10, 9, 12, 9, 183, 9, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 195, 8, 12, 10, 12, 12, 12, 198, 9, 12, 1, 13, 1, 13, 1, 13, 3, 13, 203, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6, 1, 0, 28, 29, 1, 0, 7, 8, 2, 0, 13, 13, 15, 15, 2, 0, 14, 14, 16, 16, 1, 0, 30, 33, 1, 0, 34, 36, 227, 0, 34, 1, 0, 0, 0, 2, 45, 1, 0, 0, 0, 4, 47, 1, 0, 0, 0, 6, 55, 1, 0, 0, 0, 8, 65, 1, 0, 0, 0, 10, 76, 1, 0, 0, 0, 12, 150, 1, 0, 0, 0, 14, 162, 1, 0, 0, 0, 16, 174, 1, 0, 0, 0, 18, 176, 1, 0, 0, 0, 20, 184, 1, 0, 0, 0, 22, 186, 1, 0, 0, 0, 24, 191, 1, 0, 0, 0, 26, 202, 1, 0, 0, 0, 28, 204, 1, 0, 0, 0, 30, 208, 1, 0, 0, 0, 32, 210, 1, 0, 0, 0, 34, 40, 3, 2, 1, 0, 35, 36, 7, 0, 0, 0, 36, 39, 3, 2, 1, 0, 37, 39, 3, 2, 1, 0, 38, 35, 1, 0, 0, 0, 38, 37, 1, 0, 0, 0, 39, 42, 1, 0, 0, 0, 40, 38, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 43, 1, 0, 0, 0, 42, 40, 1, 0, 0, 0, 43, 44, 5, 0, 0, 1, 44, 1, 1, 0, 0, 0, 45, 46, 3, 4, 2, 0, 46, 3, 1, 0, 0, 0, 47, 52, 3, 6, 3, 0, 48, 49, 5, 29, 0, 0, 49, 51, 3, 6, 3, 0, 50, 48, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 5, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 61, 3, 8, 4, 0, 56, 57, 5, 28, 0, 0, 57, 60, 3, 8, 4, 0, 58, 60, 3, 8, 4, 0, 59, 56, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, 60, 63, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 61, 62, 1, 0, 0, 0, 62, 7, 1, 0, 0, 0, 63, 61, 1, 0, 0, 0, 64, 66, 5, 27, 0, 0, 65, 64, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 68, 3, 10, 5, 0, 68, 9, 1, 0, 0, 0, 69, 70, 5, 1, 0, 0, 70, 71, 3, 4, 2, 0, 71, 72, 5, 2, 0, 0, 72, 77, 1, 0, 0, 0, 73, 77, 3, 12, 6, 0, 74, 77, 3, 22, 11, 0, 75, 77, 3, 20, 10, 0, 76, 69, 1, 0, 0, 0, 76, 73, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 75, 1, 0, 0, 0, 77, 11, 1, 0, 0, 0, 78, 79, 3, 32, 16, 0, 79, 80, 5, 6, 0, 0, 80, 81, 3, 30, 15, 0, 81, 151, 1, 0, 0, 0, 82, 83, 3, 32, 16, 0, 83, 84, 7, 1, 0, 0, 84, 85, 3, 30, 15, 0, 85, 151, 1, 0, 0, 0, 86, 87, 3, 32, 16, 0, 87, 88, 5, 9, 0, 0, 88, 89, 3, 30, 15, 0, 89, 151, 1, 0, 0, 0, 90, 91, 3, 32, 16, 0, 91, 92, 5, 10, 0, 0, 92, 93, 3, 30, 15, 0, 93, 151, 1, 0, 0, 0, 94, 95, 3, 32, 16, 0, 95, 96, 5, 11, 0, 0, 96, 97, 3, 30, 15, 0, 97, 151, 1, 0, 0, 0, 98, 99, 3, 32, 16, 0, 99, 100, 5, 12, 0, 0, 100, 101, 3, 30, 15, 0, 101, 151, 1, 0, 0, 0, 102, 103, 3, 32, 16, 0, 103, 104, 7, 2, 0, 0, 104, 105, 3, 30, 15, 0, 105, 151, 1, 0, 0, 0, 106, 107, 3, 32, 16, 0, 107, 108, 7, 3, 0, 0, 108, 109, 3, 30, 15, 0, 109, 151, 1, 0, 0, 0, 110, 111, 3, 32, 16, 0, 111, 112, 5, 17, 0, 0, 112, 113, 3, 30, 15, 0, 113, 114, 5, 28, 0, 0, 114, 115, 3, 30, 15, 0, 115, 151, 1, 0, 0, 0, 116, 117, 3, 32, 16, 0, 117, 118, 5, 18, 0, 0, 118, 119, 3, 30, 15, 0, 119, 120, 5, 28, 0, 0, 120, 121, 3, 30, 15, 0, 121, 151, 1, 0, 0, 0, 122, 123, 3, 32, 16, 0, 123, 124, 3, 14, 7, 0, 124, 151, 1, 0, 0, 0, 125, 126, 3, 32, 16, 0, 126, 127, 3, 16, 8, 0, 127, 151, 1, 0, 0, 0, 128, 129, 3, 32, 16, 0, 129, 130, 5, 19, 0, 0, 130, 151, 1, 0, 0, 0, 131, 132, 3, 32, 16, 0, 132, 133, 5, 20, 0, 0, 133, 151, 1, 0, 0, 0, 134, 135, 3, 32, 16, 0, 135, 136, 5, 21, 0, 0, 136, 137, 3, 30, 15, 0, 137, 151, 1, 0, 0, 0, 138, 139, 3, 32, 16, 0, 139, 140, 5, 22, 0, 0, 140, 141, 3, 30, 15, 0, 141, 151, 1, 0, 0, 0, 142, 143, 3, 32, 16, 0, 143, 144, 5, 23, 0, 0, 144, 145, 3, 30, 15, 0, 145, 151, 1, 0, 0, 0, 146, 147, 3, 32, 16, 0, 147, 148, 5, 24, 0, 0, 148, 149, 3, 30, 15, 0, 149, 151, 1, 0, 0, 0, 150, 78, 1, 0, 0, 0, 150, 82, 1, 0, 0, 0, 150, 86, 1, 0, 0, 0, 150, 90, 1, 0, 0, 0, 150, 94, 1, 0, 0, 0, 150, 98, 1, 0, 0, 0, 150, 102, 1, 0, 0, 0, 150, 106, 1, 0, 0, 0, 150, 110, 1, 0, 0, 0, 150, 116, 1, 0, 0, 0, 150, 122, 1, 0, 0, 0, 150, 125, 1, 0, 0, 0, 150, 128, 1, 0, 0, 0, 150, 131, 1, 0, 0, 0, 150, 134, 1, 0, 0, 0, 150, 138, 1, 0, 0, 0, 150, 142, 1, 0, 0, 0, 150, 146, 1, 0, 0, 0, 151, 13, 1, 0, 0, 0, 152, 153, 5, 25, 0, 0, 153, 154, 5, 1, 0, 0, 154, 155, 3, 18, 9, 0, 155, 156, 5, 2, 0, 0, 156, 163, 1, 0, 0, 0, 157, 158, 5, 25, 0, 0, 158, 159, 5, 3, 0, 0, 159, 160, 3, 18, 9, 0, 160, 161, 5, 4, 0, 0, 161, 163, 1, 0, 0, 0, 162, 152, 1, 0, 0, 0, 162, 157, 1, 0, 0, 0, 163, 15, 1, 0, 0, 0, 164, 165, 5, 26, 0, 0, 165, 166, 5, 1, 0, 0, 166, 167, 3, 18, 9, 0, 167, 168, 5, 2, 0, 0, 168, 175, 1, 0, 0, 0, 169, 170, 5, 26, 0, 0, 170, 171, 5, 3, 0, 0, 171, 172, 3, 18, 9, 0, 172, 173, 5, 4, 0, 0, 173, 175, 1, 0, 0, 0, 174, 164, 1, 0, 0, 0, 174, 169, 1, 0, 0, 0, 175, 17, 1, 0, 0, 0, 176, 181, 3, 30, 15, 0, 177, 178, 5, 5, 0, 0, 178, 180, 3, 30, 15, 0, 179, 177, 1, 0, 0, 0, 180, 183, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 19, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 185, 5, 36, 0, 0, 185, 21, 1, 0, 0, 0, 186, 187, 7, 4, 0, 0, 187, 188, 5, 1, 0, 0, 188, 189, 3, 24, 12, 0, 189, 190, 5, 2, 0, 0, 190, 23, 1, 0, 0, 0, 191, 196, 3, 26, 13, 0, 192, 193, 5, 5, 0, 0, 193, 195, 3, 26, 13, 0, 194, 192, 1, 0, 0, 0, 195, 198, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 25, 1, 0, 0, 0, 198, 196, 1, 0, 0, 0, 199, 203, 3, 32, 16, 0, 200, 203, 3, 30, 15, 0, 201, 203, 3, 28, 14, 0, 202, 199, 1, 0, 0, 0, 202, 200, 1, 0, 0, 0, 202, 201, 1, 0, 0, 0, 203, 27, 1, 0, 0, 0, 204, 205, 5, 3, 0, 0, 205, 206, 3, 18, 9, 0, 206, 207, 5, 4, 0, 0, 207, 29, 1, 0, 0, 0, 208, 209, 7, 5, 0, 0, 209, 31, 1, 0, 0, 0, 210, 211, 5, 37, 0, 0, 211, 33, 1, 0, 0, 0, 13, 38, 40, 52, 59, 61, 65, 76, 150, 162, 174, 181, 196, 202] \ No newline at end of file diff --git a/frontend/src/query-grammar/.antlr/FilterQuery.tokens b/frontend/src/query-grammar/.antlr/FilterQuery.tokens new file mode 100644 index 000000000000..58b4f992a113 --- /dev/null +++ b/frontend/src/query-grammar/.antlr/FilterQuery.tokens @@ -0,0 +1,49 @@ +LPAREN=1 +RPAREN=2 +LBRACK=3 +RBRACK=4 +COMMA=5 +EQUALS=6 +NOT_EQUALS=7 +NEQ=8 +LT=9 +LE=10 +GT=11 +GE=12 +LIKE=13 +NOT_LIKE=14 +ILIKE=15 +NOT_ILIKE=16 +BETWEEN=17 +NOT_BETWEEN=18 +EXISTS=19 +NOT_EXISTS=20 +REGEXP=21 +NOT_REGEXP=22 +CONTAINS=23 +NOT_CONTAINS=24 +IN=25 +NOT_IN=26 +NOT=27 +AND=28 +OR=29 +HAS=30 +HASANY=31 +HASALL=32 +HASNONE=33 +BOOL=34 +NUMBER=35 +QUOTED_TEXT=36 +KEY=37 +WS=38 +'('=1 +')'=2 +'['=3 +']'=4 +','=5 +'!='=7 +'<>'=8 +'<'=9 +'<='=10 +'>'=11 +'>='=12 diff --git a/frontend/src/query-grammar/.antlr/FilterQueryLexer.interp b/frontend/src/query-grammar/.antlr/FilterQueryLexer.interp new file mode 100644 index 000000000000..127061871d87 --- /dev/null +++ b/frontend/src/query-grammar/.antlr/FilterQueryLexer.interp @@ -0,0 +1,132 @@ +token literal names: +null +'(' +')' +'[' +']' +',' +null +'!=' +'<>' +'<' +'<=' +'>' +'>=' +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +LPAREN +RPAREN +LBRACK +RBRACK +COMMA +EQUALS +NOT_EQUALS +NEQ +LT +LE +GT +GE +LIKE +NOT_LIKE +ILIKE +NOT_ILIKE +BETWEEN +NOT_BETWEEN +EXISTS +NOT_EXISTS +REGEXP +NOT_REGEXP +CONTAINS +NOT_CONTAINS +IN +NOT_IN +NOT +AND +OR +HAS +HASANY +HASALL +HASNONE +BOOL +NUMBER +QUOTED_TEXT +KEY +WS + +rule names: +LPAREN +RPAREN +LBRACK +RBRACK +COMMA +EQUALS +NOT_EQUALS +NEQ +LT +LE +GT +GE +LIKE +NOT_LIKE +ILIKE +NOT_ILIKE +BETWEEN +NOT_BETWEEN +EXISTS +NOT_EXISTS +REGEXP +NOT_REGEXP +CONTAINS +NOT_CONTAINS +IN +NOT_IN +NOT +AND +OR +HAS +HASANY +HASALL +HASNONE +BOOL +NUMBER +QUOTED_TEXT +KEY +WS +DIGIT + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 38, 359, 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, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 93, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 4, 13, 120, 8, 13, 11, 13, 12, 13, 121, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 4, 15, 139, 8, 15, 11, 15, 12, 15, 140, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 4, 17, 161, 8, 17, 11, 17, 12, 17, 162, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 179, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 4, 19, 185, 8, 19, 11, 19, 12, 19, 186, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 195, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 4, 21, 208, 8, 21, 11, 21, 12, 21, 209, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 227, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 4, 23, 233, 8, 23, 11, 23, 12, 23, 234, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 245, 8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 4, 25, 254, 8, 25, 11, 25, 12, 25, 255, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 3, 33, 307, 8, 33, 1, 34, 4, 34, 310, 8, 34, 11, 34, 12, 34, 311, 1, 34, 1, 34, 4, 34, 316, 8, 34, 11, 34, 12, 34, 317, 3, 34, 320, 8, 34, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 326, 8, 35, 10, 35, 12, 35, 329, 9, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 336, 8, 35, 10, 35, 12, 35, 339, 9, 35, 1, 35, 3, 35, 342, 8, 35, 1, 36, 1, 36, 5, 36, 346, 8, 36, 10, 36, 12, 36, 349, 9, 36, 1, 37, 4, 37, 352, 8, 37, 11, 37, 12, 37, 353, 1, 37, 1, 37, 1, 38, 1, 38, 0, 0, 39, 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, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 0, 1, 0, 28, 2, 0, 76, 76, 108, 108, 2, 0, 73, 73, 105, 105, 2, 0, 75, 75, 107, 107, 2, 0, 69, 69, 101, 101, 2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 0, 84, 84, 116, 116, 2, 0, 9, 9, 32, 32, 2, 0, 66, 66, 98, 98, 2, 0, 87, 87, 119, 119, 2, 0, 88, 88, 120, 120, 2, 0, 83, 83, 115, 115, 2, 0, 82, 82, 114, 114, 2, 0, 71, 71, 103, 103, 2, 0, 80, 80, 112, 112, 2, 0, 67, 67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 68, 68, 100, 100, 2, 0, 72, 72, 104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85, 85, 117, 117, 2, 0, 70, 70, 102, 102, 2, 0, 34, 34, 92, 92, 2, 0, 39, 39, 92, 92, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 6, 0, 46, 46, 48, 57, 65, 91, 93, 93, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57, 380, 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, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 1, 79, 1, 0, 0, 0, 3, 81, 1, 0, 0, 0, 5, 83, 1, 0, 0, 0, 7, 85, 1, 0, 0, 0, 9, 87, 1, 0, 0, 0, 11, 92, 1, 0, 0, 0, 13, 94, 1, 0, 0, 0, 15, 97, 1, 0, 0, 0, 17, 100, 1, 0, 0, 0, 19, 102, 1, 0, 0, 0, 21, 105, 1, 0, 0, 0, 23, 107, 1, 0, 0, 0, 25, 110, 1, 0, 0, 0, 27, 115, 1, 0, 0, 0, 29, 128, 1, 0, 0, 0, 31, 134, 1, 0, 0, 0, 33, 148, 1, 0, 0, 0, 35, 156, 1, 0, 0, 0, 37, 172, 1, 0, 0, 0, 39, 180, 1, 0, 0, 0, 41, 196, 1, 0, 0, 0, 43, 203, 1, 0, 0, 0, 45, 218, 1, 0, 0, 0, 47, 228, 1, 0, 0, 0, 49, 246, 1, 0, 0, 0, 51, 249, 1, 0, 0, 0, 53, 260, 1, 0, 0, 0, 55, 264, 1, 0, 0, 0, 57, 268, 1, 0, 0, 0, 59, 271, 1, 0, 0, 0, 61, 275, 1, 0, 0, 0, 63, 282, 1, 0, 0, 0, 65, 289, 1, 0, 0, 0, 67, 306, 1, 0, 0, 0, 69, 309, 1, 0, 0, 0, 71, 341, 1, 0, 0, 0, 73, 343, 1, 0, 0, 0, 75, 351, 1, 0, 0, 0, 77, 357, 1, 0, 0, 0, 79, 80, 5, 40, 0, 0, 80, 2, 1, 0, 0, 0, 81, 82, 5, 41, 0, 0, 82, 4, 1, 0, 0, 0, 83, 84, 5, 91, 0, 0, 84, 6, 1, 0, 0, 0, 85, 86, 5, 93, 0, 0, 86, 8, 1, 0, 0, 0, 87, 88, 5, 44, 0, 0, 88, 10, 1, 0, 0, 0, 89, 93, 5, 61, 0, 0, 90, 91, 5, 61, 0, 0, 91, 93, 5, 61, 0, 0, 92, 89, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 93, 12, 1, 0, 0, 0, 94, 95, 5, 33, 0, 0, 95, 96, 5, 61, 0, 0, 96, 14, 1, 0, 0, 0, 97, 98, 5, 60, 0, 0, 98, 99, 5, 62, 0, 0, 99, 16, 1, 0, 0, 0, 100, 101, 5, 60, 0, 0, 101, 18, 1, 0, 0, 0, 102, 103, 5, 60, 0, 0, 103, 104, 5, 61, 0, 0, 104, 20, 1, 0, 0, 0, 105, 106, 5, 62, 0, 0, 106, 22, 1, 0, 0, 0, 107, 108, 5, 62, 0, 0, 108, 109, 5, 61, 0, 0, 109, 24, 1, 0, 0, 0, 110, 111, 7, 0, 0, 0, 111, 112, 7, 1, 0, 0, 112, 113, 7, 2, 0, 0, 113, 114, 7, 3, 0, 0, 114, 26, 1, 0, 0, 0, 115, 116, 7, 4, 0, 0, 116, 117, 7, 5, 0, 0, 117, 119, 7, 6, 0, 0, 118, 120, 7, 7, 0, 0, 119, 118, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 123, 1, 0, 0, 0, 123, 124, 7, 0, 0, 0, 124, 125, 7, 1, 0, 0, 125, 126, 7, 2, 0, 0, 126, 127, 7, 3, 0, 0, 127, 28, 1, 0, 0, 0, 128, 129, 7, 1, 0, 0, 129, 130, 7, 0, 0, 0, 130, 131, 7, 1, 0, 0, 131, 132, 7, 2, 0, 0, 132, 133, 7, 3, 0, 0, 133, 30, 1, 0, 0, 0, 134, 135, 7, 4, 0, 0, 135, 136, 7, 5, 0, 0, 136, 138, 7, 6, 0, 0, 137, 139, 7, 7, 0, 0, 138, 137, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 140, 141, 1, 0, 0, 0, 141, 142, 1, 0, 0, 0, 142, 143, 7, 1, 0, 0, 143, 144, 7, 0, 0, 0, 144, 145, 7, 1, 0, 0, 145, 146, 7, 2, 0, 0, 146, 147, 7, 3, 0, 0, 147, 32, 1, 0, 0, 0, 148, 149, 7, 8, 0, 0, 149, 150, 7, 3, 0, 0, 150, 151, 7, 6, 0, 0, 151, 152, 7, 9, 0, 0, 152, 153, 7, 3, 0, 0, 153, 154, 7, 3, 0, 0, 154, 155, 7, 4, 0, 0, 155, 34, 1, 0, 0, 0, 156, 157, 7, 4, 0, 0, 157, 158, 7, 5, 0, 0, 158, 160, 7, 6, 0, 0, 159, 161, 7, 7, 0, 0, 160, 159, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 160, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 165, 7, 8, 0, 0, 165, 166, 7, 3, 0, 0, 166, 167, 7, 6, 0, 0, 167, 168, 7, 9, 0, 0, 168, 169, 7, 3, 0, 0, 169, 170, 7, 3, 0, 0, 170, 171, 7, 4, 0, 0, 171, 36, 1, 0, 0, 0, 172, 173, 7, 3, 0, 0, 173, 174, 7, 10, 0, 0, 174, 175, 7, 1, 0, 0, 175, 176, 7, 11, 0, 0, 176, 178, 7, 6, 0, 0, 177, 179, 7, 11, 0, 0, 178, 177, 1, 0, 0, 0, 178, 179, 1, 0, 0, 0, 179, 38, 1, 0, 0, 0, 180, 181, 7, 4, 0, 0, 181, 182, 7, 5, 0, 0, 182, 184, 7, 6, 0, 0, 183, 185, 7, 7, 0, 0, 184, 183, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 184, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, 189, 7, 3, 0, 0, 189, 190, 7, 10, 0, 0, 190, 191, 7, 1, 0, 0, 191, 192, 7, 11, 0, 0, 192, 194, 7, 6, 0, 0, 193, 195, 7, 11, 0, 0, 194, 193, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 40, 1, 0, 0, 0, 196, 197, 7, 12, 0, 0, 197, 198, 7, 3, 0, 0, 198, 199, 7, 13, 0, 0, 199, 200, 7, 3, 0, 0, 200, 201, 7, 10, 0, 0, 201, 202, 7, 14, 0, 0, 202, 42, 1, 0, 0, 0, 203, 204, 7, 4, 0, 0, 204, 205, 7, 5, 0, 0, 205, 207, 7, 6, 0, 0, 206, 208, 7, 7, 0, 0, 207, 206, 1, 0, 0, 0, 208, 209, 1, 0, 0, 0, 209, 207, 1, 0, 0, 0, 209, 210, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 212, 7, 12, 0, 0, 212, 213, 7, 3, 0, 0, 213, 214, 7, 13, 0, 0, 214, 215, 7, 3, 0, 0, 215, 216, 7, 10, 0, 0, 216, 217, 7, 14, 0, 0, 217, 44, 1, 0, 0, 0, 218, 219, 7, 15, 0, 0, 219, 220, 7, 5, 0, 0, 220, 221, 7, 4, 0, 0, 221, 222, 7, 6, 0, 0, 222, 223, 7, 16, 0, 0, 223, 224, 7, 1, 0, 0, 224, 226, 7, 4, 0, 0, 225, 227, 7, 11, 0, 0, 226, 225, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 46, 1, 0, 0, 0, 228, 229, 7, 4, 0, 0, 229, 230, 7, 5, 0, 0, 230, 232, 7, 6, 0, 0, 231, 233, 7, 7, 0, 0, 232, 231, 1, 0, 0, 0, 233, 234, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 234, 235, 1, 0, 0, 0, 235, 236, 1, 0, 0, 0, 236, 237, 7, 15, 0, 0, 237, 238, 7, 5, 0, 0, 238, 239, 7, 4, 0, 0, 239, 240, 7, 6, 0, 0, 240, 241, 7, 16, 0, 0, 241, 242, 7, 1, 0, 0, 242, 244, 7, 4, 0, 0, 243, 245, 7, 11, 0, 0, 244, 243, 1, 0, 0, 0, 244, 245, 1, 0, 0, 0, 245, 48, 1, 0, 0, 0, 246, 247, 7, 1, 0, 0, 247, 248, 7, 4, 0, 0, 248, 50, 1, 0, 0, 0, 249, 250, 7, 4, 0, 0, 250, 251, 7, 5, 0, 0, 251, 253, 7, 6, 0, 0, 252, 254, 7, 7, 0, 0, 253, 252, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 253, 1, 0, 0, 0, 255, 256, 1, 0, 0, 0, 256, 257, 1, 0, 0, 0, 257, 258, 7, 1, 0, 0, 258, 259, 7, 4, 0, 0, 259, 52, 1, 0, 0, 0, 260, 261, 7, 4, 0, 0, 261, 262, 7, 5, 0, 0, 262, 263, 7, 6, 0, 0, 263, 54, 1, 0, 0, 0, 264, 265, 7, 16, 0, 0, 265, 266, 7, 4, 0, 0, 266, 267, 7, 17, 0, 0, 267, 56, 1, 0, 0, 0, 268, 269, 7, 5, 0, 0, 269, 270, 7, 12, 0, 0, 270, 58, 1, 0, 0, 0, 271, 272, 7, 18, 0, 0, 272, 273, 7, 16, 0, 0, 273, 274, 7, 11, 0, 0, 274, 60, 1, 0, 0, 0, 275, 276, 7, 18, 0, 0, 276, 277, 7, 16, 0, 0, 277, 278, 7, 11, 0, 0, 278, 279, 7, 16, 0, 0, 279, 280, 7, 4, 0, 0, 280, 281, 7, 19, 0, 0, 281, 62, 1, 0, 0, 0, 282, 283, 7, 18, 0, 0, 283, 284, 7, 16, 0, 0, 284, 285, 7, 11, 0, 0, 285, 286, 7, 16, 0, 0, 286, 287, 7, 0, 0, 0, 287, 288, 7, 0, 0, 0, 288, 64, 1, 0, 0, 0, 289, 290, 7, 18, 0, 0, 290, 291, 7, 16, 0, 0, 291, 292, 7, 11, 0, 0, 292, 293, 7, 4, 0, 0, 293, 294, 7, 5, 0, 0, 294, 295, 7, 4, 0, 0, 295, 296, 7, 3, 0, 0, 296, 66, 1, 0, 0, 0, 297, 298, 7, 6, 0, 0, 298, 299, 7, 12, 0, 0, 299, 300, 7, 20, 0, 0, 300, 307, 7, 3, 0, 0, 301, 302, 7, 21, 0, 0, 302, 303, 7, 16, 0, 0, 303, 304, 7, 0, 0, 0, 304, 305, 7, 11, 0, 0, 305, 307, 7, 3, 0, 0, 306, 297, 1, 0, 0, 0, 306, 301, 1, 0, 0, 0, 307, 68, 1, 0, 0, 0, 308, 310, 3, 77, 38, 0, 309, 308, 1, 0, 0, 0, 310, 311, 1, 0, 0, 0, 311, 309, 1, 0, 0, 0, 311, 312, 1, 0, 0, 0, 312, 319, 1, 0, 0, 0, 313, 315, 5, 46, 0, 0, 314, 316, 3, 77, 38, 0, 315, 314, 1, 0, 0, 0, 316, 317, 1, 0, 0, 0, 317, 315, 1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 320, 1, 0, 0, 0, 319, 313, 1, 0, 0, 0, 319, 320, 1, 0, 0, 0, 320, 70, 1, 0, 0, 0, 321, 327, 5, 34, 0, 0, 322, 326, 8, 22, 0, 0, 323, 324, 5, 92, 0, 0, 324, 326, 9, 0, 0, 0, 325, 322, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 326, 329, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 327, 328, 1, 0, 0, 0, 328, 330, 1, 0, 0, 0, 329, 327, 1, 0, 0, 0, 330, 342, 5, 34, 0, 0, 331, 337, 5, 39, 0, 0, 332, 336, 8, 23, 0, 0, 333, 334, 5, 92, 0, 0, 334, 336, 9, 0, 0, 0, 335, 332, 1, 0, 0, 0, 335, 333, 1, 0, 0, 0, 336, 339, 1, 0, 0, 0, 337, 335, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 340, 1, 0, 0, 0, 339, 337, 1, 0, 0, 0, 340, 342, 5, 39, 0, 0, 341, 321, 1, 0, 0, 0, 341, 331, 1, 0, 0, 0, 342, 72, 1, 0, 0, 0, 343, 347, 7, 24, 0, 0, 344, 346, 7, 25, 0, 0, 345, 344, 1, 0, 0, 0, 346, 349, 1, 0, 0, 0, 347, 345, 1, 0, 0, 0, 347, 348, 1, 0, 0, 0, 348, 74, 1, 0, 0, 0, 349, 347, 1, 0, 0, 0, 350, 352, 7, 26, 0, 0, 351, 350, 1, 0, 0, 0, 352, 353, 1, 0, 0, 0, 353, 351, 1, 0, 0, 0, 353, 354, 1, 0, 0, 0, 354, 355, 1, 0, 0, 0, 355, 356, 6, 37, 0, 0, 356, 76, 1, 0, 0, 0, 357, 358, 7, 27, 0, 0, 358, 78, 1, 0, 0, 0, 24, 0, 92, 121, 140, 162, 178, 186, 194, 209, 226, 234, 244, 255, 306, 311, 317, 319, 325, 327, 335, 337, 341, 347, 353, 1, 6, 0, 0] \ No newline at end of file diff --git a/frontend/src/query-grammar/.antlr/FilterQueryLexer.java b/frontend/src/query-grammar/.antlr/FilterQueryLexer.java new file mode 100644 index 000000000000..fc5bd5751e65 --- /dev/null +++ b/frontend/src/query-grammar/.antlr/FilterQueryLexer.java @@ -0,0 +1,371 @@ +// Generated from /Users/younix/Documents/SigNoz-Repos/signoz/frontend/src/query-grammar/FilterQuery.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 FilterQueryLexer 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 + LPAREN=1, RPAREN=2, LBRACK=3, RBRACK=4, COMMA=5, EQUALS=6, NOT_EQUALS=7, + NEQ=8, LT=9, LE=10, GT=11, GE=12, LIKE=13, NOT_LIKE=14, ILIKE=15, NOT_ILIKE=16, + BETWEEN=17, NOT_BETWEEN=18, EXISTS=19, NOT_EXISTS=20, REGEXP=21, NOT_REGEXP=22, + CONTAINS=23, NOT_CONTAINS=24, IN=25, NOT_IN=26, NOT=27, AND=28, OR=29, + HAS=30, HASANY=31, HASALL=32, HASNONE=33, BOOL=34, NUMBER=35, QUOTED_TEXT=36, + KEY=37, WS=38; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS", + "NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE", + "BETWEEN", "NOT_BETWEEN", "EXISTS", "NOT_EXISTS", "REGEXP", "NOT_REGEXP", + "CONTAINS", "NOT_CONTAINS", "IN", "NOT_IN", "NOT", "AND", "OR", "HAS", + "HASANY", "HASALL", "HASNONE", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", + "WS", "DIGIT" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'('", "')'", "'['", "']'", "','", null, "'!='", "'<>'", "'<'", + "'<='", "'>'", "'>='" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS", + "NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE", + "BETWEEN", "NOT_BETWEEN", "EXISTS", "NOT_EXISTS", "REGEXP", "NOT_REGEXP", + "CONTAINS", "NOT_CONTAINS", "IN", "NOT_IN", "NOT", "AND", "OR", "HAS", + "HASANY", "HASALL", "HASNONE", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", + "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 FilterQueryLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "FilterQuery.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&\u0167\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\u0002"+ + "\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002"+ + "\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002"+ + "\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+ + "\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ + "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ + "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ + "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ + "&\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002"+ + "\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+ + "\u0001\u0005\u0003\u0005]\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001"+ + "\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\f\u0001\f"+ + "\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001\r\u0004\rx\b\r"+ + "\u000b\r\f\ry\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001"+ + "\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ + "\u000f\u0001\u000f\u0001\u000f\u0004\u000f\u008b\b\u000f\u000b\u000f\f"+ + "\u000f\u008c\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f"+ + "\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010"+ + "\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011\u0001\u0011"+ + "\u0001\u0011\u0004\u0011\u00a1\b\u0011\u000b\u0011\f\u0011\u00a2\u0001"+ + "\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ + "\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001"+ + "\u0012\u0001\u0012\u0003\u0012\u00b3\b\u0012\u0001\u0013\u0001\u0013\u0001"+ + "\u0013\u0001\u0013\u0004\u0013\u00b9\b\u0013\u000b\u0013\f\u0013\u00ba"+ + "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0003\u0013\u00c3\b\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014"+ + "\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015"+ + "\u0001\u0015\u0004\u0015\u00d0\b\u0015\u000b\u0015\f\u0015\u00d1\u0001"+ + "\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001"+ + "\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001"+ + "\u0016\u0001\u0016\u0001\u0016\u0003\u0016\u00e3\b\u0016\u0001\u0017\u0001"+ + "\u0017\u0001\u0017\u0001\u0017\u0004\u0017\u00e9\b\u0017\u000b\u0017\f"+ + "\u0017\u00ea\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017"+ + "\u0001\u0017\u0001\u0017\u0001\u0017\u0003\u0017\u00f5\b\u0017\u0001\u0018"+ + "\u0001\u0018\u0001\u0018\u0001\u0019\u0001\u0019\u0001\u0019\u0001\u0019"+ + "\u0004\u0019\u00fe\b\u0019\u000b\u0019\f\u0019\u00ff\u0001\u0019\u0001"+ + "\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ + "\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001"+ + "\u001c\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001"+ + "\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001"+ + "\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0001 \u0001 \u0001 \u0001!"+ + "\u0001!\u0001!\u0001!\u0001!\u0001!\u0001!\u0001!\u0001!\u0003!\u0133"+ + "\b!\u0001\"\u0004\"\u0136\b\"\u000b\"\f\"\u0137\u0001\"\u0001\"\u0004"+ + "\"\u013c\b\"\u000b\"\f\"\u013d\u0003\"\u0140\b\"\u0001#\u0001#\u0001#"+ + "\u0001#\u0005#\u0146\b#\n#\f#\u0149\t#\u0001#\u0001#\u0001#\u0001#\u0001"+ + "#\u0005#\u0150\b#\n#\f#\u0153\t#\u0001#\u0003#\u0156\b#\u0001$\u0001$"+ + "\u0005$\u015a\b$\n$\f$\u015d\t$\u0001%\u0004%\u0160\b%\u000b%\f%\u0161"+ + "\u0001%\u0001%\u0001&\u0001&\u0000\u0000\'\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\u001f\u0010!\u0011"+ + "#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u00181\u00193\u001a5\u001b"+ + "7\u001c9\u001d;\u001e=\u001f? A!C\"E#G$I%K&M\u0000\u0001\u0000\u001c\u0002"+ + "\u0000LLll\u0002\u0000IIii\u0002\u0000KKkk\u0002\u0000EEee\u0002\u0000"+ + "NNnn\u0002\u0000OOoo\u0002\u0000TTtt\u0002\u0000\t\t \u0002\u0000BBb"+ + "b\u0002\u0000WWww\u0002\u0000XXxx\u0002\u0000SSss\u0002\u0000RRrr\u0002"+ + "\u0000GGgg\u0002\u0000PPpp\u0002\u0000CCcc\u0002\u0000AAaa\u0002\u0000"+ + "DDdd\u0002\u0000HHhh\u0002\u0000YYyy\u0002\u0000UUuu\u0002\u0000FFff\u0002"+ + "\u0000\"\"\\\\\u0002\u0000\'\'\\\\\u0004\u000009AZ__az\u0006\u0000..0"+ + "9A[]]__az\u0003\u0000\t\n\r\r \u0001\u000009\u017c\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\u0000\u001f\u0001\u0000\u0000\u0000\u0000!\u0001\u0000\u0000\u0000"+ + "\u0000#\u0001\u0000\u0000\u0000\u0000%\u0001\u0000\u0000\u0000\u0000\'"+ + "\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000\u0000\u0000+\u0001\u0000"+ + "\u0000\u0000\u0000-\u0001\u0000\u0000\u0000\u0000/\u0001\u0000\u0000\u0000"+ + "\u00001\u0001\u0000\u0000\u0000\u00003\u0001\u0000\u0000\u0000\u00005"+ + "\u0001\u0000\u0000\u0000\u00007\u0001\u0000\u0000\u0000\u00009\u0001\u0000"+ + "\u0000\u0000\u0000;\u0001\u0000\u0000\u0000\u0000=\u0001\u0000\u0000\u0000"+ + "\u0000?\u0001\u0000\u0000\u0000\u0000A\u0001\u0000\u0000\u0000\u0000C"+ + "\u0001\u0000\u0000\u0000\u0000E\u0001\u0000\u0000\u0000\u0000G\u0001\u0000"+ + "\u0000\u0000\u0000I\u0001\u0000\u0000\u0000\u0000K\u0001\u0000\u0000\u0000"+ + "\u0001O\u0001\u0000\u0000\u0000\u0003Q\u0001\u0000\u0000\u0000\u0005S"+ + "\u0001\u0000\u0000\u0000\u0007U\u0001\u0000\u0000\u0000\tW\u0001\u0000"+ + "\u0000\u0000\u000b\\\u0001\u0000\u0000\u0000\r^\u0001\u0000\u0000\u0000"+ + "\u000fa\u0001\u0000\u0000\u0000\u0011d\u0001\u0000\u0000\u0000\u0013f"+ + "\u0001\u0000\u0000\u0000\u0015i\u0001\u0000\u0000\u0000\u0017k\u0001\u0000"+ + "\u0000\u0000\u0019n\u0001\u0000\u0000\u0000\u001bs\u0001\u0000\u0000\u0000"+ + "\u001d\u0080\u0001\u0000\u0000\u0000\u001f\u0086\u0001\u0000\u0000\u0000"+ + "!\u0094\u0001\u0000\u0000\u0000#\u009c\u0001\u0000\u0000\u0000%\u00ac"+ + "\u0001\u0000\u0000\u0000\'\u00b4\u0001\u0000\u0000\u0000)\u00c4\u0001"+ + "\u0000\u0000\u0000+\u00cb\u0001\u0000\u0000\u0000-\u00da\u0001\u0000\u0000"+ + "\u0000/\u00e4\u0001\u0000\u0000\u00001\u00f6\u0001\u0000\u0000\u00003"+ + "\u00f9\u0001\u0000\u0000\u00005\u0104\u0001\u0000\u0000\u00007\u0108\u0001"+ + "\u0000\u0000\u00009\u010c\u0001\u0000\u0000\u0000;\u010f\u0001\u0000\u0000"+ + "\u0000=\u0113\u0001\u0000\u0000\u0000?\u011a\u0001\u0000\u0000\u0000A"+ + "\u0121\u0001\u0000\u0000\u0000C\u0132\u0001\u0000\u0000\u0000E\u0135\u0001"+ + "\u0000\u0000\u0000G\u0155\u0001\u0000\u0000\u0000I\u0157\u0001\u0000\u0000"+ + "\u0000K\u015f\u0001\u0000\u0000\u0000M\u0165\u0001\u0000\u0000\u0000O"+ + "P\u0005(\u0000\u0000P\u0002\u0001\u0000\u0000\u0000QR\u0005)\u0000\u0000"+ + "R\u0004\u0001\u0000\u0000\u0000ST\u0005[\u0000\u0000T\u0006\u0001\u0000"+ + "\u0000\u0000UV\u0005]\u0000\u0000V\b\u0001\u0000\u0000\u0000WX\u0005,"+ + "\u0000\u0000X\n\u0001\u0000\u0000\u0000Y]\u0005=\u0000\u0000Z[\u0005="+ + "\u0000\u0000[]\u0005=\u0000\u0000\\Y\u0001\u0000\u0000\u0000\\Z\u0001"+ + "\u0000\u0000\u0000]\f\u0001\u0000\u0000\u0000^_\u0005!\u0000\u0000_`\u0005"+ + "=\u0000\u0000`\u000e\u0001\u0000\u0000\u0000ab\u0005<\u0000\u0000bc\u0005"+ + ">\u0000\u0000c\u0010\u0001\u0000\u0000\u0000de\u0005<\u0000\u0000e\u0012"+ + "\u0001\u0000\u0000\u0000fg\u0005<\u0000\u0000gh\u0005=\u0000\u0000h\u0014"+ + "\u0001\u0000\u0000\u0000ij\u0005>\u0000\u0000j\u0016\u0001\u0000\u0000"+ + "\u0000kl\u0005>\u0000\u0000lm\u0005=\u0000\u0000m\u0018\u0001\u0000\u0000"+ + "\u0000no\u0007\u0000\u0000\u0000op\u0007\u0001\u0000\u0000pq\u0007\u0002"+ + "\u0000\u0000qr\u0007\u0003\u0000\u0000r\u001a\u0001\u0000\u0000\u0000"+ + "st\u0007\u0004\u0000\u0000tu\u0007\u0005\u0000\u0000uw\u0007\u0006\u0000"+ + "\u0000vx\u0007\u0007\u0000\u0000wv\u0001\u0000\u0000\u0000xy\u0001\u0000"+ + "\u0000\u0000yw\u0001\u0000\u0000\u0000yz\u0001\u0000\u0000\u0000z{\u0001"+ + "\u0000\u0000\u0000{|\u0007\u0000\u0000\u0000|}\u0007\u0001\u0000\u0000"+ + "}~\u0007\u0002\u0000\u0000~\u007f\u0007\u0003\u0000\u0000\u007f\u001c"+ + "\u0001\u0000\u0000\u0000\u0080\u0081\u0007\u0001\u0000\u0000\u0081\u0082"+ + "\u0007\u0000\u0000\u0000\u0082\u0083\u0007\u0001\u0000\u0000\u0083\u0084"+ + "\u0007\u0002\u0000\u0000\u0084\u0085\u0007\u0003\u0000\u0000\u0085\u001e"+ + "\u0001\u0000\u0000\u0000\u0086\u0087\u0007\u0004\u0000\u0000\u0087\u0088"+ + "\u0007\u0005\u0000\u0000\u0088\u008a\u0007\u0006\u0000\u0000\u0089\u008b"+ + "\u0007\u0007\u0000\u0000\u008a\u0089\u0001\u0000\u0000\u0000\u008b\u008c"+ + "\u0001\u0000\u0000\u0000\u008c\u008a\u0001\u0000\u0000\u0000\u008c\u008d"+ + "\u0001\u0000\u0000\u0000\u008d\u008e\u0001\u0000\u0000\u0000\u008e\u008f"+ + "\u0007\u0001\u0000\u0000\u008f\u0090\u0007\u0000\u0000\u0000\u0090\u0091"+ + "\u0007\u0001\u0000\u0000\u0091\u0092\u0007\u0002\u0000\u0000\u0092\u0093"+ + "\u0007\u0003\u0000\u0000\u0093 \u0001\u0000\u0000\u0000\u0094\u0095\u0007"+ + "\b\u0000\u0000\u0095\u0096\u0007\u0003\u0000\u0000\u0096\u0097\u0007\u0006"+ + "\u0000\u0000\u0097\u0098\u0007\t\u0000\u0000\u0098\u0099\u0007\u0003\u0000"+ + "\u0000\u0099\u009a\u0007\u0003\u0000\u0000\u009a\u009b\u0007\u0004\u0000"+ + "\u0000\u009b\"\u0001\u0000\u0000\u0000\u009c\u009d\u0007\u0004\u0000\u0000"+ + "\u009d\u009e\u0007\u0005\u0000\u0000\u009e\u00a0\u0007\u0006\u0000\u0000"+ + "\u009f\u00a1\u0007\u0007\u0000\u0000\u00a0\u009f\u0001\u0000\u0000\u0000"+ + "\u00a1\u00a2\u0001\u0000\u0000\u0000\u00a2\u00a0\u0001\u0000\u0000\u0000"+ + "\u00a2\u00a3\u0001\u0000\u0000\u0000\u00a3\u00a4\u0001\u0000\u0000\u0000"+ + "\u00a4\u00a5\u0007\b\u0000\u0000\u00a5\u00a6\u0007\u0003\u0000\u0000\u00a6"+ + "\u00a7\u0007\u0006\u0000\u0000\u00a7\u00a8\u0007\t\u0000\u0000\u00a8\u00a9"+ + "\u0007\u0003\u0000\u0000\u00a9\u00aa\u0007\u0003\u0000\u0000\u00aa\u00ab"+ + "\u0007\u0004\u0000\u0000\u00ab$\u0001\u0000\u0000\u0000\u00ac\u00ad\u0007"+ + "\u0003\u0000\u0000\u00ad\u00ae\u0007\n\u0000\u0000\u00ae\u00af\u0007\u0001"+ + "\u0000\u0000\u00af\u00b0\u0007\u000b\u0000\u0000\u00b0\u00b2\u0007\u0006"+ + "\u0000\u0000\u00b1\u00b3\u0007\u000b\u0000\u0000\u00b2\u00b1\u0001\u0000"+ + "\u0000\u0000\u00b2\u00b3\u0001\u0000\u0000\u0000\u00b3&\u0001\u0000\u0000"+ + "\u0000\u00b4\u00b5\u0007\u0004\u0000\u0000\u00b5\u00b6\u0007\u0005\u0000"+ + "\u0000\u00b6\u00b8\u0007\u0006\u0000\u0000\u00b7\u00b9\u0007\u0007\u0000"+ + "\u0000\u00b8\u00b7\u0001\u0000\u0000\u0000\u00b9\u00ba\u0001\u0000\u0000"+ + "\u0000\u00ba\u00b8\u0001\u0000\u0000\u0000\u00ba\u00bb\u0001\u0000\u0000"+ + "\u0000\u00bb\u00bc\u0001\u0000\u0000\u0000\u00bc\u00bd\u0007\u0003\u0000"+ + "\u0000\u00bd\u00be\u0007\n\u0000\u0000\u00be\u00bf\u0007\u0001\u0000\u0000"+ + "\u00bf\u00c0\u0007\u000b\u0000\u0000\u00c0\u00c2\u0007\u0006\u0000\u0000"+ + "\u00c1\u00c3\u0007\u000b\u0000\u0000\u00c2\u00c1\u0001\u0000\u0000\u0000"+ + "\u00c2\u00c3\u0001\u0000\u0000\u0000\u00c3(\u0001\u0000\u0000\u0000\u00c4"+ + "\u00c5\u0007\f\u0000\u0000\u00c5\u00c6\u0007\u0003\u0000\u0000\u00c6\u00c7"+ + "\u0007\r\u0000\u0000\u00c7\u00c8\u0007\u0003\u0000\u0000\u00c8\u00c9\u0007"+ + "\n\u0000\u0000\u00c9\u00ca\u0007\u000e\u0000\u0000\u00ca*\u0001\u0000"+ + "\u0000\u0000\u00cb\u00cc\u0007\u0004\u0000\u0000\u00cc\u00cd\u0007\u0005"+ + "\u0000\u0000\u00cd\u00cf\u0007\u0006\u0000\u0000\u00ce\u00d0\u0007\u0007"+ + "\u0000\u0000\u00cf\u00ce\u0001\u0000\u0000\u0000\u00d0\u00d1\u0001\u0000"+ + "\u0000\u0000\u00d1\u00cf\u0001\u0000\u0000\u0000\u00d1\u00d2\u0001\u0000"+ + "\u0000\u0000\u00d2\u00d3\u0001\u0000\u0000\u0000\u00d3\u00d4\u0007\f\u0000"+ + "\u0000\u00d4\u00d5\u0007\u0003\u0000\u0000\u00d5\u00d6\u0007\r\u0000\u0000"+ + "\u00d6\u00d7\u0007\u0003\u0000\u0000\u00d7\u00d8\u0007\n\u0000\u0000\u00d8"+ + "\u00d9\u0007\u000e\u0000\u0000\u00d9,\u0001\u0000\u0000\u0000\u00da\u00db"+ + "\u0007\u000f\u0000\u0000\u00db\u00dc\u0007\u0005\u0000\u0000\u00dc\u00dd"+ + "\u0007\u0004\u0000\u0000\u00dd\u00de\u0007\u0006\u0000\u0000\u00de\u00df"+ + "\u0007\u0010\u0000\u0000\u00df\u00e0\u0007\u0001\u0000\u0000\u00e0\u00e2"+ + "\u0007\u0004\u0000\u0000\u00e1\u00e3\u0007\u000b\u0000\u0000\u00e2\u00e1"+ + "\u0001\u0000\u0000\u0000\u00e2\u00e3\u0001\u0000\u0000\u0000\u00e3.\u0001"+ + "\u0000\u0000\u0000\u00e4\u00e5\u0007\u0004\u0000\u0000\u00e5\u00e6\u0007"+ + "\u0005\u0000\u0000\u00e6\u00e8\u0007\u0006\u0000\u0000\u00e7\u00e9\u0007"+ + "\u0007\u0000\u0000\u00e8\u00e7\u0001\u0000\u0000\u0000\u00e9\u00ea\u0001"+ + "\u0000\u0000\u0000\u00ea\u00e8\u0001\u0000\u0000\u0000\u00ea\u00eb\u0001"+ + "\u0000\u0000\u0000\u00eb\u00ec\u0001\u0000\u0000\u0000\u00ec\u00ed\u0007"+ + "\u000f\u0000\u0000\u00ed\u00ee\u0007\u0005\u0000\u0000\u00ee\u00ef\u0007"+ + "\u0004\u0000\u0000\u00ef\u00f0\u0007\u0006\u0000\u0000\u00f0\u00f1\u0007"+ + "\u0010\u0000\u0000\u00f1\u00f2\u0007\u0001\u0000\u0000\u00f2\u00f4\u0007"+ + "\u0004\u0000\u0000\u00f3\u00f5\u0007\u000b\u0000\u0000\u00f4\u00f3\u0001"+ + "\u0000\u0000\u0000\u00f4\u00f5\u0001\u0000\u0000\u0000\u00f50\u0001\u0000"+ + "\u0000\u0000\u00f6\u00f7\u0007\u0001\u0000\u0000\u00f7\u00f8\u0007\u0004"+ + "\u0000\u0000\u00f82\u0001\u0000\u0000\u0000\u00f9\u00fa\u0007\u0004\u0000"+ + "\u0000\u00fa\u00fb\u0007\u0005\u0000\u0000\u00fb\u00fd\u0007\u0006\u0000"+ + "\u0000\u00fc\u00fe\u0007\u0007\u0000\u0000\u00fd\u00fc\u0001\u0000\u0000"+ + "\u0000\u00fe\u00ff\u0001\u0000\u0000\u0000\u00ff\u00fd\u0001\u0000\u0000"+ + "\u0000\u00ff\u0100\u0001\u0000\u0000\u0000\u0100\u0101\u0001\u0000\u0000"+ + "\u0000\u0101\u0102\u0007\u0001\u0000\u0000\u0102\u0103\u0007\u0004\u0000"+ + "\u0000\u01034\u0001\u0000\u0000\u0000\u0104\u0105\u0007\u0004\u0000\u0000"+ + "\u0105\u0106\u0007\u0005\u0000\u0000\u0106\u0107\u0007\u0006\u0000\u0000"+ + "\u01076\u0001\u0000\u0000\u0000\u0108\u0109\u0007\u0010\u0000\u0000\u0109"+ + "\u010a\u0007\u0004\u0000\u0000\u010a\u010b\u0007\u0011\u0000\u0000\u010b"+ + "8\u0001\u0000\u0000\u0000\u010c\u010d\u0007\u0005\u0000\u0000\u010d\u010e"+ + "\u0007\f\u0000\u0000\u010e:\u0001\u0000\u0000\u0000\u010f\u0110\u0007"+ + "\u0012\u0000\u0000\u0110\u0111\u0007\u0010\u0000\u0000\u0111\u0112\u0007"+ + "\u000b\u0000\u0000\u0112<\u0001\u0000\u0000\u0000\u0113\u0114\u0007\u0012"+ + "\u0000\u0000\u0114\u0115\u0007\u0010\u0000\u0000\u0115\u0116\u0007\u000b"+ + "\u0000\u0000\u0116\u0117\u0007\u0010\u0000\u0000\u0117\u0118\u0007\u0004"+ + "\u0000\u0000\u0118\u0119\u0007\u0013\u0000\u0000\u0119>\u0001\u0000\u0000"+ + "\u0000\u011a\u011b\u0007\u0012\u0000\u0000\u011b\u011c\u0007\u0010\u0000"+ + "\u0000\u011c\u011d\u0007\u000b\u0000\u0000\u011d\u011e\u0007\u0010\u0000"+ + "\u0000\u011e\u011f\u0007\u0000\u0000\u0000\u011f\u0120\u0007\u0000\u0000"+ + "\u0000\u0120@\u0001\u0000\u0000\u0000\u0121\u0122\u0007\u0012\u0000\u0000"+ + "\u0122\u0123\u0007\u0010\u0000\u0000\u0123\u0124\u0007\u000b\u0000\u0000"+ + "\u0124\u0125\u0007\u0004\u0000\u0000\u0125\u0126\u0007\u0005\u0000\u0000"+ + "\u0126\u0127\u0007\u0004\u0000\u0000\u0127\u0128\u0007\u0003\u0000\u0000"+ + "\u0128B\u0001\u0000\u0000\u0000\u0129\u012a\u0007\u0006\u0000\u0000\u012a"+ + "\u012b\u0007\f\u0000\u0000\u012b\u012c\u0007\u0014\u0000\u0000\u012c\u0133"+ + "\u0007\u0003\u0000\u0000\u012d\u012e\u0007\u0015\u0000\u0000\u012e\u012f"+ + "\u0007\u0010\u0000\u0000\u012f\u0130\u0007\u0000\u0000\u0000\u0130\u0131"+ + "\u0007\u000b\u0000\u0000\u0131\u0133\u0007\u0003\u0000\u0000\u0132\u0129"+ + "\u0001\u0000\u0000\u0000\u0132\u012d\u0001\u0000\u0000\u0000\u0133D\u0001"+ + "\u0000\u0000\u0000\u0134\u0136\u0003M&\u0000\u0135\u0134\u0001\u0000\u0000"+ + "\u0000\u0136\u0137\u0001\u0000\u0000\u0000\u0137\u0135\u0001\u0000\u0000"+ + "\u0000\u0137\u0138\u0001\u0000\u0000\u0000\u0138\u013f\u0001\u0000\u0000"+ + "\u0000\u0139\u013b\u0005.\u0000\u0000\u013a\u013c\u0003M&\u0000\u013b"+ + "\u013a\u0001\u0000\u0000\u0000\u013c\u013d\u0001\u0000\u0000\u0000\u013d"+ + "\u013b\u0001\u0000\u0000\u0000\u013d\u013e\u0001\u0000\u0000\u0000\u013e"+ + "\u0140\u0001\u0000\u0000\u0000\u013f\u0139\u0001\u0000\u0000\u0000\u013f"+ + "\u0140\u0001\u0000\u0000\u0000\u0140F\u0001\u0000\u0000\u0000\u0141\u0147"+ + "\u0005\"\u0000\u0000\u0142\u0146\b\u0016\u0000\u0000\u0143\u0144\u0005"+ + "\\\u0000\u0000\u0144\u0146\t\u0000\u0000\u0000\u0145\u0142\u0001\u0000"+ + "\u0000\u0000\u0145\u0143\u0001\u0000\u0000\u0000\u0146\u0149\u0001\u0000"+ + "\u0000\u0000\u0147\u0145\u0001\u0000\u0000\u0000\u0147\u0148\u0001\u0000"+ + "\u0000\u0000\u0148\u014a\u0001\u0000\u0000\u0000\u0149\u0147\u0001\u0000"+ + "\u0000\u0000\u014a\u0156\u0005\"\u0000\u0000\u014b\u0151\u0005\'\u0000"+ + "\u0000\u014c\u0150\b\u0017\u0000\u0000\u014d\u014e\u0005\\\u0000\u0000"+ + "\u014e\u0150\t\u0000\u0000\u0000\u014f\u014c\u0001\u0000\u0000\u0000\u014f"+ + "\u014d\u0001\u0000\u0000\u0000\u0150\u0153\u0001\u0000\u0000\u0000\u0151"+ + "\u014f\u0001\u0000\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152"+ + "\u0154\u0001\u0000\u0000\u0000\u0153\u0151\u0001\u0000\u0000\u0000\u0154"+ + "\u0156\u0005\'\u0000\u0000\u0155\u0141\u0001\u0000\u0000\u0000\u0155\u014b"+ + "\u0001\u0000\u0000\u0000\u0156H\u0001\u0000\u0000\u0000\u0157\u015b\u0007"+ + "\u0018\u0000\u0000\u0158\u015a\u0007\u0019\u0000\u0000\u0159\u0158\u0001"+ + "\u0000\u0000\u0000\u015a\u015d\u0001\u0000\u0000\u0000\u015b\u0159\u0001"+ + "\u0000\u0000\u0000\u015b\u015c\u0001\u0000\u0000\u0000\u015cJ\u0001\u0000"+ + "\u0000\u0000\u015d\u015b\u0001\u0000\u0000\u0000\u015e\u0160\u0007\u001a"+ + "\u0000\u0000\u015f\u015e\u0001\u0000\u0000\u0000\u0160\u0161\u0001\u0000"+ + "\u0000\u0000\u0161\u015f\u0001\u0000\u0000\u0000\u0161\u0162\u0001\u0000"+ + "\u0000\u0000\u0162\u0163\u0001\u0000\u0000\u0000\u0163\u0164\u0006%\u0000"+ + "\u0000\u0164L\u0001\u0000\u0000\u0000\u0165\u0166\u0007\u001b\u0000\u0000"+ + "\u0166N\u0001\u0000\u0000\u0000\u0018\u0000\\y\u008c\u00a2\u00b2\u00ba"+ + "\u00c2\u00d1\u00e2\u00ea\u00f4\u00ff\u0132\u0137\u013d\u013f\u0145\u0147"+ + "\u014f\u0151\u0155\u015b\u0161\u0001\u0006\u0000\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/frontend/src/query-grammar/.antlr/FilterQueryLexer.tokens b/frontend/src/query-grammar/.antlr/FilterQueryLexer.tokens new file mode 100644 index 000000000000..58b4f992a113 --- /dev/null +++ b/frontend/src/query-grammar/.antlr/FilterQueryLexer.tokens @@ -0,0 +1,49 @@ +LPAREN=1 +RPAREN=2 +LBRACK=3 +RBRACK=4 +COMMA=5 +EQUALS=6 +NOT_EQUALS=7 +NEQ=8 +LT=9 +LE=10 +GT=11 +GE=12 +LIKE=13 +NOT_LIKE=14 +ILIKE=15 +NOT_ILIKE=16 +BETWEEN=17 +NOT_BETWEEN=18 +EXISTS=19 +NOT_EXISTS=20 +REGEXP=21 +NOT_REGEXP=22 +CONTAINS=23 +NOT_CONTAINS=24 +IN=25 +NOT_IN=26 +NOT=27 +AND=28 +OR=29 +HAS=30 +HASANY=31 +HASALL=32 +HASNONE=33 +BOOL=34 +NUMBER=35 +QUOTED_TEXT=36 +KEY=37 +WS=38 +'('=1 +')'=2 +'['=3 +']'=4 +','=5 +'!='=7 +'<>'=8 +'<'=9 +'<='=10 +'>'=11 +'>='=12 diff --git a/frontend/src/query-grammar/.antlr/FilterQueryParser.java b/frontend/src/query-grammar/.antlr/FilterQueryParser.java new file mode 100644 index 000000000000..cadd9fe33d7c --- /dev/null +++ b/frontend/src/query-grammar/.antlr/FilterQueryParser.java @@ -0,0 +1,1413 @@ +// Generated from /Users/younix/Documents/SigNoz-Repos/signoz/frontend/src/query-grammar/FilterQuery.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 FilterQueryParser 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 + LPAREN=1, RPAREN=2, LBRACK=3, RBRACK=4, COMMA=5, EQUALS=6, NOT_EQUALS=7, + NEQ=8, LT=9, LE=10, GT=11, GE=12, LIKE=13, NOT_LIKE=14, ILIKE=15, NOT_ILIKE=16, + BETWEEN=17, NOT_BETWEEN=18, EXISTS=19, NOT_EXISTS=20, REGEXP=21, NOT_REGEXP=22, + CONTAINS=23, NOT_CONTAINS=24, IN=25, NOT_IN=26, NOT=27, AND=28, OR=29, + HAS=30, HASANY=31, HASALL=32, HASNONE=33, BOOL=34, NUMBER=35, QUOTED_TEXT=36, + KEY=37, WS=38; + public static final int + RULE_query = 0, RULE_expression = 1, RULE_orExpression = 2, RULE_andExpression = 3, + RULE_unaryExpression = 4, RULE_primary = 5, RULE_comparison = 6, RULE_inClause = 7, + RULE_notInClause = 8, RULE_valueList = 9, RULE_fullText = 10, RULE_functionCall = 11, + RULE_functionParamList = 12, RULE_functionParam = 13, RULE_array = 14, + RULE_value = 15, RULE_key = 16; + private static String[] makeRuleNames() { + return new String[] { + "query", "expression", "orExpression", "andExpression", "unaryExpression", + "primary", "comparison", "inClause", "notInClause", "valueList", "fullText", + "functionCall", "functionParamList", "functionParam", "array", "value", + "key" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'('", "')'", "'['", "']'", "','", null, "'!='", "'<>'", "'<'", + "'<='", "'>'", "'>='" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, "LPAREN", "RPAREN", "LBRACK", "RBRACK", "COMMA", "EQUALS", "NOT_EQUALS", + "NEQ", "LT", "LE", "GT", "GE", "LIKE", "NOT_LIKE", "ILIKE", "NOT_ILIKE", + "BETWEEN", "NOT_BETWEEN", "EXISTS", "NOT_EXISTS", "REGEXP", "NOT_REGEXP", + "CONTAINS", "NOT_CONTAINS", "IN", "NOT_IN", "NOT", "AND", "OR", "HAS", + "HASANY", "HASALL", "HASNONE", "BOOL", "NUMBER", "QUOTED_TEXT", "KEY", + "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 "FilterQuery.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public FilterQueryParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class QueryContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public TerminalNode EOF() { return getToken(FilterQueryParser.EOF, 0); } + public List AND() { return getTokens(FilterQueryParser.AND); } + public TerminalNode AND(int i) { + return getToken(FilterQueryParser.AND, i); + } + public List OR() { return getTokens(FilterQueryParser.OR); } + public TerminalNode OR(int i) { + return getToken(FilterQueryParser.OR, i); + } + 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); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(34); + expression(); + setState(40); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 223204081666L) != 0)) { + { + setState(38); + _errHandler.sync(this); + switch (_input.LA(1)) { + case AND: + case OR: + { + setState(35); + _la = _input.LA(1); + if ( !(_la==AND || _la==OR) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(36); + expression(); + } + break; + case LPAREN: + case NOT: + case HAS: + case HASANY: + case HASALL: + case HASNONE: + case QUOTED_TEXT: + case KEY: + { + setState(37); + expression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + setState(42); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(43); + 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 ExpressionContext extends ParserRuleContext { + public OrExpressionContext orExpression() { + return getRuleContext(OrExpressionContext.class,0); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(45); + orExpression(); + } + } + 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(FilterQueryParser.OR); } + public TerminalNode OR(int i) { + return getToken(FilterQueryParser.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, 4, RULE_orExpression); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(47); + andExpression(); + setState(52); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(48); + match(OR); + setState(49); + andExpression(); + } + } + } + setState(54); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + } + } + } + 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 unaryExpression() { + return getRuleContexts(UnaryExpressionContext.class); + } + public UnaryExpressionContext unaryExpression(int i) { + return getRuleContext(UnaryExpressionContext.class,i); + } + public List AND() { return getTokens(FilterQueryParser.AND); } + public TerminalNode AND(int i) { + return getToken(FilterQueryParser.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, 6, RULE_andExpression); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(55); + unaryExpression(); + setState(61); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,4,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + setState(59); + _errHandler.sync(this); + switch (_input.LA(1)) { + case AND: + { + setState(56); + match(AND); + setState(57); + unaryExpression(); + } + break; + case LPAREN: + case NOT: + case HAS: + case HASANY: + case HASALL: + case HASNONE: + case QUOTED_TEXT: + case KEY: + { + setState(58); + unaryExpression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + } + setState(63); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,4,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class UnaryExpressionContext extends ParserRuleContext { + public PrimaryContext primary() { + return getRuleContext(PrimaryContext.class,0); + } + public TerminalNode NOT() { return getToken(FilterQueryParser.NOT, 0); } + public UnaryExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_unaryExpression; } + } + + public final UnaryExpressionContext unaryExpression() throws RecognitionException { + UnaryExpressionContext _localctx = new UnaryExpressionContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_unaryExpression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(65); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==NOT) { + { + setState(64); + match(NOT); + } + } + + setState(67); + primary(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PrimaryContext extends ParserRuleContext { + public TerminalNode LPAREN() { return getToken(FilterQueryParser.LPAREN, 0); } + public OrExpressionContext orExpression() { + return getRuleContext(OrExpressionContext.class,0); + } + public TerminalNode RPAREN() { return getToken(FilterQueryParser.RPAREN, 0); } + public ComparisonContext comparison() { + return getRuleContext(ComparisonContext.class,0); + } + public FunctionCallContext functionCall() { + return getRuleContext(FunctionCallContext.class,0); + } + public FullTextContext fullText() { + return getRuleContext(FullTextContext.class,0); + } + public PrimaryContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_primary; } + } + + public final PrimaryContext primary() throws RecognitionException { + PrimaryContext _localctx = new PrimaryContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_primary); + try { + setState(76); + _errHandler.sync(this); + switch (_input.LA(1)) { + case LPAREN: + enterOuterAlt(_localctx, 1); + { + setState(69); + match(LPAREN); + setState(70); + orExpression(); + setState(71); + match(RPAREN); + } + break; + case KEY: + enterOuterAlt(_localctx, 2); + { + setState(73); + comparison(); + } + break; + case HAS: + case HASANY: + case HASALL: + case HASNONE: + enterOuterAlt(_localctx, 3); + { + setState(74); + functionCall(); + } + break; + case QUOTED_TEXT: + enterOuterAlt(_localctx, 4); + { + setState(75); + fullText(); + } + 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 ComparisonContext extends ParserRuleContext { + public KeyContext key() { + return getRuleContext(KeyContext.class,0); + } + public TerminalNode EQUALS() { return getToken(FilterQueryParser.EQUALS, 0); } + public List value() { + return getRuleContexts(ValueContext.class); + } + public ValueContext value(int i) { + return getRuleContext(ValueContext.class,i); + } + public TerminalNode NOT_EQUALS() { return getToken(FilterQueryParser.NOT_EQUALS, 0); } + public TerminalNode NEQ() { return getToken(FilterQueryParser.NEQ, 0); } + public TerminalNode LT() { return getToken(FilterQueryParser.LT, 0); } + public TerminalNode LE() { return getToken(FilterQueryParser.LE, 0); } + public TerminalNode GT() { return getToken(FilterQueryParser.GT, 0); } + public TerminalNode GE() { return getToken(FilterQueryParser.GE, 0); } + public TerminalNode LIKE() { return getToken(FilterQueryParser.LIKE, 0); } + public TerminalNode ILIKE() { return getToken(FilterQueryParser.ILIKE, 0); } + public TerminalNode NOT_LIKE() { return getToken(FilterQueryParser.NOT_LIKE, 0); } + public TerminalNode NOT_ILIKE() { return getToken(FilterQueryParser.NOT_ILIKE, 0); } + public TerminalNode BETWEEN() { return getToken(FilterQueryParser.BETWEEN, 0); } + public TerminalNode AND() { return getToken(FilterQueryParser.AND, 0); } + public TerminalNode NOT_BETWEEN() { return getToken(FilterQueryParser.NOT_BETWEEN, 0); } + public InClauseContext inClause() { + return getRuleContext(InClauseContext.class,0); + } + public NotInClauseContext notInClause() { + return getRuleContext(NotInClauseContext.class,0); + } + public TerminalNode EXISTS() { return getToken(FilterQueryParser.EXISTS, 0); } + public TerminalNode NOT_EXISTS() { return getToken(FilterQueryParser.NOT_EXISTS, 0); } + public TerminalNode REGEXP() { return getToken(FilterQueryParser.REGEXP, 0); } + public TerminalNode NOT_REGEXP() { return getToken(FilterQueryParser.NOT_REGEXP, 0); } + public TerminalNode CONTAINS() { return getToken(FilterQueryParser.CONTAINS, 0); } + public TerminalNode NOT_CONTAINS() { return getToken(FilterQueryParser.NOT_CONTAINS, 0); } + public ComparisonContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_comparison; } + } + + public final ComparisonContext comparison() throws RecognitionException { + ComparisonContext _localctx = new ComparisonContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_comparison); + int _la; + try { + setState(150); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(78); + key(); + setState(79); + match(EQUALS); + setState(80); + value(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(82); + key(); + setState(83); + _la = _input.LA(1); + if ( !(_la==NOT_EQUALS || _la==NEQ) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(84); + value(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(86); + key(); + setState(87); + match(LT); + setState(88); + value(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(90); + key(); + setState(91); + match(LE); + setState(92); + value(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(94); + key(); + setState(95); + match(GT); + setState(96); + value(); + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(98); + key(); + setState(99); + match(GE); + setState(100); + value(); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(102); + key(); + setState(103); + _la = _input.LA(1); + if ( !(_la==LIKE || _la==ILIKE) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(104); + value(); + } + break; + case 8: + enterOuterAlt(_localctx, 8); + { + setState(106); + key(); + setState(107); + _la = _input.LA(1); + if ( !(_la==NOT_LIKE || _la==NOT_ILIKE) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(108); + value(); + } + break; + case 9: + enterOuterAlt(_localctx, 9); + { + setState(110); + key(); + setState(111); + match(BETWEEN); + setState(112); + value(); + setState(113); + match(AND); + setState(114); + value(); + } + break; + case 10: + enterOuterAlt(_localctx, 10); + { + setState(116); + key(); + setState(117); + match(NOT_BETWEEN); + setState(118); + value(); + setState(119); + match(AND); + setState(120); + value(); + } + break; + case 11: + enterOuterAlt(_localctx, 11); + { + setState(122); + key(); + setState(123); + inClause(); + } + break; + case 12: + enterOuterAlt(_localctx, 12); + { + setState(125); + key(); + setState(126); + notInClause(); + } + break; + case 13: + enterOuterAlt(_localctx, 13); + { + setState(128); + key(); + setState(129); + match(EXISTS); + } + break; + case 14: + enterOuterAlt(_localctx, 14); + { + setState(131); + key(); + setState(132); + match(NOT_EXISTS); + } + break; + case 15: + enterOuterAlt(_localctx, 15); + { + setState(134); + key(); + setState(135); + match(REGEXP); + setState(136); + value(); + } + break; + case 16: + enterOuterAlt(_localctx, 16); + { + setState(138); + key(); + setState(139); + match(NOT_REGEXP); + setState(140); + value(); + } + break; + case 17: + enterOuterAlt(_localctx, 17); + { + setState(142); + key(); + setState(143); + match(CONTAINS); + setState(144); + value(); + } + break; + case 18: + enterOuterAlt(_localctx, 18); + { + setState(146); + key(); + setState(147); + match(NOT_CONTAINS); + setState(148); + value(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class InClauseContext extends ParserRuleContext { + public TerminalNode IN() { return getToken(FilterQueryParser.IN, 0); } + public TerminalNode LPAREN() { return getToken(FilterQueryParser.LPAREN, 0); } + public ValueListContext valueList() { + return getRuleContext(ValueListContext.class,0); + } + public TerminalNode RPAREN() { return getToken(FilterQueryParser.RPAREN, 0); } + public TerminalNode LBRACK() { return getToken(FilterQueryParser.LBRACK, 0); } + public TerminalNode RBRACK() { return getToken(FilterQueryParser.RBRACK, 0); } + public InClauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_inClause; } + } + + public final InClauseContext inClause() throws RecognitionException { + InClauseContext _localctx = new InClauseContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_inClause); + try { + setState(162); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(152); + match(IN); + setState(153); + match(LPAREN); + setState(154); + valueList(); + setState(155); + match(RPAREN); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(157); + match(IN); + setState(158); + match(LBRACK); + setState(159); + valueList(); + setState(160); + match(RBRACK); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NotInClauseContext extends ParserRuleContext { + public TerminalNode NOT_IN() { return getToken(FilterQueryParser.NOT_IN, 0); } + public TerminalNode LPAREN() { return getToken(FilterQueryParser.LPAREN, 0); } + public ValueListContext valueList() { + return getRuleContext(ValueListContext.class,0); + } + public TerminalNode RPAREN() { return getToken(FilterQueryParser.RPAREN, 0); } + public TerminalNode LBRACK() { return getToken(FilterQueryParser.LBRACK, 0); } + public TerminalNode RBRACK() { return getToken(FilterQueryParser.RBRACK, 0); } + public NotInClauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_notInClause; } + } + + public final NotInClauseContext notInClause() throws RecognitionException { + NotInClauseContext _localctx = new NotInClauseContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_notInClause); + try { + setState(174); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(164); + match(NOT_IN); + setState(165); + match(LPAREN); + setState(166); + valueList(); + setState(167); + match(RPAREN); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(169); + match(NOT_IN); + setState(170); + match(LBRACK); + setState(171); + valueList(); + setState(172); + match(RBRACK); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ValueListContext extends ParserRuleContext { + public List value() { + return getRuleContexts(ValueContext.class); + } + public ValueContext value(int i) { + return getRuleContext(ValueContext.class,i); + } + public List COMMA() { return getTokens(FilterQueryParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(FilterQueryParser.COMMA, i); + } + public ValueListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_valueList; } + } + + public final ValueListContext valueList() throws RecognitionException { + ValueListContext _localctx = new ValueListContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_valueList); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(176); + value(); + setState(181); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(177); + match(COMMA); + setState(178); + value(); + } + } + setState(183); + _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 FullTextContext extends ParserRuleContext { + public TerminalNode QUOTED_TEXT() { return getToken(FilterQueryParser.QUOTED_TEXT, 0); } + public FullTextContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_fullText; } + } + + public final FullTextContext fullText() throws RecognitionException { + FullTextContext _localctx = new FullTextContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_fullText); + try { + enterOuterAlt(_localctx, 1); + { + setState(184); + match(QUOTED_TEXT); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FunctionCallContext extends ParserRuleContext { + public TerminalNode LPAREN() { return getToken(FilterQueryParser.LPAREN, 0); } + public FunctionParamListContext functionParamList() { + return getRuleContext(FunctionParamListContext.class,0); + } + public TerminalNode RPAREN() { return getToken(FilterQueryParser.RPAREN, 0); } + public TerminalNode HAS() { return getToken(FilterQueryParser.HAS, 0); } + public TerminalNode HASANY() { return getToken(FilterQueryParser.HASANY, 0); } + public TerminalNode HASALL() { return getToken(FilterQueryParser.HASALL, 0); } + public TerminalNode HASNONE() { return getToken(FilterQueryParser.HASNONE, 0); } + public FunctionCallContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionCall; } + } + + public final FunctionCallContext functionCall() throws RecognitionException { + FunctionCallContext _localctx = new FunctionCallContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_functionCall); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(186); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 16106127360L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(187); + match(LPAREN); + setState(188); + functionParamList(); + setState(189); + 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 FunctionParamListContext extends ParserRuleContext { + public List functionParam() { + return getRuleContexts(FunctionParamContext.class); + } + public FunctionParamContext functionParam(int i) { + return getRuleContext(FunctionParamContext.class,i); + } + public List COMMA() { return getTokens(FilterQueryParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(FilterQueryParser.COMMA, i); + } + public FunctionParamListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionParamList; } + } + + public final FunctionParamListContext functionParamList() throws RecognitionException { + FunctionParamListContext _localctx = new FunctionParamListContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_functionParamList); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(191); + functionParam(); + setState(196); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(192); + match(COMMA); + setState(193); + functionParam(); + } + } + setState(198); + _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 FunctionParamContext extends ParserRuleContext { + public KeyContext key() { + return getRuleContext(KeyContext.class,0); + } + public ValueContext value() { + return getRuleContext(ValueContext.class,0); + } + public ArrayContext array() { + return getRuleContext(ArrayContext.class,0); + } + public FunctionParamContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionParam; } + } + + public final FunctionParamContext functionParam() throws RecognitionException { + FunctionParamContext _localctx = new FunctionParamContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_functionParam); + try { + setState(202); + _errHandler.sync(this); + switch (_input.LA(1)) { + case KEY: + enterOuterAlt(_localctx, 1); + { + setState(199); + key(); + } + break; + case BOOL: + case NUMBER: + case QUOTED_TEXT: + enterOuterAlt(_localctx, 2); + { + setState(200); + value(); + } + break; + case LBRACK: + enterOuterAlt(_localctx, 3); + { + setState(201); + array(); + } + 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 ArrayContext extends ParserRuleContext { + public TerminalNode LBRACK() { return getToken(FilterQueryParser.LBRACK, 0); } + public ValueListContext valueList() { + return getRuleContext(ValueListContext.class,0); + } + public TerminalNode RBRACK() { return getToken(FilterQueryParser.RBRACK, 0); } + public ArrayContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_array; } + } + + public final ArrayContext array() throws RecognitionException { + ArrayContext _localctx = new ArrayContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_array); + try { + enterOuterAlt(_localctx, 1); + { + setState(204); + match(LBRACK); + setState(205); + valueList(); + setState(206); + match(RBRACK); + } + } + 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 QUOTED_TEXT() { return getToken(FilterQueryParser.QUOTED_TEXT, 0); } + public TerminalNode NUMBER() { return getToken(FilterQueryParser.NUMBER, 0); } + public TerminalNode BOOL() { return getToken(FilterQueryParser.BOOL, 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, 30, RULE_value); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(208); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 120259084288L) != 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; + } + + @SuppressWarnings("CheckReturnValue") + public static class KeyContext extends ParserRuleContext { + public TerminalNode KEY() { return getToken(FilterQueryParser.KEY, 0); } + public KeyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_key; } + } + + public final KeyContext key() throws RecognitionException { + KeyContext _localctx = new KeyContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_key); + try { + enterOuterAlt(_localctx, 1); + { + setState(210); + match(KEY); + } + } + 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&\u00d5\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\u0002\u000f\u0007\u000f"+ + "\u0002\u0010\u0007\u0010\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ + "\u0005\u0000\'\b\u0000\n\u0000\f\u0000*\t\u0000\u0001\u0000\u0001\u0000"+ + "\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0005\u0002"+ + "3\b\u0002\n\u0002\f\u00026\t\u0002\u0001\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0005\u0003<\b\u0003\n\u0003\f\u0003?\t\u0003\u0001\u0004"+ + "\u0003\u0004B\b\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+ + "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0003\u0005"+ + "M\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0003\u0006\u0097\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0001\u0007\u0003\u0007\u00a3\b\u0007\u0001\b\u0001\b\u0001\b\u0001\b"+ + "\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0003\b\u00af\b\b\u0001"+ + "\t\u0001\t\u0001\t\u0005\t\u00b4\b\t\n\t\f\t\u00b7\t\t\u0001\n\u0001\n"+ + "\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\f\u0001"+ + "\f\u0001\f\u0005\f\u00c3\b\f\n\f\f\f\u00c6\t\f\u0001\r\u0001\r\u0001\r"+ + "\u0003\r\u00cb\b\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001"+ + "\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0000\u0000\u0011"+ + "\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a"+ + "\u001c\u001e \u0000\u0006\u0001\u0000\u001c\u001d\u0001\u0000\u0007\b"+ + "\u0002\u0000\r\r\u000f\u000f\u0002\u0000\u000e\u000e\u0010\u0010\u0001"+ + "\u0000\u001e!\u0001\u0000\"$\u00e3\u0000\"\u0001\u0000\u0000\u0000\u0002"+ + "-\u0001\u0000\u0000\u0000\u0004/\u0001\u0000\u0000\u0000\u00067\u0001"+ + "\u0000\u0000\u0000\bA\u0001\u0000\u0000\u0000\nL\u0001\u0000\u0000\u0000"+ + "\f\u0096\u0001\u0000\u0000\u0000\u000e\u00a2\u0001\u0000\u0000\u0000\u0010"+ + "\u00ae\u0001\u0000\u0000\u0000\u0012\u00b0\u0001\u0000\u0000\u0000\u0014"+ + "\u00b8\u0001\u0000\u0000\u0000\u0016\u00ba\u0001\u0000\u0000\u0000\u0018"+ + "\u00bf\u0001\u0000\u0000\u0000\u001a\u00ca\u0001\u0000\u0000\u0000\u001c"+ + "\u00cc\u0001\u0000\u0000\u0000\u001e\u00d0\u0001\u0000\u0000\u0000 \u00d2"+ + "\u0001\u0000\u0000\u0000\"(\u0003\u0002\u0001\u0000#$\u0007\u0000\u0000"+ + "\u0000$\'\u0003\u0002\u0001\u0000%\'\u0003\u0002\u0001\u0000&#\u0001\u0000"+ + "\u0000\u0000&%\u0001\u0000\u0000\u0000\'*\u0001\u0000\u0000\u0000(&\u0001"+ + "\u0000\u0000\u0000()\u0001\u0000\u0000\u0000)+\u0001\u0000\u0000\u0000"+ + "*(\u0001\u0000\u0000\u0000+,\u0005\u0000\u0000\u0001,\u0001\u0001\u0000"+ + "\u0000\u0000-.\u0003\u0004\u0002\u0000.\u0003\u0001\u0000\u0000\u0000"+ + "/4\u0003\u0006\u0003\u000001\u0005\u001d\u0000\u000013\u0003\u0006\u0003"+ + "\u000020\u0001\u0000\u0000\u000036\u0001\u0000\u0000\u000042\u0001\u0000"+ + "\u0000\u000045\u0001\u0000\u0000\u00005\u0005\u0001\u0000\u0000\u0000"+ + "64\u0001\u0000\u0000\u00007=\u0003\b\u0004\u000089\u0005\u001c\u0000\u0000"+ + "9<\u0003\b\u0004\u0000:<\u0003\b\u0004\u0000;8\u0001\u0000\u0000\u0000"+ + ";:\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000>\u0007\u0001\u0000\u0000\u0000?=\u0001"+ + "\u0000\u0000\u0000@B\u0005\u001b\u0000\u0000A@\u0001\u0000\u0000\u0000"+ + "AB\u0001\u0000\u0000\u0000BC\u0001\u0000\u0000\u0000CD\u0003\n\u0005\u0000"+ + "D\t\u0001\u0000\u0000\u0000EF\u0005\u0001\u0000\u0000FG\u0003\u0004\u0002"+ + "\u0000GH\u0005\u0002\u0000\u0000HM\u0001\u0000\u0000\u0000IM\u0003\f\u0006"+ + "\u0000JM\u0003\u0016\u000b\u0000KM\u0003\u0014\n\u0000LE\u0001\u0000\u0000"+ + "\u0000LI\u0001\u0000\u0000\u0000LJ\u0001\u0000\u0000\u0000LK\u0001\u0000"+ + "\u0000\u0000M\u000b\u0001\u0000\u0000\u0000NO\u0003 \u0010\u0000OP\u0005"+ + "\u0006\u0000\u0000PQ\u0003\u001e\u000f\u0000Q\u0097\u0001\u0000\u0000"+ + "\u0000RS\u0003 \u0010\u0000ST\u0007\u0001\u0000\u0000TU\u0003\u001e\u000f"+ + "\u0000U\u0097\u0001\u0000\u0000\u0000VW\u0003 \u0010\u0000WX\u0005\t\u0000"+ + "\u0000XY\u0003\u001e\u000f\u0000Y\u0097\u0001\u0000\u0000\u0000Z[\u0003"+ + " \u0010\u0000[\\\u0005\n\u0000\u0000\\]\u0003\u001e\u000f\u0000]\u0097"+ + "\u0001\u0000\u0000\u0000^_\u0003 \u0010\u0000_`\u0005\u000b\u0000\u0000"+ + "`a\u0003\u001e\u000f\u0000a\u0097\u0001\u0000\u0000\u0000bc\u0003 \u0010"+ + "\u0000cd\u0005\f\u0000\u0000de\u0003\u001e\u000f\u0000e\u0097\u0001\u0000"+ + "\u0000\u0000fg\u0003 \u0010\u0000gh\u0007\u0002\u0000\u0000hi\u0003\u001e"+ + "\u000f\u0000i\u0097\u0001\u0000\u0000\u0000jk\u0003 \u0010\u0000kl\u0007"+ + "\u0003\u0000\u0000lm\u0003\u001e\u000f\u0000m\u0097\u0001\u0000\u0000"+ + "\u0000no\u0003 \u0010\u0000op\u0005\u0011\u0000\u0000pq\u0003\u001e\u000f"+ + "\u0000qr\u0005\u001c\u0000\u0000rs\u0003\u001e\u000f\u0000s\u0097\u0001"+ + "\u0000\u0000\u0000tu\u0003 \u0010\u0000uv\u0005\u0012\u0000\u0000vw\u0003"+ + "\u001e\u000f\u0000wx\u0005\u001c\u0000\u0000xy\u0003\u001e\u000f\u0000"+ + "y\u0097\u0001\u0000\u0000\u0000z{\u0003 \u0010\u0000{|\u0003\u000e\u0007"+ + "\u0000|\u0097\u0001\u0000\u0000\u0000}~\u0003 \u0010\u0000~\u007f\u0003"+ + "\u0010\b\u0000\u007f\u0097\u0001\u0000\u0000\u0000\u0080\u0081\u0003 "+ + "\u0010\u0000\u0081\u0082\u0005\u0013\u0000\u0000\u0082\u0097\u0001\u0000"+ + "\u0000\u0000\u0083\u0084\u0003 \u0010\u0000\u0084\u0085\u0005\u0014\u0000"+ + "\u0000\u0085\u0097\u0001\u0000\u0000\u0000\u0086\u0087\u0003 \u0010\u0000"+ + "\u0087\u0088\u0005\u0015\u0000\u0000\u0088\u0089\u0003\u001e\u000f\u0000"+ + "\u0089\u0097\u0001\u0000\u0000\u0000\u008a\u008b\u0003 \u0010\u0000\u008b"+ + "\u008c\u0005\u0016\u0000\u0000\u008c\u008d\u0003\u001e\u000f\u0000\u008d"+ + "\u0097\u0001\u0000\u0000\u0000\u008e\u008f\u0003 \u0010\u0000\u008f\u0090"+ + "\u0005\u0017\u0000\u0000\u0090\u0091\u0003\u001e\u000f\u0000\u0091\u0097"+ + "\u0001\u0000\u0000\u0000\u0092\u0093\u0003 \u0010\u0000\u0093\u0094\u0005"+ + "\u0018\u0000\u0000\u0094\u0095\u0003\u001e\u000f\u0000\u0095\u0097\u0001"+ + "\u0000\u0000\u0000\u0096N\u0001\u0000\u0000\u0000\u0096R\u0001\u0000\u0000"+ + "\u0000\u0096V\u0001\u0000\u0000\u0000\u0096Z\u0001\u0000\u0000\u0000\u0096"+ + "^\u0001\u0000\u0000\u0000\u0096b\u0001\u0000\u0000\u0000\u0096f\u0001"+ + "\u0000\u0000\u0000\u0096j\u0001\u0000\u0000\u0000\u0096n\u0001\u0000\u0000"+ + "\u0000\u0096t\u0001\u0000\u0000\u0000\u0096z\u0001\u0000\u0000\u0000\u0096"+ + "}\u0001\u0000\u0000\u0000\u0096\u0080\u0001\u0000\u0000\u0000\u0096\u0083"+ + "\u0001\u0000\u0000\u0000\u0096\u0086\u0001\u0000\u0000\u0000\u0096\u008a"+ + "\u0001\u0000\u0000\u0000\u0096\u008e\u0001\u0000\u0000\u0000\u0096\u0092"+ + "\u0001\u0000\u0000\u0000\u0097\r\u0001\u0000\u0000\u0000\u0098\u0099\u0005"+ + "\u0019\u0000\u0000\u0099\u009a\u0005\u0001\u0000\u0000\u009a\u009b\u0003"+ + "\u0012\t\u0000\u009b\u009c\u0005\u0002\u0000\u0000\u009c\u00a3\u0001\u0000"+ + "\u0000\u0000\u009d\u009e\u0005\u0019\u0000\u0000\u009e\u009f\u0005\u0003"+ + "\u0000\u0000\u009f\u00a0\u0003\u0012\t\u0000\u00a0\u00a1\u0005\u0004\u0000"+ + "\u0000\u00a1\u00a3\u0001\u0000\u0000\u0000\u00a2\u0098\u0001\u0000\u0000"+ + "\u0000\u00a2\u009d\u0001\u0000\u0000\u0000\u00a3\u000f\u0001\u0000\u0000"+ + "\u0000\u00a4\u00a5\u0005\u001a\u0000\u0000\u00a5\u00a6\u0005\u0001\u0000"+ + "\u0000\u00a6\u00a7\u0003\u0012\t\u0000\u00a7\u00a8\u0005\u0002\u0000\u0000"+ + "\u00a8\u00af\u0001\u0000\u0000\u0000\u00a9\u00aa\u0005\u001a\u0000\u0000"+ + "\u00aa\u00ab\u0005\u0003\u0000\u0000\u00ab\u00ac\u0003\u0012\t\u0000\u00ac"+ + "\u00ad\u0005\u0004\u0000\u0000\u00ad\u00af\u0001\u0000\u0000\u0000\u00ae"+ + "\u00a4\u0001\u0000\u0000\u0000\u00ae\u00a9\u0001\u0000\u0000\u0000\u00af"+ + "\u0011\u0001\u0000\u0000\u0000\u00b0\u00b5\u0003\u001e\u000f\u0000\u00b1"+ + "\u00b2\u0005\u0005\u0000\u0000\u00b2\u00b4\u0003\u001e\u000f\u0000\u00b3"+ + "\u00b1\u0001\u0000\u0000\u0000\u00b4\u00b7\u0001\u0000\u0000\u0000\u00b5"+ + "\u00b3\u0001\u0000\u0000\u0000\u00b5\u00b6\u0001\u0000\u0000\u0000\u00b6"+ + "\u0013\u0001\u0000\u0000\u0000\u00b7\u00b5\u0001\u0000\u0000\u0000\u00b8"+ + "\u00b9\u0005$\u0000\u0000\u00b9\u0015\u0001\u0000\u0000\u0000\u00ba\u00bb"+ + "\u0007\u0004\u0000\u0000\u00bb\u00bc\u0005\u0001\u0000\u0000\u00bc\u00bd"+ + "\u0003\u0018\f\u0000\u00bd\u00be\u0005\u0002\u0000\u0000\u00be\u0017\u0001"+ + "\u0000\u0000\u0000\u00bf\u00c4\u0003\u001a\r\u0000\u00c0\u00c1\u0005\u0005"+ + "\u0000\u0000\u00c1\u00c3\u0003\u001a\r\u0000\u00c2\u00c0\u0001\u0000\u0000"+ + "\u0000\u00c3\u00c6\u0001\u0000\u0000\u0000\u00c4\u00c2\u0001\u0000\u0000"+ + "\u0000\u00c4\u00c5\u0001\u0000\u0000\u0000\u00c5\u0019\u0001\u0000\u0000"+ + "\u0000\u00c6\u00c4\u0001\u0000\u0000\u0000\u00c7\u00cb\u0003 \u0010\u0000"+ + "\u00c8\u00cb\u0003\u001e\u000f\u0000\u00c9\u00cb\u0003\u001c\u000e\u0000"+ + "\u00ca\u00c7\u0001\u0000\u0000\u0000\u00ca\u00c8\u0001\u0000\u0000\u0000"+ + "\u00ca\u00c9\u0001\u0000\u0000\u0000\u00cb\u001b\u0001\u0000\u0000\u0000"+ + "\u00cc\u00cd\u0005\u0003\u0000\u0000\u00cd\u00ce\u0003\u0012\t\u0000\u00ce"+ + "\u00cf\u0005\u0004\u0000\u0000\u00cf\u001d\u0001\u0000\u0000\u0000\u00d0"+ + "\u00d1\u0007\u0005\u0000\u0000\u00d1\u001f\u0001\u0000\u0000\u0000\u00d2"+ + "\u00d3\u0005%\u0000\u0000\u00d3!\u0001\u0000\u0000\u0000\r&(4;=AL\u0096"+ + "\u00a2\u00ae\u00b5\u00c4\u00ca"; + 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/frontend/src/types/antlrQueryTypes.ts b/frontend/src/types/antlrQueryTypes.ts new file mode 100644 index 000000000000..22e0e5302015 --- /dev/null +++ b/frontend/src/types/antlrQueryTypes.ts @@ -0,0 +1,39 @@ +export interface IValidationResult { + isValid: boolean; + message: string; + errors: string[]; +} + +export interface IToken { + type: number; + text: string; + start: number; + stop: number; + channel?: number; +} + +export interface IQueryContext { + tokenType: number; + text: string; + start: number; + stop: number; + currentToken: string; + isInValue: boolean; + isInKey: boolean; + isInOperator: boolean; + isInFunction: boolean; +} + +export interface IDetailedError { + message: string; + line: number; + column: number; + offendingSymbol?: string; + expectedTokens?: string[]; +} + +export interface ASTNode { + type: string; + value?: string; + children?: ASTNode[]; +} diff --git a/frontend/src/utils/antlrQueryUtils.ts b/frontend/src/utils/antlrQueryUtils.ts new file mode 100644 index 000000000000..8d9054f2c876 --- /dev/null +++ b/frontend/src/utils/antlrQueryUtils.ts @@ -0,0 +1,340 @@ +/* eslint-disable sonarjs/no-collapsible-if */ +/* eslint-disable no-continue */ +/* eslint-disable sonarjs/cognitive-complexity */ +/* eslint-disable max-classes-per-file */ +import { CharStreams, CommonTokenStream } from 'antlr4'; +import FilterQueryLexer from 'parser/FilterQueryLexer'; +import FilterQueryParser from 'parser/FilterQueryParser'; +import { + IDetailedError, + IQueryContext, + IToken, + IValidationResult, +} from 'types/antlrQueryTypes'; + +// Custom error listener to capture ANTLR errors +class QueryErrorListener { + private errors: IDetailedError[] = []; + + syntaxError( + _recognizer: any, + offendingSymbol: any, + line: number, + column: number, + msg: string, + ): void { + // For unterminated quotes, we only want to show one error + if (this.hasUnterminatedQuoteError() && msg.includes('expecting')) { + return; + } + + const error: IDetailedError = { + message: msg, + line, + column, + offendingSymbol: offendingSymbol?.text || String(offendingSymbol), + }; + + // Extract expected tokens if available + if (msg.includes('expecting')) { + const expectedTokens = msg + .split('expecting')[1] + .trim() + .split(',') + .map((token) => token.trim()); + error.expectedTokens = expectedTokens; + } + + // Check if this is a duplicate error (same location and similar message) + const isDuplicate = this.errors.some( + (e) => + e.line === line && + e.column === column && + this.isSimilarError(e.message, msg), + ); + + if (!isDuplicate) { + this.errors.push(error); + } + } + + private hasUnterminatedQuoteError(): boolean { + return this.errors.some( + (error) => + error.message.includes('unterminated') || + (error.message.includes('missing') && error.message.includes("'")), + ); + } + + private isSimilarError = (msg1: string, msg2: string): boolean => { + // Consider errors similar if they're for the same core issue + const normalize = (msg: string): string => + msg.toLowerCase().replace(/['"`]/g, 'quote').replace(/\s+/g, ' ').trim(); + + return normalize(msg1) === normalize(msg2); + }; + + // eslint-disable-next-line @typescript-eslint/no-empty-function + reportAmbiguity = (): void => {}; + + // eslint-disable-next-line @typescript-eslint/no-empty-function + reportAttemptingFullContext = (): void => {}; + + // eslint-disable-next-line @typescript-eslint/no-empty-function + reportContextSensitivity = (): void => {}; + + getErrors(): IDetailedError[] { + return this.errors; + } + + hasErrors(): boolean { + return this.errors.length > 0; + } + + getFormattedErrors(): string[] { + return this.errors.map((error) => { + let message = `Line ${error.line}:${error.column} - ${error.message}`; + + if (error.offendingSymbol && error.offendingSymbol !== 'undefined') { + message += `\nOffending symbol: '${error.offendingSymbol}'`; + } + + if (error.expectedTokens && error.expectedTokens.length > 0) { + message += `\nExpected: ${error.expectedTokens.join(', ')}`; + } + + return message; + }); + } +} + +export const validateQuery = (query: string): IValidationResult => { + // Empty query is considered invalid + if (!query.trim()) { + return { + isValid: false, + message: 'Query cannot be empty', + errors: ['Query cannot be empty'], + }; + } + + try { + const errorListener = new QueryErrorListener(); + const inputStream = CharStreams.fromString(query); + + // Setup lexer + const lexer = new FilterQueryLexer(inputStream); + lexer.removeErrorListeners(); // Remove default error listeners + lexer.addErrorListener(errorListener); + + // Setup parser + const tokenStream = new CommonTokenStream(lexer); + const parser = new FilterQueryParser(tokenStream); + parser.removeErrorListeners(); // Remove default error listeners + parser.addErrorListener(errorListener); + + // Try parsing + const parsedTree = parser.query(); + + console.log('parsedTree', parsedTree); + + // Check if any errors were captured + if (errorListener.hasErrors()) { + return { + isValid: false, + message: 'Query syntax error', + errors: errorListener.getFormattedErrors(), + }; + } + + return { + isValid: true, + message: 'Query is valid!', + errors: [], + }; + } catch (error) { + const errorMessage = + error instanceof Error ? error.message : 'Invalid query syntax'; + return { + isValid: false, + message: 'Invalid query syntax', + errors: [errorMessage], + }; + } +}; + +export function getQueryContextAtCursor( + query: string, + cursorIndex: number, +): IQueryContext { + try { + // Create input stream and lexer + const input = query || ''; + const chars = CharStreams.fromString(input); + const lexer = new FilterQueryLexer(chars); + + // Create token stream and force token generation + const tokenStream = new CommonTokenStream(lexer); + tokenStream.fill(); + + // Get all tokens including whitespace + const allTokens = tokenStream.tokens as IToken[]; + + // Find exact token at cursor, including whitespace + let exactToken: IToken | null = null; + let previousToken: IToken | null = null; + let nextToken: IToken | null = null; + + // Handle cursor at the very end of input + if (cursorIndex === input.length && allTokens.length > 0) { + const lastRealToken = allTokens + .filter((t) => t.type !== FilterQueryLexer.EOF) + .pop(); + if (lastRealToken) { + exactToken = lastRealToken; + previousToken = + allTokens.filter((t) => t.stop < lastRealToken.start).pop() || null; + } + } else { + // Normal token search + for (let i = 0; i < allTokens.length; i++) { + const token = allTokens[i]; + // Skip EOF token in normal search + if (token.type === FilterQueryLexer.EOF) { + continue; + } + + // Check if cursor is within token bounds (inclusive) + if (token.start <= cursorIndex && cursorIndex <= token.stop + 1) { + exactToken = token; + previousToken = i > 0 ? allTokens[i - 1] : null; + nextToken = i < allTokens.length - 1 ? allTokens[i + 1] : null; + break; + } + } + + // If cursor is between tokens, find surrounding tokens + if (!exactToken) { + for (let i = 0; i < allTokens.length - 1; i++) { + const current = allTokens[i]; + const next = allTokens[i + 1]; + if (current.type === FilterQueryLexer.EOF) { + continue; + } + if (next.type === FilterQueryLexer.EOF) { + continue; + } + + if (current.stop + 1 < cursorIndex && cursorIndex < next.start) { + previousToken = current; + nextToken = next; + break; + } + } + } + } + + console.log('Cursor context:', { + cursorIndex, + query, + exact: exactToken, + prev: previousToken, + next: nextToken, + }); + + // Determine the context based on cursor position and surrounding tokens + let currentToken: IToken | null = null; + + if (exactToken) { + // If cursor is in a non-whitespace token, use that + if (exactToken.channel === 0) { + currentToken = exactToken; + } else { + // If in whitespace, use the previous non-whitespace token + currentToken = previousToken?.channel === 0 ? previousToken : nextToken; + } + } else if (previousToken?.channel === 0) { + // If between tokens, prefer the previous non-whitespace token + currentToken = previousToken; + } else if (nextToken?.channel === 0) { + // Otherwise use the next non-whitespace token + currentToken = nextToken; + } + + // If still no token (empty query or all whitespace), return default context + if (!currentToken) { + return { + tokenType: -1, + text: '', + start: cursorIndex, + stop: cursorIndex, + currentToken: '', + isInValue: false, + isInKey: false, + isInOperator: false, + isInFunction: false, + }; + } + + // Determine the context based on the token type + const isInValue = [ + FilterQueryLexer.QUOTED_TEXT, + FilterQueryLexer.NUMBER, + FilterQueryLexer.BOOL, + ].includes(currentToken.type); + + const isInKey = currentToken.type === FilterQueryLexer.KEY; + + const isInOperator = [ + FilterQueryLexer.EQUALS, + FilterQueryLexer.NOT_EQUALS, + FilterQueryLexer.NEQ, + FilterQueryLexer.LT, + FilterQueryLexer.LE, + FilterQueryLexer.GT, + FilterQueryLexer.GE, + FilterQueryLexer.LIKE, + FilterQueryLexer.NOT_LIKE, + FilterQueryLexer.ILIKE, + FilterQueryLexer.NOT_ILIKE, + FilterQueryLexer.BETWEEN, + FilterQueryLexer.EXISTS, + FilterQueryLexer.REGEXP, + FilterQueryLexer.CONTAINS, + FilterQueryLexer.IN, + FilterQueryLexer.NOT, + ].includes(currentToken.type); + + const isInFunction = [ + FilterQueryLexer.HAS, + FilterQueryLexer.HASANY, + FilterQueryLexer.HASALL, + FilterQueryLexer.HASNONE, + ].includes(currentToken.type); + + return { + tokenType: currentToken.type, + text: currentToken.text, + start: currentToken.start, + stop: currentToken.stop, + currentToken: currentToken.text, + isInValue, + isInKey, + isInOperator, + isInFunction, + }; + } catch (error) { + console.error('Error in getQueryContextAtCursor:', error); + return { + tokenType: -1, + text: '', + start: cursorIndex, + stop: cursorIndex, + currentToken: '', + isInValue: false, + isInKey: false, + isInOperator: false, + isInFunction: false, + }; + } +}