diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx b/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx index 40854293b9be..f0a7171719de 100644 --- a/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx +++ b/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx @@ -14,10 +14,10 @@ import { Color } from '@signozhq/design-tokens'; import { copilot } from '@uiw/codemirror-theme-copilot'; import CodeMirror, { EditorView, - Extension, keymap, + Extension, } from '@uiw/react-codemirror'; -import { Button, Card, Collapse, Popover, Tag } from 'antd'; +import { Button, Card, Collapse, Popover, Space, Tag, Typography } from 'antd'; import { getKeySuggestions } from 'api/querySuggestions/getKeySuggestions'; import { getValueSuggestions } from 'api/querySuggestions/getValueSuggestion'; import cx from 'classnames'; @@ -197,7 +197,6 @@ function QuerySearch({ return op.toUpperCase() === 'IN' || op.toUpperCase() === 'NOT IN'; }; - // Helper function to format value based on operator type and value type const formatValueForOperator = ( value: string, operatorToken: string | undefined, @@ -216,7 +215,10 @@ function QuerySearch({ // If we're already inside bracket list for IN operator and it's a string value // just wrap in quotes but not brackets (we're already in brackets) - if (type === 'value' || type === 'keyword') { + if ( + (type === 'value' || type === 'keyword') && + !/^[a-zA-Z0-9_][a-zA-Z0-9_.\[\]]*$/.test(value) + ) { return wrapStringValueInQuotes(value); } @@ -1055,7 +1057,7 @@ function QuerySearch({ )} - {/* + {queryContext && (
@@ -1098,7 +1100,7 @@ function QuerySearch({
- )} */} + )} ); } diff --git a/frontend/src/parser/FilterQuery.interp b/frontend/src/parser/FilterQuery.interp index 114118d40ad1..59028e95f718 100644 --- a/frontend/src/parser/FilterQuery.interp +++ b/frontend/src/parser/FilterQuery.interp @@ -101,4 +101,4 @@ 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 +[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, 37, 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/parser/FilterQueryLexer.ts b/frontend/src/parser/FilterQueryLexer.ts index 50a4410a75ea..4eff211d3086 100644 --- a/frontend/src/parser/FilterQueryLexer.ts +++ b/frontend/src/parser/FilterQueryLexer.ts @@ -4,13 +4,14 @@ import { ATN, ATNDeserializer, CharStream, - DecisionState, DFA, + DecisionState, + DFA, Lexer, LexerATNSimulator, RuleContext, PredictionContextCache, - Token -} from "antlr4"; + Token, +} from 'antlr4'; export default class FilterQueryLexer extends Lexer { public static readonly LPAREN = 1; public static readonly RPAREN = 2; @@ -52,198 +53,3491 @@ export default class FilterQueryLexer extends Lexer { public static readonly WS = 38; public static readonly EOF = Token.EOF; - public static readonly channelNames: string[] = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]; - public static readonly literalNames: (string | null)[] = [ null, "'('", - "')'", "'['", - "']'", "','", - null, "'!='", - "'<>'", "'<'", - "'<='", "'>'", - "'>='" ]; - public static readonly symbolicNames: (string | null)[] = [ 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" ]; - public static readonly modeNames: string[] = [ "DEFAULT_MODE", ]; + public static readonly channelNames: string[] = [ + 'DEFAULT_TOKEN_CHANNEL', + 'HIDDEN', + ]; + public static readonly literalNames: (string | null)[] = [ + null, + "'('", + "')'", + "'['", + "']'", + "','", + null, + "'!='", + "'<>'", + "'<'", + "'<='", + "'>'", + "'>='", + ]; + public static readonly symbolicNames: (string | null)[] = [ + 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', + ]; + public static readonly modeNames: string[] = ['DEFAULT_MODE']; public static readonly ruleNames: 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", + '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', ]; - constructor(input: CharStream) { super(input); - this._interp = new LexerATNSimulator(this, FilterQueryLexer._ATN, FilterQueryLexer.DecisionsToDFA, new PredictionContextCache()); + this._interp = new LexerATNSimulator( + this, + FilterQueryLexer._ATN, + FilterQueryLexer.DecisionsToDFA, + new PredictionContextCache(), + ); } - public get grammarFileName(): string { return "FilterQuery.g4"; } + public get grammarFileName(): string { + return 'FilterQuery.g4'; + } - public get literalNames(): (string | null)[] { return FilterQueryLexer.literalNames; } - public get symbolicNames(): (string | null)[] { return FilterQueryLexer.symbolicNames; } - public get ruleNames(): string[] { return FilterQueryLexer.ruleNames; } + public get literalNames(): (string | null)[] { + return FilterQueryLexer.literalNames; + } + public get symbolicNames(): (string | null)[] { + return FilterQueryLexer.symbolicNames; + } + public get ruleNames(): string[] { + return FilterQueryLexer.ruleNames; + } - public get serializedATN(): number[] { return FilterQueryLexer._serializedATN; } + public get serializedATN(): number[] { + return FilterQueryLexer._serializedATN; + } - public get channelNames(): string[] { return FilterQueryLexer.channelNames; } + public get channelNames(): string[] { + return FilterQueryLexer.channelNames; + } - public get modeNames(): string[] { return FilterQueryLexer.modeNames; } + public get modeNames(): string[] { + return FilterQueryLexer.modeNames; + } - public static readonly _serializedATN: number[] = [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]; + public static readonly _serializedATN: number[] = [ + 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, + ]; private static __ATN: ATN; public static get _ATN(): ATN { if (!FilterQueryLexer.__ATN) { - FilterQueryLexer.__ATN = new ATNDeserializer().deserialize(FilterQueryLexer._serializedATN); + FilterQueryLexer.__ATN = new ATNDeserializer().deserialize( + FilterQueryLexer._serializedATN, + ); } return FilterQueryLexer.__ATN; } - - static DecisionsToDFA = FilterQueryLexer._ATN.decisionToState.map( (ds: DecisionState, index: number) => new DFA(ds, index) ); -} \ No newline at end of file + static DecisionsToDFA = FilterQueryLexer._ATN.decisionToState.map( + (ds: DecisionState, index: number) => new DFA(ds, index), + ); +} diff --git a/frontend/src/parser/FilterQueryListener.ts b/frontend/src/parser/FilterQueryListener.ts index fc8823d37bb4..31cdb19c9644 100644 --- a/frontend/src/parser/FilterQueryListener.ts +++ b/frontend/src/parser/FilterQueryListener.ts @@ -2,25 +2,23 @@ import { ParseTreeListener } from 'antlr4'; -import { - AndExpressionContext, - ArrayContext, - ComparisonContext, - ExpressionContext, - FullTextContext, - FunctionCallContext, - FunctionParamContext, - FunctionParamListContext, - InClauseContext, - KeyContext, - NotInClauseContext, - OrExpressionContext, - PrimaryContext, - QueryContext, - UnaryExpressionContext, - ValueContext, - ValueListContext, -} from './FilterQueryParser'; +import { QueryContext } from './FilterQueryParser'; +import { ExpressionContext } from './FilterQueryParser'; +import { OrExpressionContext } from './FilterQueryParser'; +import { AndExpressionContext } from './FilterQueryParser'; +import { UnaryExpressionContext } from './FilterQueryParser'; +import { PrimaryContext } from './FilterQueryParser'; +import { ComparisonContext } from './FilterQueryParser'; +import { InClauseContext } from './FilterQueryParser'; +import { NotInClauseContext } from './FilterQueryParser'; +import { ValueListContext } from './FilterQueryParser'; +import { FullTextContext } from './FilterQueryParser'; +import { FunctionCallContext } from './FilterQueryParser'; +import { FunctionParamListContext } from './FilterQueryParser'; +import { FunctionParamContext } from './FilterQueryParser'; +import { ArrayContext } from './FilterQueryParser'; +import { ValueContext } from './FilterQueryParser'; +import { KeyContext } from './FilterQueryParser'; /** * This interface defines a complete listener for a parse tree produced by @@ -32,199 +30,166 @@ export default class FilterQueryListener extends ParseTreeListener { * @param ctx the parse tree */ enterQuery?: (ctx: QueryContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.query`. * @param ctx the parse tree */ exitQuery?: (ctx: QueryContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.expression`. * @param ctx the parse tree */ enterExpression?: (ctx: ExpressionContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.expression`. * @param ctx the parse tree */ exitExpression?: (ctx: ExpressionContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.orExpression`. * @param ctx the parse tree */ enterOrExpression?: (ctx: OrExpressionContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.orExpression`. * @param ctx the parse tree */ exitOrExpression?: (ctx: OrExpressionContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.andExpression`. * @param ctx the parse tree */ enterAndExpression?: (ctx: AndExpressionContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.andExpression`. * @param ctx the parse tree */ exitAndExpression?: (ctx: AndExpressionContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.unaryExpression`. * @param ctx the parse tree */ enterUnaryExpression?: (ctx: UnaryExpressionContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.unaryExpression`. * @param ctx the parse tree */ exitUnaryExpression?: (ctx: UnaryExpressionContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.primary`. * @param ctx the parse tree */ enterPrimary?: (ctx: PrimaryContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.primary`. * @param ctx the parse tree */ exitPrimary?: (ctx: PrimaryContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.comparison`. * @param ctx the parse tree */ enterComparison?: (ctx: ComparisonContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.comparison`. * @param ctx the parse tree */ exitComparison?: (ctx: ComparisonContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.inClause`. * @param ctx the parse tree */ enterInClause?: (ctx: InClauseContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.inClause`. * @param ctx the parse tree */ exitInClause?: (ctx: InClauseContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.notInClause`. * @param ctx the parse tree */ enterNotInClause?: (ctx: NotInClauseContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.notInClause`. * @param ctx the parse tree */ exitNotInClause?: (ctx: NotInClauseContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.valueList`. * @param ctx the parse tree */ enterValueList?: (ctx: ValueListContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.valueList`. * @param ctx the parse tree */ exitValueList?: (ctx: ValueListContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.fullText`. * @param ctx the parse tree */ enterFullText?: (ctx: FullTextContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.fullText`. * @param ctx the parse tree */ exitFullText?: (ctx: FullTextContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.functionCall`. * @param ctx the parse tree */ enterFunctionCall?: (ctx: FunctionCallContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.functionCall`. * @param ctx the parse tree */ exitFunctionCall?: (ctx: FunctionCallContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.functionParamList`. * @param ctx the parse tree */ enterFunctionParamList?: (ctx: FunctionParamListContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.functionParamList`. * @param ctx the parse tree */ exitFunctionParamList?: (ctx: FunctionParamListContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.functionParam`. * @param ctx the parse tree */ enterFunctionParam?: (ctx: FunctionParamContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.functionParam`. * @param ctx the parse tree */ exitFunctionParam?: (ctx: FunctionParamContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.array`. * @param ctx the parse tree */ enterArray?: (ctx: ArrayContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.array`. * @param ctx the parse tree */ exitArray?: (ctx: ArrayContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.value`. * @param ctx the parse tree */ enterValue?: (ctx: ValueContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.value`. * @param ctx the parse tree */ exitValue?: (ctx: ValueContext) => void; - /** * Enter a parse tree produced by `FilterQueryParser.key`. * @param ctx the parse tree */ enterKey?: (ctx: KeyContext) => void; - /** * Exit a parse tree produced by `FilterQueryParser.key`. * @param ctx the parse tree diff --git a/frontend/src/parser/FilterQueryParser.ts b/frontend/src/parser/FilterQueryParser.ts index 4d775998f803..7cdcc52d0ecf 100644 --- a/frontend/src/parser/FilterQueryParser.ts +++ b/frontend/src/parser/FilterQueryParser.ts @@ -1022,17 +1022,15 @@ export default class FilterQueryParser extends Parser { try { this.state = 202; this._errHandler.sync(this); - switch (this._input.LA(1)) { - case 37: + switch (this._interp.adaptivePredict(this._input, 12, this._ctx)) { + case 1: this.enterOuterAlt(localctx, 1); { this.state = 199; this.key(); } break; - case 34: - case 35: - case 36: + case 2: this.enterOuterAlt(localctx, 2); { this.state = 200; @@ -1046,8 +1044,6 @@ export default class FilterQueryParser extends Parser { this.array(); } break; - default: - throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { @@ -1099,7 +1095,7 @@ export default class FilterQueryParser extends Parser { { this.state = 208; _la = this._input.LA(1); - if (!(((_la - 34) & ~0x1f) === 0 && ((1 << (_la - 34)) & 7) !== 0)) { + if (!(((_la - 34) & ~0x1f) === 0 && ((1 << (_la - 34)) & 15) !== 0)) { this._errHandler.recoverInline(this); } else { this._errHandler.reportMatch(this); @@ -1639,7 +1635,7 @@ export default class FilterQueryParser extends Parser { 1, 0, 34, - 36, + 37, 227, 0, 34, @@ -3809,6 +3805,9 @@ export class ValueContext extends ParserRuleContext { public BOOL(): TerminalNode { return this.getToken(FilterQueryParser.BOOL, 0); } + public KEY(): TerminalNode { + return this.getToken(FilterQueryParser.KEY, 0); + } public get ruleIndex(): number { return FilterQueryParser.RULE_value; } diff --git a/frontend/src/parser/FilterQueryVisitor.ts b/frontend/src/parser/FilterQueryVisitor.ts index 89ae1c9857a9..2f9a868d69cd 100644 --- a/frontend/src/parser/FilterQueryVisitor.ts +++ b/frontend/src/parser/FilterQueryVisitor.ts @@ -2,25 +2,23 @@ import { ParseTreeVisitor } from 'antlr4'; -import { - AndExpressionContext, - ArrayContext, - ComparisonContext, - ExpressionContext, - FullTextContext, - FunctionCallContext, - FunctionParamContext, - FunctionParamListContext, - InClauseContext, - KeyContext, - NotInClauseContext, - OrExpressionContext, - PrimaryContext, - QueryContext, - UnaryExpressionContext, - ValueContext, - ValueListContext, -} from './FilterQueryParser'; +import { QueryContext } from './FilterQueryParser'; +import { ExpressionContext } from './FilterQueryParser'; +import { OrExpressionContext } from './FilterQueryParser'; +import { AndExpressionContext } from './FilterQueryParser'; +import { UnaryExpressionContext } from './FilterQueryParser'; +import { PrimaryContext } from './FilterQueryParser'; +import { ComparisonContext } from './FilterQueryParser'; +import { InClauseContext } from './FilterQueryParser'; +import { NotInClauseContext } from './FilterQueryParser'; +import { ValueListContext } from './FilterQueryParser'; +import { FullTextContext } from './FilterQueryParser'; +import { FunctionCallContext } from './FilterQueryParser'; +import { FunctionParamListContext } from './FilterQueryParser'; +import { FunctionParamContext } from './FilterQueryParser'; +import { ArrayContext } from './FilterQueryParser'; +import { ValueContext } from './FilterQueryParser'; +import { KeyContext } from './FilterQueryParser'; /** * This interface defines a complete generic visitor for a parse tree produced @@ -38,112 +36,96 @@ export default class FilterQueryVisitor< * @return the visitor result */ visitQuery?: (ctx: QueryContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.expression`. * @param ctx the parse tree * @return the visitor result */ visitExpression?: (ctx: ExpressionContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.orExpression`. * @param ctx the parse tree * @return the visitor result */ visitOrExpression?: (ctx: OrExpressionContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.andExpression`. * @param ctx the parse tree * @return the visitor result */ visitAndExpression?: (ctx: AndExpressionContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.unaryExpression`. * @param ctx the parse tree * @return the visitor result */ visitUnaryExpression?: (ctx: UnaryExpressionContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.primary`. * @param ctx the parse tree * @return the visitor result */ visitPrimary?: (ctx: PrimaryContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.comparison`. * @param ctx the parse tree * @return the visitor result */ visitComparison?: (ctx: ComparisonContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.inClause`. * @param ctx the parse tree * @return the visitor result */ visitInClause?: (ctx: InClauseContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.notInClause`. * @param ctx the parse tree * @return the visitor result */ visitNotInClause?: (ctx: NotInClauseContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.valueList`. * @param ctx the parse tree * @return the visitor result */ visitValueList?: (ctx: ValueListContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.fullText`. * @param ctx the parse tree * @return the visitor result */ visitFullText?: (ctx: FullTextContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.functionCall`. * @param ctx the parse tree * @return the visitor result */ visitFunctionCall?: (ctx: FunctionCallContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.functionParamList`. * @param ctx the parse tree * @return the visitor result */ visitFunctionParamList?: (ctx: FunctionParamListContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.functionParam`. * @param ctx the parse tree * @return the visitor result */ visitFunctionParam?: (ctx: FunctionParamContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.array`. * @param ctx the parse tree * @return the visitor result */ visitArray?: (ctx: ArrayContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.value`. * @param ctx the parse tree * @return the visitor result */ visitValue?: (ctx: ValueContext) => Result; - /** * Visit a parse tree produced by `FilterQueryParser.key`. * @param ctx the parse tree diff --git a/frontend/src/parser/analyzeQuery.ts b/frontend/src/parser/analyzeQuery.ts new file mode 100644 index 000000000000..24066d969dae --- /dev/null +++ b/frontend/src/parser/analyzeQuery.ts @@ -0,0 +1,94 @@ +import FilterQueryLexer from './FilterQueryLexer'; +import FilterQueryParser from './FilterQueryParser'; +import { ParseTreeWalker, CharStreams, CommonTokenStream, Token } from 'antlr4'; +import { isOperatorToken } from 'utils/tokenUtils'; +import FilterQueryListener from './FilterQueryListener'; + +import { + KeyContext, + ValueContext, + ComparisonContext, +} from './FilterQueryParser'; +import { IToken } from 'types/antlrQueryTypes'; + +// 👇 Define the token classification +type TokenClassification = 'Key' | 'Value' | 'Operator'; + +interface TokenInfo { + text: string; + startIndex: number; + stopIndex: number; + type: TokenClassification; +} + +// 👇 Custom listener to walk the parse tree +class TypeTrackingListener implements FilterQueryListener { + public tokens: TokenInfo[] = []; + + enterKey(ctx: KeyContext) { + const token = ctx.KEY().symbol; + this.tokens.push({ + text: token.text!, + startIndex: token.start, + stopIndex: token.stop, + type: 'Key', + }); + } + + enterValue(ctx: ValueContext) { + const token = ctx.start; + this.tokens.push({ + text: token.text!, + startIndex: token.start, + stopIndex: token.stop, + type: 'Value', + }); + } + + enterComparison(ctx: ComparisonContext) { + const children = ctx.children || []; + for (const child of children) { + const token = (child as any).symbol; + if (token && isOperatorToken(token.type)) { + this.tokens.push({ + text: token.text!, + startIndex: token.start, + stopIndex: token.stop, + type: 'Operator', + }); + } + } + } + + // Required no-op stubs + enterEveryRule() {} + exitEveryRule() {} + exitKey() {} + exitValue() {} + exitComparison() {} + visitTerminal() {} + visitErrorNode() {} +} + +// 👇 Analyze function +export function analyzeQuery(input: string, lastToken: IToken) { + input = input.trim(); + const chars = CharStreams.fromString(input); + const lexer = new FilterQueryLexer(chars); + const tokens = new CommonTokenStream(lexer); + const parser = new FilterQueryParser(tokens); + + const tree = parser.query(); + + const listener = new TypeTrackingListener(); + ParseTreeWalker.DEFAULT.walk(listener, tree); + + const currentToken = listener.tokens.find( + (token) => + token.text === lastToken.text && + token.startIndex === lastToken.start && + token.stopIndex === lastToken.stop, + ); + + return currentToken; +} diff --git a/frontend/src/query-grammar/.antlr/FilterQuery.interp b/frontend/src/query-grammar/.antlr/FilterQuery.interp index 114118d40ad1..59028e95f718 100644 --- a/frontend/src/query-grammar/.antlr/FilterQuery.interp +++ b/frontend/src/query-grammar/.antlr/FilterQuery.interp @@ -101,4 +101,4 @@ 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 +[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, 37, 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/FilterQuery.g4 b/frontend/src/query-grammar/FilterQuery.g4 index 53475ff44c78..e2f504bb6cf8 100644 --- a/frontend/src/query-grammar/FilterQuery.g4 +++ b/frontend/src/query-grammar/FilterQuery.g4 @@ -93,6 +93,7 @@ value : QUOTED_TEXT | NUMBER | BOOL + | KEY ; key diff --git a/frontend/src/utils/queryContextUtils.ts b/frontend/src/utils/queryContextUtils.ts index 1d8db01e9de6..e44b865ba13a 100644 --- a/frontend/src/utils/queryContextUtils.ts +++ b/frontend/src/utils/queryContextUtils.ts @@ -3,6 +3,16 @@ import { CharStreams, CommonTokenStream, Token } from 'antlr4'; import FilterQueryLexer from 'parser/FilterQueryLexer'; import { IQueryContext, IQueryPair, IToken } from 'types/antlrQueryTypes'; +import { analyzeQuery } from 'parser/analyzeQuery'; +import { + isBracketToken, + isConjunctionToken, + isFunctionToken, + isKeyToken, + isMultiValueOperator, + isOperatorToken, + isValueToken, +} from './tokenUtils'; // Function to normalize multiple spaces to single spaces when not in quotes function normalizeSpaces(query: string): string { @@ -69,7 +79,8 @@ export function createContext( // Helper to determine token type for context function determineTokenContext( - tokenType: number, + token: IToken, + query: string, ): { isInKey: boolean; isInOperator: boolean; @@ -78,57 +89,49 @@ function determineTokenContext( isInConjunction: boolean; isInParenthesis: boolean; } { - // Key context - const isInKey = tokenType === FilterQueryLexer.KEY; + let isInKey: boolean = false; + let isInOperator: boolean = false; + let isInValue: boolean = false; + let isInFunction: boolean = false; + let isInConjunction: boolean = false; + let isInParenthesis: boolean = false; - // Operator context - 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(tokenType); + const tokenType = token.type; + const currentTokenContext = analyzeQuery(query, token); - // Value context - const isInValue = [ - FilterQueryLexer.QUOTED_TEXT, - FilterQueryLexer.NUMBER, - FilterQueryLexer.BOOL, - ].includes(tokenType); + if (!currentTokenContext) { + // Key context + isInKey = isKeyToken(tokenType); + + // Operator context + isInOperator = isOperatorToken(tokenType); + + // Value context + isInValue = isValueToken(tokenType); + } else { + switch (currentTokenContext.type) { + case 'Operator': + isInOperator = true; + break; + case 'Value': + isInValue = true; + break; + case 'Key': + isInKey = true; + break; + default: + break; + } + } // Function context - const isInFunction = [ - FilterQueryLexer.HAS, - FilterQueryLexer.HASANY, - FilterQueryLexer.HASALL, - FilterQueryLexer.HASNONE, - ].includes(tokenType); + isInFunction = isFunctionToken(tokenType); // Conjunction context - const isInConjunction = [FilterQueryLexer.AND, FilterQueryLexer.OR].includes( - tokenType, - ); + isInConjunction = isConjunctionToken(tokenType); // Parenthesis context - const isInParenthesis = [ - FilterQueryLexer.LPAREN, - FilterQueryLexer.RPAREN, - FilterQueryLexer.LBRACK, - FilterQueryLexer.RBRACK, - ].includes(tokenType); + isInParenthesis = isBracketToken(tokenType); return { isInKey, @@ -140,61 +143,6 @@ function determineTokenContext( }; } -// Helper function to check if a token is an operator -function isOperatorToken(tokenType: number): boolean { - return [ - 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(tokenType); -} - -// Helper function to check if a token is a value -function isValueToken(tokenType: number): boolean { - return [ - FilterQueryLexer.QUOTED_TEXT, - FilterQueryLexer.NUMBER, - FilterQueryLexer.BOOL, - ].includes(tokenType); -} - -// Helper function to check if a token is a conjunction -function isConjunctionToken(tokenType: number): boolean { - return [FilterQueryLexer.AND, FilterQueryLexer.OR].includes(tokenType); -} - -// Helper function to check if a token is a bracket -function isBracketToken(tokenType: number): boolean { - return [ - FilterQueryLexer.LPAREN, - FilterQueryLexer.RPAREN, - FilterQueryLexer.LBRACK, - FilterQueryLexer.RBRACK, - ].includes(tokenType); -} - -// Helper function to check if an operator typically uses bracket values (multi-value operators) -function isMultiValueOperator(operatorToken?: string): boolean { - if (!operatorToken) return false; - - const upperOp = operatorToken.toUpperCase(); - return upperOp === 'IN' || upperOp === 'NOT IN'; -} - // Function to determine token context boundaries more precisely function determineContextBoundaries( query: string, @@ -888,7 +836,7 @@ export function getQueryContextAtCursor( lastTokenBeforeCursor && (isAtSpace || isAfterSpace || isTransitionPoint) ) { - const lastTokenContext = determineTokenContext(lastTokenBeforeCursor.type); + const lastTokenContext = determineTokenContext(lastTokenBeforeCursor, input); // Apply the context progression logic: key → operator → value → conjunction → key if (lastTokenContext.isInKey) { @@ -984,7 +932,7 @@ export function getQueryContextAtCursor( // FIXED: Consider the case where the cursor is at the end of a token // with no space yet (user is actively typing) if (exactToken && adjustedCursorIndex === exactToken.stop + 1) { - const tokenContext = determineTokenContext(exactToken.type); + const tokenContext = determineTokenContext(exactToken, input); // When the cursor is at the end of a token, return the current token context return { @@ -1011,7 +959,7 @@ export function getQueryContextAtCursor( // Regular token-based context detection (when cursor is directly on a token) if (exactToken?.channel === 0) { - const tokenContext = determineTokenContext(exactToken.type); + const tokenContext = determineTokenContext(exactToken, input); // Get relevant tokens based on current pair const keyFromPair = currentPair?.key || ''; @@ -1044,7 +992,7 @@ export function getQueryContextAtCursor( // If we're between tokens but not after a space, use previous token to determine context if (previousToken?.channel === 0) { - const prevContext = determineTokenContext(previousToken.type); + const prevContext = determineTokenContext(previousToken, input); // Get relevant tokens based on current pair const keyFromPair = currentPair?.key || ''; @@ -1221,7 +1169,10 @@ export function extractQueryPairs(query: string): IQueryPair[] { } // If token is a KEY, start a new pair - if (token.type === FilterQueryLexer.KEY) { + if ( + token.type === FilterQueryLexer.KEY && + !(currentPair && currentPair.key) + ) { // If we have an existing incomplete pair, add it to the result if (currentPair && currentPair.key) { queryPairs.push({ diff --git a/frontend/src/utils/tokenUtils.ts b/frontend/src/utils/tokenUtils.ts new file mode 100644 index 000000000000..bbe331ca9045 --- /dev/null +++ b/frontend/src/utils/tokenUtils.ts @@ -0,0 +1,70 @@ +import FilterQueryLexer from 'parser/FilterQueryLexer'; + +export function isKeyToken(tokenType: number): boolean { + return tokenType === FilterQueryLexer.KEY; +} + +// Helper function to check if a token is an operator +export function isOperatorToken(tokenType: number): boolean { + return [ + 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(tokenType); +} + +// Helper function to check if a token is a value +export function isValueToken(tokenType: number): boolean { + return [ + FilterQueryLexer.QUOTED_TEXT, + FilterQueryLexer.NUMBER, + FilterQueryLexer.BOOL, + FilterQueryLexer.KEY, + ].includes(tokenType); +} + +// Helper function to check if a token is a conjunction +export function isConjunctionToken(tokenType: number): boolean { + return [FilterQueryLexer.AND, FilterQueryLexer.OR].includes(tokenType); +} + +// Helper function to check if a token is a bracket +export function isBracketToken(tokenType: number): boolean { + return [ + FilterQueryLexer.LPAREN, + FilterQueryLexer.RPAREN, + FilterQueryLexer.LBRACK, + FilterQueryLexer.RBRACK, + ].includes(tokenType); +} + +// Helper function to check if an operator typically uses bracket values (multi-value operators) +export function isMultiValueOperator(operatorToken?: string): boolean { + if (!operatorToken) return false; + + const upperOp = operatorToken.toUpperCase(); + return upperOp === 'IN' || upperOp === 'NOT IN'; +} + +export function isFunctionToken(tokenType: number): boolean { + return [ + FilterQueryLexer.HAS, + FilterQueryLexer.HASANY, + FilterQueryLexer.HASALL, + FilterQueryLexer.HASNONE, + ].includes(tokenType); +}