diff --git a/CHANGELOG.md b/CHANGELOG.md index e03e3c135..74d04de0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## v1.0.0-112 + + +### 🩹 Fixes + +- Remove antlr4ts ([13eaa3d](https://github.com/undb-io/undb/commit/13eaa3d)) + +### ❤️ Contributors + +- Nichenqin ([@nichenqin](http://github.com/nichenqin)) + ## v1.0.0-111 diff --git a/apps/frontend/src/lib/components/formula/formula-cursor.visitor.ts b/apps/frontend/src/lib/components/formula/formula-cursor.visitor.ts index d877455f5..7ff991608 100644 --- a/apps/frontend/src/lib/components/formula/formula-cursor.visitor.ts +++ b/apps/frontend/src/lib/components/formula/formula-cursor.visitor.ts @@ -1,5 +1,4 @@ import { - AbstractParseTreeVisitor, AddSubExprContext, AndExprContext, ArgumentListContext, @@ -16,7 +15,7 @@ import { VariableContext, } from "@undb/formula" -export class FormulaCursorVisitor extends AbstractParseTreeVisitor implements FormulaParserVisitor { +export class FormulaCursorVisitor extends FormulaParserVisitor { private pathNodes: ParseTree[] = [] private variables: Set = new Set() public readonly targetPosition: number @@ -46,7 +45,7 @@ export class FormulaCursorVisitor extends AbstractParseTreeVisitor impleme public getFunctionName(): string | undefined { const functionCall = this.getNearestFunctionNode() - return functionCall?.IDENTIFIER()?.text + return functionCall?.IDENTIFIER().getText() } protected defaultResult(): void { @@ -60,8 +59,8 @@ export class FormulaCursorVisitor extends AbstractParseTreeVisitor impleme visitPositionInRange(ctx: ExpressionContext) { if (!ctx.start || !ctx.stop) return - const start = ctx.start.startIndex - const stop = ctx.stop.stopIndex + const start = ctx.start.tokenIndex + const stop = ctx.stop.tokenIndex const isPositionWithinRange = start <= this.targetPosition && stop >= this.targetPosition if (isPositionWithinRange) { @@ -70,48 +69,48 @@ export class FormulaCursorVisitor extends AbstractParseTreeVisitor impleme } } - visitFormula(ctx: FormulaContext) { + visitFormula = (ctx: FormulaContext) => { this.visitPositionInRange(ctx) } - visitComparisonExpr(ctx: ComparisonExprContext) { + visitComparisonExpr = (ctx: ComparisonExprContext) => { this.visitPositionInRange(ctx) } - visitAndExpr(ctx: AndExprContext) { + visitAndExpr = (ctx: AndExprContext) => { this.visitPositionInRange(ctx) } - visitOrExpr(ctx: OrExprContext) { + visitOrExpr = (ctx: OrExprContext) => { this.visitPositionInRange(ctx) } - visitNotExpr(ctx: NotExprContext) { + visitNotExpr = (ctx: NotExprContext) => { this.visitPositionInRange(ctx) } - visitMulDivModExpr(ctx: MulDivModExprContext) { + visitMulDivModExpr = (ctx: MulDivModExprContext) => { this.visitPositionInRange(ctx) } - visitAddSubExpr(ctx: AddSubExprContext) { + visitAddSubExpr = (ctx: AddSubExprContext) => { this.visitPositionInRange(ctx) } - visitFunctionExpr(ctx: FunctionExprContext) { + visitFunctionExpr = (ctx: FunctionExprContext) => { this.visitPositionInRange(ctx) } - visitFunctionCall(ctx: FunctionCallContext) { + visitFunctionCall = (ctx: FunctionCallContext) => { this.visitPositionInRange(ctx) } - visitArgumentList(ctx: ArgumentListContext) { + visitArgumentList = (ctx: ArgumentListContext) => { this.visitPositionInRange(ctx) } - visitVariable(ctx: VariableContext) { - this.variables.add(ctx.IDENTIFIER().text) + visitVariable = (ctx: VariableContext) => { + this.variables.add(ctx.IDENTIFIER().getText()) this.visitPositionInRange(ctx) } } diff --git a/bun.lockb b/bun.lockb index 508ca4655..f0c1840b8 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index d85a9746d..e6bff785c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "undb", - "version": "1.0.0-111", + "version": "1.0.0-112", "private": true, "scripts": { "build": "NODE_ENV=production bun --bun turbo build", diff --git a/packages/formula/package.json b/packages/formula/package.json index ddaa33eac..09ae28105 100644 --- a/packages/formula/package.json +++ b/packages/formula/package.json @@ -4,18 +4,17 @@ "type": "module", "types": "src/index.d.ts", "devDependencies": { - "@types/bun": "latest", - "antlr4ts-cli": "^0.5.0-alpha.4" + "@types/bun": "latest" }, "peerDependencies": { "typescript": "^5.0.0" }, "dependencies": { "@undb/zod": "*", - "antlr4ts": "^0.5.0-alpha.4" + "antlr4": "^4.13.2" }, "scripts": { "generate-parser": "bun run scripts/generate-parser.ts", - "generate": "bun generate-parser" + "generate": "bun run generate-parser" } } diff --git a/packages/formula/scripts/generate-parser.ts b/packages/formula/scripts/generate-parser.ts index c898b2df3..8bd379e1d 100644 --- a/packages/formula/scripts/generate-parser.ts +++ b/packages/formula/scripts/generate-parser.ts @@ -1,3 +1,3 @@ import { $ } from "bun" -await $`antlr4ts -visitor -no-listener src/grammar/*.g4` +await $`antlr -Dlanguage=TypeScript -visitor -no-listener src/grammar/*.g4` diff --git a/packages/formula/src/formula.visitor.ts b/packages/formula/src/formula.visitor.ts index eeb513571..47e3da2f7 100644 --- a/packages/formula/src/formula.visitor.ts +++ b/packages/formula/src/formula.visitor.ts @@ -1,4 +1,3 @@ -import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor" import { FormulaFunction } from "./formula/formula.type" import { globalFunctionRegistry } from "./formula/registry" import { @@ -18,7 +17,7 @@ import { VariableContext, VariableExprContext, } from "./grammar/FormulaParser" -import type { FormulaParserVisitor } from "./grammar/FormulaParserVisitor" +import FormulaParserVisitor from "./grammar/FormulaParserVisitor" import { ArgumentListResult, ReturnType, @@ -28,10 +27,7 @@ import { type VariableResult, } from "./types" -export class FormulaVisitor - extends AbstractParseTreeVisitor - implements FormulaParserVisitor -{ +export class FormulaVisitor extends FormulaParserVisitor { private variables: Set = new Set() private assertType(result: ExpressionResult, types: ReturnType[]): boolean { @@ -53,11 +49,11 @@ export class FormulaVisitor return true } - visitFormula(ctx: FormulaContext): ExpressionResult { + visitFormula = (ctx: FormulaContext): ExpressionResult => { return this.visit(ctx.expression()) } - visitMulDivModExpr(ctx: MulDivModExprContext): ExpressionResult { + visitMulDivModExpr = (ctx: MulDivModExprContext): ExpressionResult => { const left = this.visit(ctx.expression(0)) as NumberResult | VariableResult const right = this.visit(ctx.expression(1)) as NumberResult | VariableResult @@ -70,11 +66,11 @@ export class FormulaVisitor name: op, arguments: [left, right], returnType: "number", - value: ctx.text, + value: ctx.getText(), } } - visitAddSubExpr(ctx: AddSubExprContext): ExpressionResult { + visitAddSubExpr = (ctx: AddSubExprContext): ExpressionResult => { const left = this.visit(ctx.expression(0)) as NumberResult | VariableResult const right = this.visit(ctx.expression(1)) as NumberResult | VariableResult @@ -87,11 +83,11 @@ export class FormulaVisitor name: op, arguments: [left, right], returnType: "number", - value: ctx.text, + value: ctx.getText(), } } - visitComparisonExpr(ctx: ComparisonExprContext): ExpressionResult { + visitComparisonExpr = (ctx: ComparisonExprContext): ExpressionResult => { const left = this.visit(ctx.expression(0)) const right = this.visit(ctx.expression(1)) @@ -104,11 +100,11 @@ export class FormulaVisitor name: op, arguments: [left, right], returnType: "boolean", - value: ctx.text, + value: ctx.getText(), } } - visitAndExpr(ctx: AndExprContext): ExpressionResult { + visitAndExpr = (ctx: AndExprContext): ExpressionResult => { const left = this.visit(ctx.expression(0)) const right = this.visit(ctx.expression(1)) @@ -120,11 +116,11 @@ export class FormulaVisitor name: "AND", arguments: [left, right], returnType: "boolean", - value: ctx.text, + value: ctx.getText(), } } - visitOrExpr(ctx: OrExprContext): ExpressionResult { + visitOrExpr = (ctx: OrExprContext): ExpressionResult => { const left = this.visit(ctx.expression(0)) const right = this.visit(ctx.expression(1)) @@ -136,11 +132,11 @@ export class FormulaVisitor name: "OR", arguments: [left, right], returnType: "boolean", - value: ctx.text, + value: ctx.getText(), } } - visitNotExpr(ctx: NotExprContext): ExpressionResult { + visitNotExpr = (ctx: NotExprContext): ExpressionResult => { const expr = this.visit(ctx.expression()) this.assertType(expr, ["boolean"]) return { @@ -148,32 +144,32 @@ export class FormulaVisitor name: "NOT", arguments: [expr], returnType: "boolean", - value: ctx.text, + value: ctx.getText(), } } - visitFunctionExpr(ctx: FunctionExprContext): ExpressionResult { + visitFunctionExpr = (ctx: FunctionExprContext): ExpressionResult => { return this.visit(ctx.functionCall()) } - visitVariableExpr(ctx: VariableExprContext): ExpressionResult { + visitVariableExpr = (ctx: VariableExprContext): ExpressionResult => { return this.visit(ctx.variable()) } - visitNumberExpr(ctx: NumberExprContext): ExpressionResult { - return { type: "number", value: Number(ctx.NUMBER().text) } + visitNumberExpr = (ctx: NumberExprContext): ExpressionResult => { + return { type: "number", value: Number(ctx.NUMBER().getText()) } } - visitStringExpr(ctx: StringExprContext): ExpressionResult { - return { type: "string", value: ctx.STRING().text.slice(1, -1) } + visitStringExpr = (ctx: StringExprContext): ExpressionResult => { + return { type: "string", value: ctx.STRING().getText().slice(1, -1) } } - visitParenExpr(ctx: ParenExprContext): ExpressionResult { + visitParenExpr = (ctx: ParenExprContext): ExpressionResult => { return this.visit(ctx.expression()) } - visitFunctionCall(ctx: FunctionCallContext): ExpressionResult { - const funcName = ctx.IDENTIFIER().text as FormulaFunction + visitFunctionCall = (ctx: FunctionCallContext): ExpressionResult => { + const funcName = ctx.IDENTIFIER().getText() as FormulaFunction const args = ctx.argumentList() ? (this.visit(ctx.argumentList()!) as FunctionExpressionResult) : undefined if (!globalFunctionRegistry.isValid(funcName)) { @@ -191,20 +187,20 @@ export class FormulaVisitor name: funcName, arguments: args?.arguments ?? [], returnType, - value: ctx.text, + value: ctx.getText(), } } - visitArgumentList(ctx: ArgumentListContext): ArgumentListResult { - const args = ctx.expression().map((expr) => this.visit(expr)) + visitArgumentList = (ctx: ArgumentListContext): ArgumentListResult => { + const args = ctx.expression_list().map((expr) => this.visit(expr)) return { type: "argumentList", arguments: args, } } - visitVariable(ctx: VariableContext): VariableResult { - const variableName = ctx.IDENTIFIER().text - const raw = ctx.text + visitVariable = (ctx: VariableContext): VariableResult => { + const variableName = ctx.IDENTIFIER().getText() + const raw = ctx.getText() this.variables.add(variableName) return { type: "variable", value: raw, variable: variableName } } diff --git a/packages/formula/src/grammar/FormulaLexer.interp b/packages/formula/src/grammar/FormulaLexer.interp index 6fefff5f8..5b2652930 100644 --- a/packages/formula/src/grammar/FormulaLexer.interp +++ b/packages/formula/src/grammar/FormulaLexer.interp @@ -156,4 +156,4 @@ mode names: DEFAULT_MODE atn: -[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 40, 351, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 7, 28, 200, 10, 28, 12, 28, 14, 28, 203, 11, 28, 3, 29, 6, 29, 206, 10, 29, 13, 29, 14, 29, 207, 3, 29, 3, 29, 6, 29, 212, 10, 29, 13, 29, 14, 29, 213, 5, 29, 216, 10, 29, 3, 30, 3, 30, 3, 30, 3, 30, 7, 30, 222, 10, 30, 12, 30, 14, 30, 225, 11, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 6, 37, 265, 10, 37, 13, 37, 14, 37, 266, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 7, 38, 275, 10, 38, 12, 38, 14, 38, 278, 11, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 7, 39, 286, 10, 39, 12, 39, 14, 39, 289, 11, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 41, 3, 41, 3, 42, 3, 42, 3, 43, 3, 43, 3, 44, 3, 44, 3, 45, 3, 45, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 49, 3, 49, 3, 50, 3, 50, 3, 51, 3, 51, 3, 52, 3, 52, 3, 53, 3, 53, 3, 54, 3, 54, 3, 55, 3, 55, 3, 56, 3, 56, 3, 57, 3, 57, 3, 58, 3, 58, 3, 59, 3, 59, 3, 60, 3, 60, 3, 61, 3, 61, 3, 62, 3, 62, 3, 63, 3, 63, 3, 64, 3, 64, 3, 65, 3, 65, 3, 66, 3, 66, 3, 67, 3, 67, 3, 287, 2, 2, 68, 3, 2, 3, 5, 2, 4, 7, 2, 5, 9, 2, 6, 11, 2, 7, 13, 2, 8, 15, 2, 9, 17, 2, 10, 19, 2, 11, 21, 2, 12, 23, 2, 13, 25, 2, 14, 27, 2, 15, 29, 2, 16, 31, 2, 17, 33, 2, 18, 35, 2, 19, 37, 2, 20, 39, 2, 21, 41, 2, 22, 43, 2, 23, 45, 2, 24, 47, 2, 25, 49, 2, 26, 51, 2, 27, 53, 2, 28, 55, 2, 29, 57, 2, 30, 59, 2, 31, 61, 2, 32, 63, 2, 33, 65, 2, 34, 67, 2, 35, 69, 2, 36, 71, 2, 37, 73, 2, 38, 75, 2, 39, 77, 2, 40, 79, 2, 2, 81, 2, 2, 83, 2, 2, 85, 2, 2, 87, 2, 2, 89, 2, 2, 91, 2, 2, 93, 2, 2, 95, 2, 2, 97, 2, 2, 99, 2, 2, 101, 2, 2, 103, 2, 2, 105, 2, 2, 107, 2, 2, 109, 2, 2, 111, 2, 2, 113, 2, 2, 115, 2, 2, 117, 2, 2, 119, 2, 2, 121, 2, 2, 123, 2, 2, 125, 2, 2, 127, 2, 2, 129, 2, 2, 131, 2, 2, 133, 2, 2, 3, 2, 33, 3, 2, 41, 41, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 12, 12, 15, 15, 3, 2, 50, 59, 4, 2, 67, 92, 99, 124, 4, 2, 67, 67, 99, 99, 4, 2, 68, 68, 100, 100, 4, 2, 69, 69, 101, 101, 4, 2, 70, 70, 102, 102, 4, 2, 71, 71, 103, 103, 4, 2, 72, 72, 104, 104, 4, 2, 73, 73, 105, 105, 4, 2, 74, 74, 106, 106, 4, 2, 75, 75, 107, 107, 4, 2, 76, 76, 108, 108, 4, 2, 77, 77, 109, 109, 4, 2, 78, 78, 110, 110, 4, 2, 79, 79, 111, 111, 4, 2, 80, 80, 112, 112, 4, 2, 81, 81, 113, 113, 4, 2, 82, 82, 114, 114, 4, 2, 83, 83, 115, 115, 4, 2, 84, 84, 116, 116, 4, 2, 85, 85, 117, 117, 4, 2, 86, 86, 118, 118, 4, 2, 87, 87, 119, 119, 4, 2, 88, 88, 120, 120, 4, 2, 89, 89, 121, 121, 4, 2, 90, 90, 122, 122, 4, 2, 91, 91, 123, 123, 4, 2, 92, 92, 124, 124, 2, 333, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 3, 135, 3, 2, 2, 2, 5, 137, 3, 2, 2, 2, 7, 139, 3, 2, 2, 2, 9, 141, 3, 2, 2, 2, 11, 143, 3, 2, 2, 2, 13, 145, 3, 2, 2, 2, 15, 147, 3, 2, 2, 2, 17, 149, 3, 2, 2, 2, 19, 152, 3, 2, 2, 2, 21, 154, 3, 2, 2, 2, 23, 157, 3, 2, 2, 2, 25, 159, 3, 2, 2, 2, 27, 162, 3, 2, 2, 2, 29, 166, 3, 2, 2, 2, 31, 169, 3, 2, 2, 2, 33, 173, 3, 2, 2, 2, 35, 175, 3, 2, 2, 2, 37, 177, 3, 2, 2, 2, 39, 179, 3, 2, 2, 2, 41, 181, 3, 2, 2, 2, 43, 183, 3, 2, 2, 2, 45, 185, 3, 2, 2, 2, 47, 187, 3, 2, 2, 2, 49, 189, 3, 2, 2, 2, 51, 191, 3, 2, 2, 2, 53, 193, 3, 2, 2, 2, 55, 195, 3, 2, 2, 2, 57, 205, 3, 2, 2, 2, 59, 217, 3, 2, 2, 2, 61, 228, 3, 2, 2, 2, 63, 233, 3, 2, 2, 2, 65, 239, 3, 2, 2, 2, 67, 244, 3, 2, 2, 2, 69, 249, 3, 2, 2, 2, 71, 254, 3, 2, 2, 2, 73, 264, 3, 2, 2, 2, 75, 270, 3, 2, 2, 2, 77, 281, 3, 2, 2, 2, 79, 295, 3, 2, 2, 2, 81, 297, 3, 2, 2, 2, 83, 299, 3, 2, 2, 2, 85, 301, 3, 2, 2, 2, 87, 303, 3, 2, 2, 2, 89, 305, 3, 2, 2, 2, 91, 307, 3, 2, 2, 2, 93, 309, 3, 2, 2, 2, 95, 311, 3, 2, 2, 2, 97, 313, 3, 2, 2, 2, 99, 315, 3, 2, 2, 2, 101, 317, 3, 2, 2, 2, 103, 319, 3, 2, 2, 2, 105, 321, 3, 2, 2, 2, 107, 323, 3, 2, 2, 2, 109, 325, 3, 2, 2, 2, 111, 327, 3, 2, 2, 2, 113, 329, 3, 2, 2, 2, 115, 331, 3, 2, 2, 2, 117, 333, 3, 2, 2, 2, 119, 335, 3, 2, 2, 2, 121, 337, 3, 2, 2, 2, 123, 339, 3, 2, 2, 2, 125, 341, 3, 2, 2, 2, 127, 343, 3, 2, 2, 2, 129, 345, 3, 2, 2, 2, 131, 347, 3, 2, 2, 2, 133, 349, 3, 2, 2, 2, 135, 136, 7, 45, 2, 2, 136, 4, 3, 2, 2, 2, 137, 138, 7, 47, 2, 2, 138, 6, 3, 2, 2, 2, 139, 140, 7, 44, 2, 2, 140, 8, 3, 2, 2, 2, 141, 142, 7, 49, 2, 2, 142, 10, 3, 2, 2, 2, 143, 144, 7, 39, 2, 2, 144, 12, 3, 2, 2, 2, 145, 146, 7, 96, 2, 2, 146, 14, 3, 2, 2, 2, 147, 148, 7, 63, 2, 2, 148, 16, 3, 2, 2, 2, 149, 150, 7, 35, 2, 2, 150, 151, 7, 63, 2, 2, 151, 18, 3, 2, 2, 2, 152, 153, 7, 62, 2, 2, 153, 20, 3, 2, 2, 2, 154, 155, 7, 62, 2, 2, 155, 156, 7, 63, 2, 2, 156, 22, 3, 2, 2, 2, 157, 158, 7, 64, 2, 2, 158, 24, 3, 2, 2, 2, 159, 160, 7, 64, 2, 2, 160, 161, 7, 63, 2, 2, 161, 26, 3, 2, 2, 2, 162, 163, 5, 83, 42, 2, 163, 164, 5, 109, 55, 2, 164, 165, 5, 89, 45, 2, 165, 28, 3, 2, 2, 2, 166, 167, 5, 111, 56, 2, 167, 168, 5, 117, 59, 2, 168, 30, 3, 2, 2, 2, 169, 170, 5, 109, 55, 2, 170, 171, 5, 111, 56, 2, 171, 172, 5, 121, 61, 2, 172, 32, 3, 2, 2, 2, 173, 174, 7, 42, 2, 2, 174, 34, 3, 2, 2, 2, 175, 176, 7, 43, 2, 2, 176, 36, 3, 2, 2, 2, 177, 178, 7, 125, 2, 2, 178, 38, 3, 2, 2, 2, 179, 180, 7, 127, 2, 2, 180, 40, 3, 2, 2, 2, 181, 182, 7, 93, 2, 2, 182, 42, 3, 2, 2, 2, 183, 184, 7, 95, 2, 2, 184, 44, 3, 2, 2, 2, 185, 186, 7, 46, 2, 2, 186, 46, 3, 2, 2, 2, 187, 188, 7, 61, 2, 2, 188, 48, 3, 2, 2, 2, 189, 190, 7, 60, 2, 2, 190, 50, 3, 2, 2, 2, 191, 192, 7, 48, 2, 2, 192, 52, 3, 2, 2, 2, 193, 194, 7, 97, 2, 2, 194, 54, 3, 2, 2, 2, 195, 201, 5, 81, 41, 2, 196, 200, 5, 81, 41, 2, 197, 200, 5, 79, 40, 2, 198, 200, 5, 53, 27, 2, 199, 196, 3, 2, 2, 2, 199, 197, 3, 2, 2, 2, 199, 198, 3, 2, 2, 2, 200, 203, 3, 2, 2, 2, 201, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 56, 3, 2, 2, 2, 203, 201, 3, 2, 2, 2, 204, 206, 5, 79, 40, 2, 205, 204, 3, 2, 2, 2, 206, 207, 3, 2, 2, 2, 207, 205, 3, 2, 2, 2, 207, 208, 3, 2, 2, 2, 208, 215, 3, 2, 2, 2, 209, 211, 7, 48, 2, 2, 210, 212, 5, 79, 40, 2, 211, 210, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, 213, 211, 3, 2, 2, 2, 213, 214, 3, 2, 2, 2, 214, 216, 3, 2, 2, 2, 215, 209, 3, 2, 2, 2, 215, 216, 3, 2, 2, 2, 216, 58, 3, 2, 2, 2, 217, 223, 7, 41, 2, 2, 218, 222, 10, 2, 2, 2, 219, 220, 7, 41, 2, 2, 220, 222, 7, 41, 2, 2, 221, 218, 3, 2, 2, 2, 221, 219, 3, 2, 2, 2, 222, 225, 3, 2, 2, 2, 223, 221, 3, 2, 2, 2, 223, 224, 3, 2, 2, 2, 224, 226, 3, 2, 2, 2, 225, 223, 3, 2, 2, 2, 226, 227, 7, 41, 2, 2, 227, 60, 3, 2, 2, 2, 228, 229, 5, 121, 61, 2, 229, 230, 5, 117, 59, 2, 230, 231, 5, 123, 62, 2, 231, 232, 5, 91, 46, 2, 232, 62, 3, 2, 2, 2, 233, 234, 5, 93, 47, 2, 234, 235, 5, 83, 42, 2, 235, 236, 5, 105, 53, 2, 236, 237, 5, 119, 60, 2, 237, 238, 5, 91, 46, 2, 238, 64, 3, 2, 2, 2, 239, 240, 5, 109, 55, 2, 240, 241, 5, 123, 62, 2, 241, 242, 5, 105, 53, 2, 242, 243, 5, 105, 53, 2, 243, 66, 3, 2, 2, 2, 244, 245, 5, 89, 45, 2, 245, 246, 5, 83, 42, 2, 246, 247, 5, 121, 61, 2, 247, 248, 5, 91, 46, 2, 248, 68, 3, 2, 2, 2, 249, 250, 5, 121, 61, 2, 250, 251, 5, 99, 50, 2, 251, 252, 5, 107, 54, 2, 252, 253, 5, 91, 46, 2, 253, 70, 3, 2, 2, 2, 254, 255, 5, 89, 45, 2, 255, 256, 5, 83, 42, 2, 256, 257, 5, 121, 61, 2, 257, 258, 5, 91, 46, 2, 258, 259, 5, 121, 61, 2, 259, 260, 5, 99, 50, 2, 260, 261, 5, 107, 54, 2, 261, 262, 5, 91, 46, 2, 262, 72, 3, 2, 2, 2, 263, 265, 9, 3, 2, 2, 264, 263, 3, 2, 2, 2, 265, 266, 3, 2, 2, 2, 266, 264, 3, 2, 2, 2, 266, 267, 3, 2, 2, 2, 267, 268, 3, 2, 2, 2, 268, 269, 8, 37, 2, 2, 269, 74, 3, 2, 2, 2, 270, 271, 7, 49, 2, 2, 271, 272, 7, 49, 2, 2, 272, 276, 3, 2, 2, 2, 273, 275, 10, 4, 2, 2, 274, 273, 3, 2, 2, 2, 275, 278, 3, 2, 2, 2, 276, 274, 3, 2, 2, 2, 276, 277, 3, 2, 2, 2, 277, 279, 3, 2, 2, 2, 278, 276, 3, 2, 2, 2, 279, 280, 8, 38, 2, 2, 280, 76, 3, 2, 2, 2, 281, 282, 7, 49, 2, 2, 282, 283, 7, 44, 2, 2, 283, 287, 3, 2, 2, 2, 284, 286, 11, 2, 2, 2, 285, 284, 3, 2, 2, 2, 286, 289, 3, 2, 2, 2, 287, 288, 3, 2, 2, 2, 287, 285, 3, 2, 2, 2, 288, 290, 3, 2, 2, 2, 289, 287, 3, 2, 2, 2, 290, 291, 7, 44, 2, 2, 291, 292, 7, 49, 2, 2, 292, 293, 3, 2, 2, 2, 293, 294, 8, 39, 2, 2, 294, 78, 3, 2, 2, 2, 295, 296, 9, 5, 2, 2, 296, 80, 3, 2, 2, 2, 297, 298, 9, 6, 2, 2, 298, 82, 3, 2, 2, 2, 299, 300, 9, 7, 2, 2, 300, 84, 3, 2, 2, 2, 301, 302, 9, 8, 2, 2, 302, 86, 3, 2, 2, 2, 303, 304, 9, 9, 2, 2, 304, 88, 3, 2, 2, 2, 305, 306, 9, 10, 2, 2, 306, 90, 3, 2, 2, 2, 307, 308, 9, 11, 2, 2, 308, 92, 3, 2, 2, 2, 309, 310, 9, 12, 2, 2, 310, 94, 3, 2, 2, 2, 311, 312, 9, 13, 2, 2, 312, 96, 3, 2, 2, 2, 313, 314, 9, 14, 2, 2, 314, 98, 3, 2, 2, 2, 315, 316, 9, 15, 2, 2, 316, 100, 3, 2, 2, 2, 317, 318, 9, 16, 2, 2, 318, 102, 3, 2, 2, 2, 319, 320, 9, 17, 2, 2, 320, 104, 3, 2, 2, 2, 321, 322, 9, 18, 2, 2, 322, 106, 3, 2, 2, 2, 323, 324, 9, 19, 2, 2, 324, 108, 3, 2, 2, 2, 325, 326, 9, 20, 2, 2, 326, 110, 3, 2, 2, 2, 327, 328, 9, 21, 2, 2, 328, 112, 3, 2, 2, 2, 329, 330, 9, 22, 2, 2, 330, 114, 3, 2, 2, 2, 331, 332, 9, 23, 2, 2, 332, 116, 3, 2, 2, 2, 333, 334, 9, 24, 2, 2, 334, 118, 3, 2, 2, 2, 335, 336, 9, 25, 2, 2, 336, 120, 3, 2, 2, 2, 337, 338, 9, 26, 2, 2, 338, 122, 3, 2, 2, 2, 339, 340, 9, 27, 2, 2, 340, 124, 3, 2, 2, 2, 341, 342, 9, 28, 2, 2, 342, 126, 3, 2, 2, 2, 343, 344, 9, 29, 2, 2, 344, 128, 3, 2, 2, 2, 345, 346, 9, 30, 2, 2, 346, 130, 3, 2, 2, 2, 347, 348, 9, 31, 2, 2, 348, 132, 3, 2, 2, 2, 349, 350, 9, 32, 2, 2, 350, 134, 3, 2, 2, 2, 13, 2, 199, 201, 207, 213, 215, 221, 223, 266, 276, 287, 3, 8, 2, 2] \ No newline at end of file +[4, 0, 38, 349, 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, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 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, 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, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 5, 26, 198, 8, 26, 10, 26, 12, 26, 201, 9, 26, 1, 27, 4, 27, 204, 8, 27, 11, 27, 12, 27, 205, 1, 27, 1, 27, 4, 27, 210, 8, 27, 11, 27, 12, 27, 211, 3, 27, 214, 8, 27, 1, 28, 1, 28, 1, 28, 1, 28, 5, 28, 220, 8, 28, 10, 28, 12, 28, 223, 9, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 4, 35, 263, 8, 35, 11, 35, 12, 35, 264, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 273, 8, 36, 10, 36, 12, 36, 276, 9, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 5, 37, 284, 8, 37, 10, 37, 12, 37, 287, 9, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 39, 1, 39, 1, 40, 1, 40, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 44, 1, 44, 1, 45, 1, 45, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 49, 1, 49, 1, 50, 1, 50, 1, 51, 1, 51, 1, 52, 1, 52, 1, 53, 1, 53, 1, 54, 1, 54, 1, 55, 1, 55, 1, 56, 1, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 59, 1, 59, 1, 60, 1, 60, 1, 61, 1, 61, 1, 62, 1, 62, 1, 63, 1, 63, 1, 64, 1, 64, 1, 65, 1, 65, 1, 285, 0, 66, 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, 79, 0, 81, 0, 83, 0, 85, 0, 87, 0, 89, 0, 91, 0, 93, 0, 95, 0, 97, 0, 99, 0, 101, 0, 103, 0, 105, 0, 107, 0, 109, 0, 111, 0, 113, 0, 115, 0, 117, 0, 119, 0, 121, 0, 123, 0, 125, 0, 127, 0, 129, 0, 131, 0, 1, 0, 31, 1, 0, 39, 39, 3, 0, 9, 10, 13, 13, 32, 32, 2, 0, 10, 10, 13, 13, 1, 0, 48, 57, 2, 0, 65, 90, 97, 122, 2, 0, 65, 65, 97, 97, 2, 0, 66, 66, 98, 98, 2, 0, 67, 67, 99, 99, 2, 0, 68, 68, 100, 100, 2, 0, 69, 69, 101, 101, 2, 0, 70, 70, 102, 102, 2, 0, 71, 71, 103, 103, 2, 0, 72, 72, 104, 104, 2, 0, 73, 73, 105, 105, 2, 0, 74, 74, 106, 106, 2, 0, 75, 75, 107, 107, 2, 0, 76, 76, 108, 108, 2, 0, 77, 77, 109, 109, 2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 0, 80, 80, 112, 112, 2, 0, 81, 81, 113, 113, 2, 0, 82, 82, 114, 114, 2, 0, 83, 83, 115, 115, 2, 0, 84, 84, 116, 116, 2, 0, 85, 85, 117, 117, 2, 0, 86, 86, 118, 118, 2, 0, 87, 87, 119, 119, 2, 0, 88, 88, 120, 120, 2, 0, 89, 89, 121, 121, 2, 0, 90, 90, 122, 122, 331, 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, 133, 1, 0, 0, 0, 3, 135, 1, 0, 0, 0, 5, 137, 1, 0, 0, 0, 7, 139, 1, 0, 0, 0, 9, 141, 1, 0, 0, 0, 11, 143, 1, 0, 0, 0, 13, 145, 1, 0, 0, 0, 15, 147, 1, 0, 0, 0, 17, 150, 1, 0, 0, 0, 19, 152, 1, 0, 0, 0, 21, 155, 1, 0, 0, 0, 23, 157, 1, 0, 0, 0, 25, 160, 1, 0, 0, 0, 27, 164, 1, 0, 0, 0, 29, 167, 1, 0, 0, 0, 31, 171, 1, 0, 0, 0, 33, 173, 1, 0, 0, 0, 35, 175, 1, 0, 0, 0, 37, 177, 1, 0, 0, 0, 39, 179, 1, 0, 0, 0, 41, 181, 1, 0, 0, 0, 43, 183, 1, 0, 0, 0, 45, 185, 1, 0, 0, 0, 47, 187, 1, 0, 0, 0, 49, 189, 1, 0, 0, 0, 51, 191, 1, 0, 0, 0, 53, 193, 1, 0, 0, 0, 55, 203, 1, 0, 0, 0, 57, 215, 1, 0, 0, 0, 59, 226, 1, 0, 0, 0, 61, 231, 1, 0, 0, 0, 63, 237, 1, 0, 0, 0, 65, 242, 1, 0, 0, 0, 67, 247, 1, 0, 0, 0, 69, 252, 1, 0, 0, 0, 71, 262, 1, 0, 0, 0, 73, 268, 1, 0, 0, 0, 75, 279, 1, 0, 0, 0, 77, 293, 1, 0, 0, 0, 79, 295, 1, 0, 0, 0, 81, 297, 1, 0, 0, 0, 83, 299, 1, 0, 0, 0, 85, 301, 1, 0, 0, 0, 87, 303, 1, 0, 0, 0, 89, 305, 1, 0, 0, 0, 91, 307, 1, 0, 0, 0, 93, 309, 1, 0, 0, 0, 95, 311, 1, 0, 0, 0, 97, 313, 1, 0, 0, 0, 99, 315, 1, 0, 0, 0, 101, 317, 1, 0, 0, 0, 103, 319, 1, 0, 0, 0, 105, 321, 1, 0, 0, 0, 107, 323, 1, 0, 0, 0, 109, 325, 1, 0, 0, 0, 111, 327, 1, 0, 0, 0, 113, 329, 1, 0, 0, 0, 115, 331, 1, 0, 0, 0, 117, 333, 1, 0, 0, 0, 119, 335, 1, 0, 0, 0, 121, 337, 1, 0, 0, 0, 123, 339, 1, 0, 0, 0, 125, 341, 1, 0, 0, 0, 127, 343, 1, 0, 0, 0, 129, 345, 1, 0, 0, 0, 131, 347, 1, 0, 0, 0, 133, 134, 5, 43, 0, 0, 134, 2, 1, 0, 0, 0, 135, 136, 5, 45, 0, 0, 136, 4, 1, 0, 0, 0, 137, 138, 5, 42, 0, 0, 138, 6, 1, 0, 0, 0, 139, 140, 5, 47, 0, 0, 140, 8, 1, 0, 0, 0, 141, 142, 5, 37, 0, 0, 142, 10, 1, 0, 0, 0, 143, 144, 5, 94, 0, 0, 144, 12, 1, 0, 0, 0, 145, 146, 5, 61, 0, 0, 146, 14, 1, 0, 0, 0, 147, 148, 5, 33, 0, 0, 148, 149, 5, 61, 0, 0, 149, 16, 1, 0, 0, 0, 150, 151, 5, 60, 0, 0, 151, 18, 1, 0, 0, 0, 152, 153, 5, 60, 0, 0, 153, 154, 5, 61, 0, 0, 154, 20, 1, 0, 0, 0, 155, 156, 5, 62, 0, 0, 156, 22, 1, 0, 0, 0, 157, 158, 5, 62, 0, 0, 158, 159, 5, 61, 0, 0, 159, 24, 1, 0, 0, 0, 160, 161, 3, 81, 40, 0, 161, 162, 3, 107, 53, 0, 162, 163, 3, 87, 43, 0, 163, 26, 1, 0, 0, 0, 164, 165, 3, 109, 54, 0, 165, 166, 3, 115, 57, 0, 166, 28, 1, 0, 0, 0, 167, 168, 3, 107, 53, 0, 168, 169, 3, 109, 54, 0, 169, 170, 3, 119, 59, 0, 170, 30, 1, 0, 0, 0, 171, 172, 5, 40, 0, 0, 172, 32, 1, 0, 0, 0, 173, 174, 5, 41, 0, 0, 174, 34, 1, 0, 0, 0, 175, 176, 5, 123, 0, 0, 176, 36, 1, 0, 0, 0, 177, 178, 5, 125, 0, 0, 178, 38, 1, 0, 0, 0, 179, 180, 5, 91, 0, 0, 180, 40, 1, 0, 0, 0, 181, 182, 5, 93, 0, 0, 182, 42, 1, 0, 0, 0, 183, 184, 5, 44, 0, 0, 184, 44, 1, 0, 0, 0, 185, 186, 5, 59, 0, 0, 186, 46, 1, 0, 0, 0, 187, 188, 5, 58, 0, 0, 188, 48, 1, 0, 0, 0, 189, 190, 5, 46, 0, 0, 190, 50, 1, 0, 0, 0, 191, 192, 5, 95, 0, 0, 192, 52, 1, 0, 0, 0, 193, 199, 3, 79, 39, 0, 194, 198, 3, 79, 39, 0, 195, 198, 3, 77, 38, 0, 196, 198, 3, 51, 25, 0, 197, 194, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 197, 196, 1, 0, 0, 0, 198, 201, 1, 0, 0, 0, 199, 197, 1, 0, 0, 0, 199, 200, 1, 0, 0, 0, 200, 54, 1, 0, 0, 0, 201, 199, 1, 0, 0, 0, 202, 204, 3, 77, 38, 0, 203, 202, 1, 0, 0, 0, 204, 205, 1, 0, 0, 0, 205, 203, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 213, 1, 0, 0, 0, 207, 209, 5, 46, 0, 0, 208, 210, 3, 77, 38, 0, 209, 208, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 209, 1, 0, 0, 0, 211, 212, 1, 0, 0, 0, 212, 214, 1, 0, 0, 0, 213, 207, 1, 0, 0, 0, 213, 214, 1, 0, 0, 0, 214, 56, 1, 0, 0, 0, 215, 221, 5, 39, 0, 0, 216, 220, 8, 0, 0, 0, 217, 218, 5, 39, 0, 0, 218, 220, 5, 39, 0, 0, 219, 216, 1, 0, 0, 0, 219, 217, 1, 0, 0, 0, 220, 223, 1, 0, 0, 0, 221, 219, 1, 0, 0, 0, 221, 222, 1, 0, 0, 0, 222, 224, 1, 0, 0, 0, 223, 221, 1, 0, 0, 0, 224, 225, 5, 39, 0, 0, 225, 58, 1, 0, 0, 0, 226, 227, 3, 119, 59, 0, 227, 228, 3, 115, 57, 0, 228, 229, 3, 121, 60, 0, 229, 230, 3, 89, 44, 0, 230, 60, 1, 0, 0, 0, 231, 232, 3, 91, 45, 0, 232, 233, 3, 81, 40, 0, 233, 234, 3, 103, 51, 0, 234, 235, 3, 117, 58, 0, 235, 236, 3, 89, 44, 0, 236, 62, 1, 0, 0, 0, 237, 238, 3, 107, 53, 0, 238, 239, 3, 121, 60, 0, 239, 240, 3, 103, 51, 0, 240, 241, 3, 103, 51, 0, 241, 64, 1, 0, 0, 0, 242, 243, 3, 87, 43, 0, 243, 244, 3, 81, 40, 0, 244, 245, 3, 119, 59, 0, 245, 246, 3, 89, 44, 0, 246, 66, 1, 0, 0, 0, 247, 248, 3, 119, 59, 0, 248, 249, 3, 97, 48, 0, 249, 250, 3, 105, 52, 0, 250, 251, 3, 89, 44, 0, 251, 68, 1, 0, 0, 0, 252, 253, 3, 87, 43, 0, 253, 254, 3, 81, 40, 0, 254, 255, 3, 119, 59, 0, 255, 256, 3, 89, 44, 0, 256, 257, 3, 119, 59, 0, 257, 258, 3, 97, 48, 0, 258, 259, 3, 105, 52, 0, 259, 260, 3, 89, 44, 0, 260, 70, 1, 0, 0, 0, 261, 263, 7, 1, 0, 0, 262, 261, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 262, 1, 0, 0, 0, 264, 265, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 267, 6, 35, 0, 0, 267, 72, 1, 0, 0, 0, 268, 269, 5, 47, 0, 0, 269, 270, 5, 47, 0, 0, 270, 274, 1, 0, 0, 0, 271, 273, 8, 2, 0, 0, 272, 271, 1, 0, 0, 0, 273, 276, 1, 0, 0, 0, 274, 272, 1, 0, 0, 0, 274, 275, 1, 0, 0, 0, 275, 277, 1, 0, 0, 0, 276, 274, 1, 0, 0, 0, 277, 278, 6, 36, 0, 0, 278, 74, 1, 0, 0, 0, 279, 280, 5, 47, 0, 0, 280, 281, 5, 42, 0, 0, 281, 285, 1, 0, 0, 0, 282, 284, 9, 0, 0, 0, 283, 282, 1, 0, 0, 0, 284, 287, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 285, 283, 1, 0, 0, 0, 286, 288, 1, 0, 0, 0, 287, 285, 1, 0, 0, 0, 288, 289, 5, 42, 0, 0, 289, 290, 5, 47, 0, 0, 290, 291, 1, 0, 0, 0, 291, 292, 6, 37, 0, 0, 292, 76, 1, 0, 0, 0, 293, 294, 7, 3, 0, 0, 294, 78, 1, 0, 0, 0, 295, 296, 7, 4, 0, 0, 296, 80, 1, 0, 0, 0, 297, 298, 7, 5, 0, 0, 298, 82, 1, 0, 0, 0, 299, 300, 7, 6, 0, 0, 300, 84, 1, 0, 0, 0, 301, 302, 7, 7, 0, 0, 302, 86, 1, 0, 0, 0, 303, 304, 7, 8, 0, 0, 304, 88, 1, 0, 0, 0, 305, 306, 7, 9, 0, 0, 306, 90, 1, 0, 0, 0, 307, 308, 7, 10, 0, 0, 308, 92, 1, 0, 0, 0, 309, 310, 7, 11, 0, 0, 310, 94, 1, 0, 0, 0, 311, 312, 7, 12, 0, 0, 312, 96, 1, 0, 0, 0, 313, 314, 7, 13, 0, 0, 314, 98, 1, 0, 0, 0, 315, 316, 7, 14, 0, 0, 316, 100, 1, 0, 0, 0, 317, 318, 7, 15, 0, 0, 318, 102, 1, 0, 0, 0, 319, 320, 7, 16, 0, 0, 320, 104, 1, 0, 0, 0, 321, 322, 7, 17, 0, 0, 322, 106, 1, 0, 0, 0, 323, 324, 7, 18, 0, 0, 324, 108, 1, 0, 0, 0, 325, 326, 7, 19, 0, 0, 326, 110, 1, 0, 0, 0, 327, 328, 7, 20, 0, 0, 328, 112, 1, 0, 0, 0, 329, 330, 7, 21, 0, 0, 330, 114, 1, 0, 0, 0, 331, 332, 7, 22, 0, 0, 332, 116, 1, 0, 0, 0, 333, 334, 7, 23, 0, 0, 334, 118, 1, 0, 0, 0, 335, 336, 7, 24, 0, 0, 336, 120, 1, 0, 0, 0, 337, 338, 7, 25, 0, 0, 338, 122, 1, 0, 0, 0, 339, 340, 7, 26, 0, 0, 340, 124, 1, 0, 0, 0, 341, 342, 7, 27, 0, 0, 342, 126, 1, 0, 0, 0, 343, 344, 7, 28, 0, 0, 344, 128, 1, 0, 0, 0, 345, 346, 7, 29, 0, 0, 346, 130, 1, 0, 0, 0, 347, 348, 7, 30, 0, 0, 348, 132, 1, 0, 0, 0, 11, 0, 197, 199, 205, 211, 213, 219, 221, 264, 274, 285, 1, 6, 0, 0] \ No newline at end of file diff --git a/packages/formula/src/grammar/FormulaLexer.ts b/packages/formula/src/grammar/FormulaLexer.ts index 21703eae9..1bb9d0235 100644 --- a/packages/formula/src/grammar/FormulaLexer.ts +++ b/packages/formula/src/grammar/FormulaLexer.ts @@ -1,21 +1,17 @@ -// Generated from src/grammar/FormulaLexer.g4 by ANTLR 4.9.0-SNAPSHOT - - -import { ATN } from "antlr4ts/atn/ATN"; -import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer"; -import { CharStream } from "antlr4ts/CharStream"; -import { Lexer } from "antlr4ts/Lexer"; -import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator"; -import { NotNull } from "antlr4ts/Decorators"; -import { Override } from "antlr4ts/Decorators"; -import { RuleContext } from "antlr4ts/RuleContext"; -import { Vocabulary } from "antlr4ts/Vocabulary"; -import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; - -import * as Utils from "antlr4ts/misc/Utils"; - - -export class FormulaLexer extends Lexer { +// Generated from src/grammar/FormulaLexer.g4 by ANTLR 4.13.2 +// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols +import { + ATN, + ATNDeserializer, + CharStream, + DecisionState, DFA, + Lexer, + LexerATNSimulator, + RuleContext, + PredictionContextCache, + Token +} from "antlr4"; +export default class FormulaLexer extends Lexer { public static readonly ADD = 1; public static readonly SUBTRACT = 2; public static readonly MULTIPLY = 3; @@ -54,16 +50,48 @@ export class FormulaLexer extends Lexer { public static readonly WS = 36; public static readonly COMMENT = 37; public static readonly MULTILINE_COMMENT = 38; - - // tslint:disable:no-trailing-whitespace - public static readonly channelNames: string[] = [ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", - ]; - - // tslint:disable:no-trailing-whitespace - public static readonly modeNames: string[] = [ - "DEFAULT_MODE", - ]; + public static readonly EOF = Token.EOF; + + public static readonly channelNames: string[] = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ]; + public static readonly literalNames: (string | null)[] = [ null, "'+'", + "'-'", "'*'", + "'/'", "'%'", + "'^'", "'='", + "'!='", "'<'", + "'<='", "'>'", + "'>='", null, + null, null, + "'('", "')'", + "'{'", "'}'", + "'['", "']'", + "','", "';'", + "':'", "'.'", + "'_'" ]; + public static readonly symbolicNames: (string | null)[] = [ null, "ADD", + "SUBTRACT", + "MULTIPLY", + "DIVIDE", "MODULO", + "POWER", "EQUAL", + "NOT_EQUAL", + "LESS", "LESS_EQUAL", + "GREATER", + "GREATER_EQUAL", + "AND", "OR", + "NOT", "LPAREN", + "RPAREN", "LBRACE", + "RBRACE", "LBRACKET", + "RBRACKET", + "COMMA", "SEMICOLON", + "COLON", "DOT", + "UNDERSCORE", + "IDENTIFIER", + "NUMBER", "STRING", + "TRUE", "FALSE", + "NULL", "DATE", + "TIME", "DATETIME", + "WS", "COMMENT", + "MULTILINE_COMMENT" ]; + public static readonly modeNames: string[] = [ "DEFAULT_MODE", ]; public static readonly ruleNames: string[] = [ "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "MODULO", "POWER", "EQUAL", "NOT_EQUAL", @@ -76,211 +104,146 @@ export class FormulaLexer extends Lexer { "U", "V", "W", "X", "Y", "Z", ]; - private static readonly _LITERAL_NAMES: Array = [ - undefined, "'+'", "'-'", "'*'", "'/'", "'%'", "'^'", "'='", "'!='", "'<'", - "'<='", "'>'", "'>='", undefined, undefined, undefined, "'('", "')'", - "'{'", "'}'", "'['", "']'", "','", "';'", "':'", "'.'", "'_'", - ]; - private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "MODULO", "POWER", - "EQUAL", "NOT_EQUAL", "LESS", "LESS_EQUAL", "GREATER", "GREATER_EQUAL", - "AND", "OR", "NOT", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACKET", - "RBRACKET", "COMMA", "SEMICOLON", "COLON", "DOT", "UNDERSCORE", "IDENTIFIER", - "NUMBER", "STRING", "TRUE", "FALSE", "NULL", "DATE", "TIME", "DATETIME", - "WS", "COMMENT", "MULTILINE_COMMENT", - ]; - public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(FormulaLexer._LITERAL_NAMES, FormulaLexer._SYMBOLIC_NAMES, []); - - // @Override - // @NotNull - public get vocabulary(): Vocabulary { - return FormulaLexer.VOCABULARY; - } - // tslint:enable:no-trailing-whitespace - constructor(input: CharStream) { super(input); - this._interp = new LexerATNSimulator(FormulaLexer._ATN, this); + this._interp = new LexerATNSimulator(this, FormulaLexer._ATN, FormulaLexer.DecisionsToDFA, new PredictionContextCache()); } - // @Override public get grammarFileName(): string { return "FormulaLexer.g4"; } - // @Override + public get literalNames(): (string | null)[] { return FormulaLexer.literalNames; } + public get symbolicNames(): (string | null)[] { return FormulaLexer.symbolicNames; } public get ruleNames(): string[] { return FormulaLexer.ruleNames; } - // @Override - public get serializedATN(): string { return FormulaLexer._serializedATN; } + public get serializedATN(): number[] { return FormulaLexer._serializedATN; } - // @Override public get channelNames(): string[] { return FormulaLexer.channelNames; } - // @Override public get modeNames(): string[] { return FormulaLexer.modeNames; } - public static readonly _serializedATN: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02(\u015F\b\x01" + - "\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06" + - "\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04\r" + - "\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12\t" + - "\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16\x04\x17\t" + - "\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\x04\x1B\t\x1B\x04\x1C\t" + - "\x1C\x04\x1D\t\x1D\x04\x1E\t\x1E\x04\x1F\t\x1F\x04 \t \x04!\t!\x04\"\t" + - "\"\x04#\t#\x04$\t$\x04%\t%\x04&\t&\x04\'\t\'\x04(\t(\x04)\t)\x04*\t*\x04" + - "+\t+\x04,\t,\x04-\t-\x04.\t.\x04/\t/\x040\t0\x041\t1\x042\t2\x043\t3\x04" + - "4\t4\x045\t5\x046\t6\x047\t7\x048\t8\x049\t9\x04:\t:\x04;\t;\x04<\t<\x04" + - "=\t=\x04>\t>\x04?\t?\x04@\t@\x04A\tA\x04B\tB\x04C\tC\x03\x02\x03\x02\x03" + - "\x03\x03\x03\x03\x04\x03\x04\x03\x05\x03\x05\x03\x06\x03\x06\x03\x07\x03" + - "\x07\x03\b\x03\b\x03\t\x03\t\x03\t\x03\n\x03\n\x03\v\x03\v\x03\v\x03\f" + - "\x03\f\x03\r\x03\r\x03\r\x03\x0E\x03\x0E\x03\x0E\x03\x0E\x03\x0F\x03\x0F" + - "\x03\x0F\x03\x10\x03\x10\x03\x10\x03\x10\x03\x11\x03\x11\x03\x12\x03\x12" + - "\x03\x13\x03\x13\x03\x14\x03\x14\x03\x15\x03\x15\x03\x16\x03\x16\x03\x17" + - "\x03\x17\x03\x18\x03\x18\x03\x19\x03\x19\x03\x1A\x03\x1A\x03\x1B\x03\x1B" + - "\x03\x1C\x03\x1C\x03\x1C\x03\x1C\x07\x1C\xC8\n\x1C\f\x1C\x0E\x1C\xCB\v" + - "\x1C\x03\x1D\x06\x1D\xCE\n\x1D\r\x1D\x0E\x1D\xCF\x03\x1D\x03\x1D\x06\x1D" + - "\xD4\n\x1D\r\x1D\x0E\x1D\xD5\x05\x1D\xD8\n\x1D\x03\x1E\x03\x1E\x03\x1E" + - "\x03\x1E\x07\x1E\xDE\n\x1E\f\x1E\x0E\x1E\xE1\v\x1E\x03\x1E\x03\x1E\x03" + - "\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03 \x03 \x03 \x03 \x03 \x03 \x03" + - "!\x03!\x03!\x03!\x03!\x03\"\x03\"\x03\"\x03\"\x03\"\x03#\x03#\x03#\x03" + - "#\x03#\x03$\x03$\x03$\x03$\x03$\x03$\x03$\x03$\x03$\x03%\x06%\u0109\n" + - "%\r%\x0E%\u010A\x03%\x03%\x03&\x03&\x03&\x03&\x07&\u0113\n&\f&\x0E&\u0116" + - "\v&\x03&\x03&\x03\'\x03\'\x03\'\x03\'\x07\'\u011E\n\'\f\'\x0E\'\u0121" + - "\v\'\x03\'\x03\'\x03\'\x03\'\x03\'\x03(\x03(\x03)\x03)\x03*\x03*\x03+" + - "\x03+\x03,\x03,\x03-\x03-\x03.\x03.\x03/\x03/\x030\x030\x031\x031\x03" + - "2\x032\x033\x033\x034\x034\x035\x035\x036\x036\x037\x037\x038\x038\x03" + - "9\x039\x03:\x03:\x03;\x03;\x03<\x03<\x03=\x03=\x03>\x03>\x03?\x03?\x03" + - "@\x03@\x03A\x03A\x03B\x03B\x03C\x03C\x03\u011F\x02\x02D\x03\x02\x03\x05" + - "\x02\x04\x07\x02\x05\t\x02\x06\v\x02\x07\r\x02\b\x0F\x02\t\x11\x02\n\x13" + - "\x02\v\x15\x02\f\x17\x02\r\x19\x02\x0E\x1B\x02\x0F\x1D\x02\x10\x1F\x02" + - "\x11!\x02\x12#\x02\x13%\x02\x14\'\x02\x15)\x02\x16+\x02\x17-\x02\x18/" + - "\x02\x191\x02\x1A3\x02\x1B5\x02\x1C7\x02\x1D9\x02\x1E;\x02\x1F=\x02 ?" + - "\x02!A\x02\"C\x02#E\x02$G\x02%I\x02&K\x02\'M\x02(O\x02\x02Q\x02\x02S\x02" + - "\x02U\x02\x02W\x02\x02Y\x02\x02[\x02\x02]\x02\x02_\x02\x02a\x02\x02c\x02" + - "\x02e\x02\x02g\x02\x02i\x02\x02k\x02\x02m\x02\x02o\x02\x02q\x02\x02s\x02" + - "\x02u\x02\x02w\x02\x02y\x02\x02{\x02\x02}\x02\x02\x7F\x02\x02\x81\x02" + - "\x02\x83\x02\x02\x85\x02\x02\x03\x02!\x03\x02))\x05\x02\v\f\x0F\x0F\"" + - "\"\x04\x02\f\f\x0F\x0F\x03\x022;\x04\x02C\\c|\x04\x02CCcc\x04\x02DDdd" + - "\x04\x02EEee\x04\x02FFff\x04\x02GGgg\x04\x02HHhh\x04\x02IIii\x04\x02J" + - "Jjj\x04\x02KKkk\x04\x02LLll\x04\x02MMmm\x04\x02NNnn\x04\x02OOoo\x04\x02" + - "PPpp\x04\x02QQqq\x04\x02RRrr\x04\x02SSss\x04\x02TTtt\x04\x02UUuu\x04\x02" + - "VVvv\x04\x02WWww\x04\x02XXxx\x04\x02YYyy\x04\x02ZZzz\x04\x02[[{{\x04\x02" + - "\\\\||\x02\u014D\x02\x03\x03\x02\x02\x02\x02\x05\x03\x02\x02\x02\x02\x07" + - "\x03\x02\x02\x02\x02\t\x03\x02\x02\x02\x02\v\x03\x02\x02\x02\x02\r\x03" + - "\x02\x02\x02\x02\x0F\x03\x02\x02\x02\x02\x11\x03\x02\x02\x02\x02\x13\x03" + - "\x02\x02\x02\x02\x15\x03\x02\x02\x02\x02\x17\x03\x02\x02\x02\x02\x19\x03" + - "\x02\x02\x02\x02\x1B\x03\x02\x02\x02\x02\x1D\x03\x02\x02\x02\x02\x1F\x03" + - "\x02\x02\x02\x02!\x03\x02\x02\x02\x02#\x03\x02\x02\x02\x02%\x03\x02\x02" + - "\x02\x02\'\x03\x02\x02\x02\x02)\x03\x02\x02\x02\x02+\x03\x02\x02\x02\x02" + - "-\x03\x02\x02\x02\x02/\x03\x02\x02\x02\x021\x03\x02\x02\x02\x023\x03\x02" + - "\x02\x02\x025\x03\x02\x02\x02\x027\x03\x02\x02\x02\x029\x03\x02\x02\x02" + - "\x02;\x03\x02\x02\x02\x02=\x03\x02\x02\x02\x02?\x03\x02\x02\x02\x02A\x03" + - "\x02\x02\x02\x02C\x03\x02\x02\x02\x02E\x03\x02\x02\x02\x02G\x03\x02\x02" + - "\x02\x02I\x03\x02\x02\x02\x02K\x03\x02\x02\x02\x02M\x03\x02\x02\x02\x03" + - "\x87\x03\x02\x02\x02\x05\x89\x03\x02\x02\x02\x07\x8B\x03\x02\x02\x02\t" + - "\x8D\x03\x02\x02\x02\v\x8F\x03\x02\x02\x02\r\x91\x03\x02\x02\x02\x0F\x93" + - "\x03\x02\x02\x02\x11\x95\x03\x02\x02\x02\x13\x98\x03\x02\x02\x02\x15\x9A" + - "\x03\x02\x02\x02\x17\x9D\x03\x02\x02\x02\x19\x9F\x03\x02\x02\x02\x1B\xA2" + - "\x03\x02\x02\x02\x1D\xA6\x03\x02\x02\x02\x1F\xA9\x03\x02\x02\x02!\xAD" + - "\x03\x02\x02\x02#\xAF\x03\x02\x02\x02%\xB1\x03\x02\x02\x02\'\xB3\x03\x02" + - "\x02\x02)\xB5\x03\x02\x02\x02+\xB7\x03\x02\x02\x02-\xB9\x03\x02\x02\x02" + - "/\xBB\x03\x02\x02\x021\xBD\x03\x02\x02\x023\xBF\x03\x02\x02\x025\xC1\x03" + - "\x02\x02\x027\xC3\x03\x02\x02\x029\xCD\x03\x02\x02\x02;\xD9\x03\x02\x02" + - "\x02=\xE4\x03\x02\x02\x02?\xE9\x03\x02\x02\x02A\xEF\x03\x02\x02\x02C\xF4" + - "\x03\x02\x02\x02E\xF9\x03\x02\x02\x02G\xFE\x03\x02\x02\x02I\u0108\x03" + - "\x02\x02\x02K\u010E\x03\x02\x02\x02M\u0119\x03\x02\x02\x02O\u0127\x03" + - "\x02\x02\x02Q\u0129\x03\x02\x02\x02S\u012B\x03\x02\x02\x02U\u012D\x03" + - "\x02\x02\x02W\u012F\x03\x02\x02\x02Y\u0131\x03\x02\x02\x02[\u0133\x03" + - "\x02\x02\x02]\u0135\x03\x02\x02\x02_\u0137\x03\x02\x02\x02a\u0139\x03" + - "\x02\x02\x02c\u013B\x03\x02\x02\x02e\u013D\x03\x02\x02\x02g\u013F\x03" + - "\x02\x02\x02i\u0141\x03\x02\x02\x02k\u0143\x03\x02\x02\x02m\u0145\x03" + - "\x02\x02\x02o\u0147\x03\x02\x02\x02q\u0149\x03\x02\x02\x02s\u014B\x03" + - "\x02\x02\x02u\u014D\x03\x02\x02\x02w\u014F\x03\x02\x02\x02y\u0151\x03" + - "\x02\x02\x02{\u0153\x03\x02\x02\x02}\u0155\x03\x02\x02\x02\x7F\u0157\x03" + - "\x02\x02\x02\x81\u0159\x03\x02\x02\x02\x83\u015B\x03\x02\x02\x02\x85\u015D" + - "\x03\x02\x02\x02\x87\x88\x07-\x02\x02\x88\x04\x03\x02\x02\x02\x89\x8A" + - "\x07/\x02\x02\x8A\x06\x03\x02\x02\x02\x8B\x8C\x07,\x02\x02\x8C\b\x03\x02" + - "\x02\x02\x8D\x8E\x071\x02\x02\x8E\n\x03\x02\x02\x02\x8F\x90\x07\'\x02" + - "\x02\x90\f\x03\x02\x02\x02\x91\x92\x07`\x02\x02\x92\x0E\x03\x02\x02\x02" + - "\x93\x94\x07?\x02\x02\x94\x10\x03\x02\x02\x02\x95\x96\x07#\x02\x02\x96" + - "\x97\x07?\x02\x02\x97\x12\x03\x02\x02\x02\x98\x99\x07>\x02\x02\x99\x14" + - "\x03\x02\x02\x02\x9A\x9B\x07>\x02\x02\x9B\x9C\x07?\x02\x02\x9C\x16\x03" + - "\x02\x02\x02\x9D\x9E\x07@\x02\x02\x9E\x18\x03\x02\x02\x02\x9F\xA0\x07" + - "@\x02\x02\xA0\xA1\x07?\x02\x02\xA1\x1A\x03\x02\x02\x02\xA2\xA3\x05S*\x02" + - "\xA3\xA4\x05m7\x02\xA4\xA5\x05Y-\x02\xA5\x1C\x03\x02\x02\x02\xA6\xA7\x05" + - "o8\x02\xA7\xA8\x05u;\x02\xA8\x1E\x03\x02\x02\x02\xA9\xAA\x05m7\x02\xAA" + - "\xAB\x05o8\x02\xAB\xAC\x05y=\x02\xAC \x03\x02\x02\x02\xAD\xAE\x07*\x02" + - "\x02\xAE\"\x03\x02\x02\x02\xAF\xB0\x07+\x02\x02\xB0$\x03\x02\x02\x02\xB1" + - "\xB2\x07}\x02\x02\xB2&\x03\x02\x02\x02\xB3\xB4\x07\x7F\x02\x02\xB4(\x03" + - "\x02\x02\x02\xB5\xB6\x07]\x02\x02\xB6*\x03\x02\x02\x02\xB7\xB8\x07_\x02" + - "\x02\xB8,\x03\x02\x02\x02\xB9\xBA\x07.\x02\x02\xBA.\x03\x02\x02\x02\xBB" + - "\xBC\x07=\x02\x02\xBC0\x03\x02\x02\x02\xBD\xBE\x07<\x02\x02\xBE2\x03\x02" + - "\x02\x02\xBF\xC0\x070\x02\x02\xC04\x03\x02\x02\x02\xC1\xC2\x07a\x02\x02" + - "\xC26\x03\x02\x02\x02\xC3\xC9\x05Q)\x02\xC4\xC8\x05Q)\x02\xC5\xC8\x05" + - "O(\x02\xC6\xC8\x055\x1B\x02\xC7\xC4\x03\x02\x02\x02\xC7\xC5\x03\x02\x02" + - "\x02\xC7\xC6\x03\x02\x02\x02\xC8\xCB\x03\x02\x02\x02\xC9\xC7\x03\x02\x02" + - "\x02\xC9\xCA\x03\x02\x02\x02\xCA8\x03\x02\x02\x02\xCB\xC9\x03\x02\x02" + - "\x02\xCC\xCE\x05O(\x02\xCD\xCC\x03\x02\x02\x02\xCE\xCF\x03\x02\x02\x02" + - "\xCF\xCD\x03\x02\x02\x02\xCF\xD0\x03\x02\x02\x02\xD0\xD7\x03\x02\x02\x02" + - "\xD1\xD3\x070\x02\x02\xD2\xD4\x05O(\x02\xD3\xD2\x03\x02\x02\x02\xD4\xD5" + - "\x03\x02\x02\x02\xD5\xD3\x03\x02\x02\x02\xD5\xD6\x03\x02\x02\x02\xD6\xD8" + - "\x03\x02\x02\x02\xD7\xD1\x03\x02\x02\x02\xD7\xD8\x03\x02\x02\x02\xD8:" + - "\x03\x02\x02\x02\xD9\xDF\x07)\x02\x02\xDA\xDE\n\x02\x02\x02\xDB\xDC\x07" + - ")\x02\x02\xDC\xDE\x07)\x02\x02\xDD\xDA\x03\x02\x02\x02\xDD\xDB\x03\x02" + - "\x02\x02\xDE\xE1\x03\x02\x02\x02\xDF\xDD\x03\x02\x02\x02\xDF\xE0\x03\x02" + - "\x02\x02\xE0\xE2\x03\x02\x02\x02\xE1\xDF\x03\x02\x02\x02\xE2\xE3\x07)" + - "\x02\x02\xE3<\x03\x02\x02\x02\xE4\xE5\x05y=\x02\xE5\xE6\x05u;\x02\xE6" + - "\xE7\x05{>\x02\xE7\xE8\x05[.\x02\xE8>\x03\x02\x02\x02\xE9\xEA\x05]/\x02" + - "\xEA\xEB\x05S*\x02\xEB\xEC\x05i5\x02\xEC\xED\x05w<\x02\xED\xEE\x05[.\x02" + - "\xEE@\x03\x02\x02\x02\xEF\xF0\x05m7\x02\xF0\xF1\x05{>\x02\xF1\xF2\x05" + - "i5\x02\xF2\xF3\x05i5\x02\xF3B\x03\x02\x02\x02\xF4\xF5\x05Y-\x02\xF5\xF6" + - "\x05S*\x02\xF6\xF7\x05y=\x02\xF7\xF8\x05[.\x02\xF8D\x03\x02\x02\x02\xF9" + - "\xFA\x05y=\x02\xFA\xFB\x05c2\x02\xFB\xFC\x05k6\x02\xFC\xFD\x05[.\x02\xFD" + - "F\x03\x02\x02\x02\xFE\xFF\x05Y-\x02\xFF\u0100\x05S*\x02\u0100\u0101\x05" + - "y=\x02\u0101\u0102\x05[.\x02\u0102\u0103\x05y=\x02\u0103\u0104\x05c2\x02" + - "\u0104\u0105\x05k6\x02\u0105\u0106\x05[.\x02\u0106H\x03\x02\x02\x02\u0107" + - "\u0109\t\x03\x02\x02\u0108\u0107\x03\x02\x02\x02\u0109\u010A\x03\x02\x02" + - "\x02\u010A\u0108\x03\x02\x02\x02\u010A\u010B\x03\x02\x02\x02\u010B\u010C" + - "\x03\x02\x02\x02\u010C\u010D\b%\x02\x02\u010DJ\x03\x02\x02\x02\u010E\u010F" + - "\x071\x02\x02\u010F\u0110\x071\x02\x02\u0110\u0114\x03\x02\x02\x02\u0111" + - "\u0113\n\x04\x02\x02\u0112\u0111\x03\x02\x02\x02\u0113\u0116\x03\x02\x02" + - "\x02\u0114\u0112\x03\x02\x02\x02\u0114\u0115\x03\x02\x02\x02\u0115\u0117" + - "\x03\x02\x02\x02\u0116\u0114\x03\x02\x02\x02\u0117\u0118\b&\x02\x02\u0118" + - "L\x03\x02\x02\x02\u0119\u011A\x071\x02\x02\u011A\u011B\x07,\x02\x02\u011B" + - "\u011F\x03\x02\x02\x02\u011C\u011E\v\x02\x02\x02\u011D\u011C\x03\x02\x02" + - "\x02\u011E\u0121\x03\x02\x02\x02\u011F\u0120\x03\x02\x02\x02\u011F\u011D" + - "\x03\x02\x02\x02\u0120\u0122\x03\x02\x02\x02\u0121\u011F\x03\x02\x02\x02" + - "\u0122\u0123\x07,\x02\x02\u0123\u0124\x071\x02\x02\u0124\u0125\x03\x02" + - "\x02\x02\u0125\u0126\b\'\x02\x02\u0126N\x03\x02\x02\x02\u0127\u0128\t" + - "\x05\x02\x02\u0128P\x03\x02\x02\x02\u0129\u012A\t\x06\x02\x02\u012AR\x03" + - "\x02\x02\x02\u012B\u012C\t\x07\x02\x02\u012CT\x03\x02\x02\x02\u012D\u012E" + - "\t\b\x02\x02\u012EV\x03\x02\x02\x02\u012F\u0130\t\t\x02\x02\u0130X\x03" + - "\x02\x02\x02\u0131\u0132\t\n\x02\x02\u0132Z\x03\x02\x02\x02\u0133\u0134" + - "\t\v\x02\x02\u0134\\\x03\x02\x02\x02\u0135\u0136\t\f\x02\x02\u0136^\x03" + - "\x02\x02\x02\u0137\u0138\t\r\x02\x02\u0138`\x03\x02\x02\x02\u0139\u013A" + - "\t\x0E\x02\x02\u013Ab\x03\x02\x02\x02\u013B\u013C\t\x0F\x02\x02\u013C" + - "d\x03\x02\x02\x02\u013D\u013E\t\x10\x02\x02\u013Ef\x03\x02\x02\x02\u013F" + - "\u0140\t\x11\x02\x02\u0140h\x03\x02\x02\x02\u0141\u0142\t\x12\x02\x02" + - "\u0142j\x03\x02\x02\x02\u0143\u0144\t\x13\x02\x02\u0144l\x03\x02\x02\x02" + - "\u0145\u0146\t\x14\x02\x02\u0146n\x03\x02\x02\x02\u0147\u0148\t\x15\x02" + - "\x02\u0148p\x03\x02\x02\x02\u0149\u014A\t\x16\x02\x02\u014Ar\x03\x02\x02" + - "\x02\u014B\u014C\t\x17\x02\x02\u014Ct\x03\x02\x02\x02\u014D\u014E\t\x18" + - "\x02\x02\u014Ev\x03\x02\x02\x02\u014F\u0150\t\x19\x02\x02\u0150x\x03\x02" + - "\x02\x02\u0151\u0152\t\x1A\x02\x02\u0152z\x03\x02\x02\x02\u0153\u0154" + - "\t\x1B\x02\x02\u0154|\x03\x02\x02\x02\u0155\u0156\t\x1C\x02\x02\u0156" + - "~\x03\x02\x02\x02\u0157\u0158\t\x1D\x02\x02\u0158\x80\x03\x02\x02\x02" + - "\u0159\u015A\t\x1E\x02\x02\u015A\x82\x03\x02\x02\x02\u015B\u015C\t\x1F" + - "\x02\x02\u015C\x84\x03\x02\x02\x02\u015D\u015E\t \x02\x02\u015E\x86\x03" + - "\x02\x02\x02\r\x02\xC7\xC9\xCF\xD5\xD7\xDD\xDF\u010A\u0114\u011F\x03\b" + - "\x02\x02"; - public static __ATN: ATN; + public static readonly _serializedATN: number[] = [4,0,38,349,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,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7, + 45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52, + 2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2, + 60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,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,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,13,1,13,1,13,1,14,1,14, + 1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,20,1,20,1, + 21,1,21,1,22,1,22,1,23,1,23,1,24,1,24,1,25,1,25,1,26,1,26,1,26,1,26,5,26, + 198,8,26,10,26,12,26,201,9,26,1,27,4,27,204,8,27,11,27,12,27,205,1,27,1, + 27,4,27,210,8,27,11,27,12,27,211,3,27,214,8,27,1,28,1,28,1,28,1,28,5,28, + 220,8,28,10,28,12,28,223,9,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,30,1, + 30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32, + 1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1, + 35,4,35,263,8,35,11,35,12,35,264,1,35,1,35,1,36,1,36,1,36,1,36,5,36,273, + 8,36,10,36,12,36,276,9,36,1,36,1,36,1,37,1,37,1,37,1,37,5,37,284,8,37,10, + 37,12,37,287,9,37,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,39,1,39,1,40,1,40, + 1,41,1,41,1,42,1,42,1,43,1,43,1,44,1,44,1,45,1,45,1,46,1,46,1,47,1,47,1, + 48,1,48,1,49,1,49,1,50,1,50,1,51,1,51,1,52,1,52,1,53,1,53,1,54,1,54,1,55, + 1,55,1,56,1,56,1,57,1,57,1,58,1,58,1,59,1,59,1,60,1,60,1,61,1,61,1,62,1, + 62,1,63,1,63,1,64,1,64,1,65,1,65,1,285,0,66,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,79,0,81,0,83,0,85,0,87,0, + 89,0,91,0,93,0,95,0,97,0,99,0,101,0,103,0,105,0,107,0,109,0,111,0,113,0, + 115,0,117,0,119,0,121,0,123,0,125,0,127,0,129,0,131,0,1,0,31,1,0,39,39, + 3,0,9,10,13,13,32,32,2,0,10,10,13,13,1,0,48,57,2,0,65,90,97,122,2,0,65, + 65,97,97,2,0,66,66,98,98,2,0,67,67,99,99,2,0,68,68,100,100,2,0,69,69,101, + 101,2,0,70,70,102,102,2,0,71,71,103,103,2,0,72,72,104,104,2,0,73,73,105, + 105,2,0,74,74,106,106,2,0,75,75,107,107,2,0,76,76,108,108,2,0,77,77,109, + 109,2,0,78,78,110,110,2,0,79,79,111,111,2,0,80,80,112,112,2,0,81,81,113, + 113,2,0,82,82,114,114,2,0,83,83,115,115,2,0,84,84,116,116,2,0,85,85,117, + 117,2,0,86,86,118,118,2,0,87,87,119,119,2,0,88,88,120,120,2,0,89,89,121, + 121,2,0,90,90,122,122,331,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,133,1,0,0,0,3,135,1,0,0,0,5,137,1,0,0,0,7,139,1,0,0,0, + 9,141,1,0,0,0,11,143,1,0,0,0,13,145,1,0,0,0,15,147,1,0,0,0,17,150,1,0,0, + 0,19,152,1,0,0,0,21,155,1,0,0,0,23,157,1,0,0,0,25,160,1,0,0,0,27,164,1, + 0,0,0,29,167,1,0,0,0,31,171,1,0,0,0,33,173,1,0,0,0,35,175,1,0,0,0,37,177, + 1,0,0,0,39,179,1,0,0,0,41,181,1,0,0,0,43,183,1,0,0,0,45,185,1,0,0,0,47, + 187,1,0,0,0,49,189,1,0,0,0,51,191,1,0,0,0,53,193,1,0,0,0,55,203,1,0,0,0, + 57,215,1,0,0,0,59,226,1,0,0,0,61,231,1,0,0,0,63,237,1,0,0,0,65,242,1,0, + 0,0,67,247,1,0,0,0,69,252,1,0,0,0,71,262,1,0,0,0,73,268,1,0,0,0,75,279, + 1,0,0,0,77,293,1,0,0,0,79,295,1,0,0,0,81,297,1,0,0,0,83,299,1,0,0,0,85, + 301,1,0,0,0,87,303,1,0,0,0,89,305,1,0,0,0,91,307,1,0,0,0,93,309,1,0,0,0, + 95,311,1,0,0,0,97,313,1,0,0,0,99,315,1,0,0,0,101,317,1,0,0,0,103,319,1, + 0,0,0,105,321,1,0,0,0,107,323,1,0,0,0,109,325,1,0,0,0,111,327,1,0,0,0,113, + 329,1,0,0,0,115,331,1,0,0,0,117,333,1,0,0,0,119,335,1,0,0,0,121,337,1,0, + 0,0,123,339,1,0,0,0,125,341,1,0,0,0,127,343,1,0,0,0,129,345,1,0,0,0,131, + 347,1,0,0,0,133,134,5,43,0,0,134,2,1,0,0,0,135,136,5,45,0,0,136,4,1,0,0, + 0,137,138,5,42,0,0,138,6,1,0,0,0,139,140,5,47,0,0,140,8,1,0,0,0,141,142, + 5,37,0,0,142,10,1,0,0,0,143,144,5,94,0,0,144,12,1,0,0,0,145,146,5,61,0, + 0,146,14,1,0,0,0,147,148,5,33,0,0,148,149,5,61,0,0,149,16,1,0,0,0,150,151, + 5,60,0,0,151,18,1,0,0,0,152,153,5,60,0,0,153,154,5,61,0,0,154,20,1,0,0, + 0,155,156,5,62,0,0,156,22,1,0,0,0,157,158,5,62,0,0,158,159,5,61,0,0,159, + 24,1,0,0,0,160,161,3,81,40,0,161,162,3,107,53,0,162,163,3,87,43,0,163,26, + 1,0,0,0,164,165,3,109,54,0,165,166,3,115,57,0,166,28,1,0,0,0,167,168,3, + 107,53,0,168,169,3,109,54,0,169,170,3,119,59,0,170,30,1,0,0,0,171,172,5, + 40,0,0,172,32,1,0,0,0,173,174,5,41,0,0,174,34,1,0,0,0,175,176,5,123,0,0, + 176,36,1,0,0,0,177,178,5,125,0,0,178,38,1,0,0,0,179,180,5,91,0,0,180,40, + 1,0,0,0,181,182,5,93,0,0,182,42,1,0,0,0,183,184,5,44,0,0,184,44,1,0,0,0, + 185,186,5,59,0,0,186,46,1,0,0,0,187,188,5,58,0,0,188,48,1,0,0,0,189,190, + 5,46,0,0,190,50,1,0,0,0,191,192,5,95,0,0,192,52,1,0,0,0,193,199,3,79,39, + 0,194,198,3,79,39,0,195,198,3,77,38,0,196,198,3,51,25,0,197,194,1,0,0,0, + 197,195,1,0,0,0,197,196,1,0,0,0,198,201,1,0,0,0,199,197,1,0,0,0,199,200, + 1,0,0,0,200,54,1,0,0,0,201,199,1,0,0,0,202,204,3,77,38,0,203,202,1,0,0, + 0,204,205,1,0,0,0,205,203,1,0,0,0,205,206,1,0,0,0,206,213,1,0,0,0,207,209, + 5,46,0,0,208,210,3,77,38,0,209,208,1,0,0,0,210,211,1,0,0,0,211,209,1,0, + 0,0,211,212,1,0,0,0,212,214,1,0,0,0,213,207,1,0,0,0,213,214,1,0,0,0,214, + 56,1,0,0,0,215,221,5,39,0,0,216,220,8,0,0,0,217,218,5,39,0,0,218,220,5, + 39,0,0,219,216,1,0,0,0,219,217,1,0,0,0,220,223,1,0,0,0,221,219,1,0,0,0, + 221,222,1,0,0,0,222,224,1,0,0,0,223,221,1,0,0,0,224,225,5,39,0,0,225,58, + 1,0,0,0,226,227,3,119,59,0,227,228,3,115,57,0,228,229,3,121,60,0,229,230, + 3,89,44,0,230,60,1,0,0,0,231,232,3,91,45,0,232,233,3,81,40,0,233,234,3, + 103,51,0,234,235,3,117,58,0,235,236,3,89,44,0,236,62,1,0,0,0,237,238,3, + 107,53,0,238,239,3,121,60,0,239,240,3,103,51,0,240,241,3,103,51,0,241,64, + 1,0,0,0,242,243,3,87,43,0,243,244,3,81,40,0,244,245,3,119,59,0,245,246, + 3,89,44,0,246,66,1,0,0,0,247,248,3,119,59,0,248,249,3,97,48,0,249,250,3, + 105,52,0,250,251,3,89,44,0,251,68,1,0,0,0,252,253,3,87,43,0,253,254,3,81, + 40,0,254,255,3,119,59,0,255,256,3,89,44,0,256,257,3,119,59,0,257,258,3, + 97,48,0,258,259,3,105,52,0,259,260,3,89,44,0,260,70,1,0,0,0,261,263,7,1, + 0,0,262,261,1,0,0,0,263,264,1,0,0,0,264,262,1,0,0,0,264,265,1,0,0,0,265, + 266,1,0,0,0,266,267,6,35,0,0,267,72,1,0,0,0,268,269,5,47,0,0,269,270,5, + 47,0,0,270,274,1,0,0,0,271,273,8,2,0,0,272,271,1,0,0,0,273,276,1,0,0,0, + 274,272,1,0,0,0,274,275,1,0,0,0,275,277,1,0,0,0,276,274,1,0,0,0,277,278, + 6,36,0,0,278,74,1,0,0,0,279,280,5,47,0,0,280,281,5,42,0,0,281,285,1,0,0, + 0,282,284,9,0,0,0,283,282,1,0,0,0,284,287,1,0,0,0,285,286,1,0,0,0,285,283, + 1,0,0,0,286,288,1,0,0,0,287,285,1,0,0,0,288,289,5,42,0,0,289,290,5,47,0, + 0,290,291,1,0,0,0,291,292,6,37,0,0,292,76,1,0,0,0,293,294,7,3,0,0,294,78, + 1,0,0,0,295,296,7,4,0,0,296,80,1,0,0,0,297,298,7,5,0,0,298,82,1,0,0,0,299, + 300,7,6,0,0,300,84,1,0,0,0,301,302,7,7,0,0,302,86,1,0,0,0,303,304,7,8,0, + 0,304,88,1,0,0,0,305,306,7,9,0,0,306,90,1,0,0,0,307,308,7,10,0,0,308,92, + 1,0,0,0,309,310,7,11,0,0,310,94,1,0,0,0,311,312,7,12,0,0,312,96,1,0,0,0, + 313,314,7,13,0,0,314,98,1,0,0,0,315,316,7,14,0,0,316,100,1,0,0,0,317,318, + 7,15,0,0,318,102,1,0,0,0,319,320,7,16,0,0,320,104,1,0,0,0,321,322,7,17, + 0,0,322,106,1,0,0,0,323,324,7,18,0,0,324,108,1,0,0,0,325,326,7,19,0,0,326, + 110,1,0,0,0,327,328,7,20,0,0,328,112,1,0,0,0,329,330,7,21,0,0,330,114,1, + 0,0,0,331,332,7,22,0,0,332,116,1,0,0,0,333,334,7,23,0,0,334,118,1,0,0,0, + 335,336,7,24,0,0,336,120,1,0,0,0,337,338,7,25,0,0,338,122,1,0,0,0,339,340, + 7,26,0,0,340,124,1,0,0,0,341,342,7,27,0,0,342,126,1,0,0,0,343,344,7,28, + 0,0,344,128,1,0,0,0,345,346,7,29,0,0,346,130,1,0,0,0,347,348,7,30,0,0,348, + 132,1,0,0,0,11,0,197,199,205,211,213,219,221,264,274,285,1,6,0,0]; + + private static __ATN: ATN; public static get _ATN(): ATN { if (!FormulaLexer.__ATN) { - FormulaLexer.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(FormulaLexer._serializedATN)); + FormulaLexer.__ATN = new ATNDeserializer().deserialize(FormulaLexer._serializedATN); } return FormulaLexer.__ATN; } -} + static DecisionsToDFA = FormulaLexer._ATN.decisionToState.map( (ds: DecisionState, index: number) => new DFA(ds, index) ); +} \ No newline at end of file diff --git a/packages/formula/src/grammar/FormulaParser.interp b/packages/formula/src/grammar/FormulaParser.interp index 0c855ac47..5ac83ee1f 100644 --- a/packages/formula/src/grammar/FormulaParser.interp +++ b/packages/formula/src/grammar/FormulaParser.interp @@ -89,4 +89,4 @@ variable atn: -[3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 40, 79, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 33, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 53, 10, 3, 12, 3, 14, 3, 56, 11, 3, 3, 4, 3, 4, 3, 4, 5, 4, 61, 10, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 7, 5, 68, 10, 5, 12, 5, 14, 5, 71, 11, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 2, 2, 3, 4, 7, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 2, 5, 3, 2, 5, 7, 3, 2, 3, 4, 3, 2, 9, 14, 2, 92, 2, 12, 3, 2, 2, 2, 4, 32, 3, 2, 2, 2, 6, 57, 3, 2, 2, 2, 8, 64, 3, 2, 2, 2, 10, 72, 3, 2, 2, 2, 12, 13, 5, 4, 3, 2, 13, 14, 7, 2, 2, 3, 14, 3, 3, 2, 2, 2, 15, 16, 8, 3, 1, 2, 16, 17, 7, 17, 2, 2, 17, 33, 5, 4, 3, 14, 18, 33, 5, 6, 4, 2, 19, 33, 5, 10, 6, 2, 20, 33, 7, 30, 2, 2, 21, 33, 7, 31, 2, 2, 22, 33, 7, 32, 2, 2, 23, 33, 7, 33, 2, 2, 24, 33, 7, 34, 2, 2, 25, 33, 7, 35, 2, 2, 26, 33, 7, 36, 2, 2, 27, 33, 7, 37, 2, 2, 28, 29, 7, 18, 2, 2, 29, 30, 5, 4, 3, 2, 30, 31, 7, 19, 2, 2, 31, 33, 3, 2, 2, 2, 32, 15, 3, 2, 2, 2, 32, 18, 3, 2, 2, 2, 32, 19, 3, 2, 2, 2, 32, 20, 3, 2, 2, 2, 32, 21, 3, 2, 2, 2, 32, 22, 3, 2, 2, 2, 32, 23, 3, 2, 2, 2, 32, 24, 3, 2, 2, 2, 32, 25, 3, 2, 2, 2, 32, 26, 3, 2, 2, 2, 32, 27, 3, 2, 2, 2, 32, 28, 3, 2, 2, 2, 33, 54, 3, 2, 2, 2, 34, 35, 12, 20, 2, 2, 35, 36, 9, 2, 2, 2, 36, 53, 5, 4, 3, 21, 37, 38, 12, 19, 2, 2, 38, 39, 9, 3, 2, 2, 39, 53, 5, 4, 3, 20, 40, 41, 12, 18, 2, 2, 41, 42, 7, 8, 2, 2, 42, 53, 5, 4, 3, 19, 43, 44, 12, 17, 2, 2, 44, 45, 9, 4, 2, 2, 45, 53, 5, 4, 3, 18, 46, 47, 12, 16, 2, 2, 47, 48, 7, 15, 2, 2, 48, 53, 5, 4, 3, 17, 49, 50, 12, 15, 2, 2, 50, 51, 7, 16, 2, 2, 51, 53, 5, 4, 3, 16, 52, 34, 3, 2, 2, 2, 52, 37, 3, 2, 2, 2, 52, 40, 3, 2, 2, 2, 52, 43, 3, 2, 2, 2, 52, 46, 3, 2, 2, 2, 52, 49, 3, 2, 2, 2, 53, 56, 3, 2, 2, 2, 54, 52, 3, 2, 2, 2, 54, 55, 3, 2, 2, 2, 55, 5, 3, 2, 2, 2, 56, 54, 3, 2, 2, 2, 57, 58, 7, 29, 2, 2, 58, 60, 7, 18, 2, 2, 59, 61, 5, 8, 5, 2, 60, 59, 3, 2, 2, 2, 60, 61, 3, 2, 2, 2, 61, 62, 3, 2, 2, 2, 62, 63, 7, 19, 2, 2, 63, 7, 3, 2, 2, 2, 64, 69, 5, 4, 3, 2, 65, 66, 7, 24, 2, 2, 66, 68, 5, 4, 3, 2, 67, 65, 3, 2, 2, 2, 68, 71, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 69, 70, 3, 2, 2, 2, 70, 9, 3, 2, 2, 2, 71, 69, 3, 2, 2, 2, 72, 73, 7, 20, 2, 2, 73, 74, 7, 20, 2, 2, 74, 75, 7, 29, 2, 2, 75, 76, 7, 21, 2, 2, 76, 77, 7, 21, 2, 2, 77, 11, 3, 2, 2, 2, 7, 32, 52, 54, 60, 69] \ No newline at end of file +[4, 1, 38, 77, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 31, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 51, 8, 1, 10, 1, 12, 1, 54, 9, 1, 1, 2, 1, 2, 1, 2, 3, 2, 59, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 5, 3, 66, 8, 3, 10, 3, 12, 3, 69, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 0, 1, 2, 5, 0, 2, 4, 6, 8, 0, 3, 1, 0, 3, 5, 1, 0, 1, 2, 1, 0, 7, 12, 90, 0, 10, 1, 0, 0, 0, 2, 30, 1, 0, 0, 0, 4, 55, 1, 0, 0, 0, 6, 62, 1, 0, 0, 0, 8, 70, 1, 0, 0, 0, 10, 11, 3, 2, 1, 0, 11, 12, 5, 0, 0, 1, 12, 1, 1, 0, 0, 0, 13, 14, 6, 1, -1, 0, 14, 15, 5, 15, 0, 0, 15, 31, 3, 2, 1, 12, 16, 31, 3, 4, 2, 0, 17, 31, 3, 8, 4, 0, 18, 31, 5, 28, 0, 0, 19, 31, 5, 29, 0, 0, 20, 31, 5, 30, 0, 0, 21, 31, 5, 31, 0, 0, 22, 31, 5, 32, 0, 0, 23, 31, 5, 33, 0, 0, 24, 31, 5, 34, 0, 0, 25, 31, 5, 35, 0, 0, 26, 27, 5, 16, 0, 0, 27, 28, 3, 2, 1, 0, 28, 29, 5, 17, 0, 0, 29, 31, 1, 0, 0, 0, 30, 13, 1, 0, 0, 0, 30, 16, 1, 0, 0, 0, 30, 17, 1, 0, 0, 0, 30, 18, 1, 0, 0, 0, 30, 19, 1, 0, 0, 0, 30, 20, 1, 0, 0, 0, 30, 21, 1, 0, 0, 0, 30, 22, 1, 0, 0, 0, 30, 23, 1, 0, 0, 0, 30, 24, 1, 0, 0, 0, 30, 25, 1, 0, 0, 0, 30, 26, 1, 0, 0, 0, 31, 52, 1, 0, 0, 0, 32, 33, 10, 18, 0, 0, 33, 34, 7, 0, 0, 0, 34, 51, 3, 2, 1, 19, 35, 36, 10, 17, 0, 0, 36, 37, 7, 1, 0, 0, 37, 51, 3, 2, 1, 18, 38, 39, 10, 16, 0, 0, 39, 40, 5, 6, 0, 0, 40, 51, 3, 2, 1, 17, 41, 42, 10, 15, 0, 0, 42, 43, 7, 2, 0, 0, 43, 51, 3, 2, 1, 16, 44, 45, 10, 14, 0, 0, 45, 46, 5, 13, 0, 0, 46, 51, 3, 2, 1, 15, 47, 48, 10, 13, 0, 0, 48, 49, 5, 14, 0, 0, 49, 51, 3, 2, 1, 14, 50, 32, 1, 0, 0, 0, 50, 35, 1, 0, 0, 0, 50, 38, 1, 0, 0, 0, 50, 41, 1, 0, 0, 0, 50, 44, 1, 0, 0, 0, 50, 47, 1, 0, 0, 0, 51, 54, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 3, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 55, 56, 5, 27, 0, 0, 56, 58, 5, 16, 0, 0, 57, 59, 3, 6, 3, 0, 58, 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 61, 5, 17, 0, 0, 61, 5, 1, 0, 0, 0, 62, 67, 3, 2, 1, 0, 63, 64, 5, 22, 0, 0, 64, 66, 3, 2, 1, 0, 65, 63, 1, 0, 0, 0, 66, 69, 1, 0, 0, 0, 67, 65, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 7, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 70, 71, 5, 18, 0, 0, 71, 72, 5, 18, 0, 0, 72, 73, 5, 27, 0, 0, 73, 74, 5, 19, 0, 0, 74, 75, 5, 19, 0, 0, 75, 9, 1, 0, 0, 0, 5, 30, 50, 52, 58, 67] \ No newline at end of file diff --git a/packages/formula/src/grammar/FormulaParser.ts b/packages/formula/src/grammar/FormulaParser.ts index 7ce7934a8..497fbcf72 100644 --- a/packages/formula/src/grammar/FormulaParser.ts +++ b/packages/formula/src/grammar/FormulaParser.ts @@ -1,32 +1,23 @@ -// Generated from src/grammar/FormulaParser.g4 by ANTLR 4.9.0-SNAPSHOT +// Generated from src/grammar/FormulaParser.g4 by ANTLR 4.13.2 +// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols +import { + ATN, + ATNDeserializer, DecisionState, DFA, FailedPredicateException, + RecognitionException, NoViableAltException, BailErrorStrategy, + Parser, ParserATNSimulator, + RuleContext, ParserRuleContext, PredictionMode, PredictionContextCache, + TerminalNode, RuleNode, + Token, TokenStream, + Interval, IntervalSet +} from 'antlr4'; +import FormulaParserVisitor from "./FormulaParserVisitor.js"; -import { ATN } from "antlr4ts/atn/ATN"; -import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer"; -import { FailedPredicateException } from "antlr4ts/FailedPredicateException"; -import { NotNull } from "antlr4ts/Decorators"; -import { NoViableAltException } from "antlr4ts/NoViableAltException"; -import { Override } from "antlr4ts/Decorators"; -import { Parser } from "antlr4ts/Parser"; -import { ParserRuleContext } from "antlr4ts/ParserRuleContext"; -import { ParserATNSimulator } from "antlr4ts/atn/ParserATNSimulator"; -import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; -import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; -import { RecognitionException } from "antlr4ts/RecognitionException"; -import { RuleContext } from "antlr4ts/RuleContext"; -//import { RuleVersion } from "antlr4ts/RuleVersion"; -import { TerminalNode } from "antlr4ts/tree/TerminalNode"; -import { Token } from "antlr4ts/Token"; -import { TokenStream } from "antlr4ts/TokenStream"; -import { Vocabulary } from "antlr4ts/Vocabulary"; -import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; +// for running tests with parameters, TODO: discuss strategy for typed parameters in CI +// eslint-disable-next-line no-unused-vars +type int = number; -import * as Utils from "antlr4ts/misc/Utils"; - -import { FormulaParserVisitor } from "./FormulaParserVisitor"; - - -export class FormulaParser extends Parser { +export default class FormulaParser extends Parser { public static readonly ADD = 1; public static readonly SUBTRACT = 2; public static readonly MULTIPLY = 3; @@ -65,46 +56,59 @@ export class FormulaParser extends Parser { public static readonly WS = 36; public static readonly COMMENT = 37; public static readonly MULTILINE_COMMENT = 38; + public static override readonly EOF = Token.EOF; public static readonly RULE_formula = 0; public static readonly RULE_expression = 1; public static readonly RULE_functionCall = 2; public static readonly RULE_argumentList = 3; public static readonly RULE_variable = 4; + public static readonly literalNames: (string | null)[] = [ null, "'+'", + "'-'", "'*'", + "'/'", "'%'", + "'^'", "'='", + "'!='", "'<'", + "'<='", "'>'", + "'>='", null, + null, null, + "'('", "')'", + "'{'", "'}'", + "'['", "']'", + "','", "';'", + "':'", "'.'", + "'_'" ]; + public static readonly symbolicNames: (string | null)[] = [ null, "ADD", + "SUBTRACT", + "MULTIPLY", + "DIVIDE", "MODULO", + "POWER", "EQUAL", + "NOT_EQUAL", + "LESS", "LESS_EQUAL", + "GREATER", + "GREATER_EQUAL", + "AND", "OR", + "NOT", "LPAREN", + "RPAREN", "LBRACE", + "RBRACE", "LBRACKET", + "RBRACKET", + "COMMA", "SEMICOLON", + "COLON", "DOT", + "UNDERSCORE", + "IDENTIFIER", + "NUMBER", "STRING", + "TRUE", "FALSE", + "NULL", "DATE", + "TIME", "DATETIME", + "WS", "COMMENT", + "MULTILINE_COMMENT" ]; // tslint:disable:no-trailing-whitespace public static readonly ruleNames: string[] = [ "formula", "expression", "functionCall", "argumentList", "variable", ]; - - private static readonly _LITERAL_NAMES: Array = [ - undefined, "'+'", "'-'", "'*'", "'/'", "'%'", "'^'", "'='", "'!='", "'<'", - "'<='", "'>'", "'>='", undefined, undefined, undefined, "'('", "')'", - "'{'", "'}'", "'['", "']'", "','", "';'", "':'", "'.'", "'_'", - ]; - private static readonly _SYMBOLIC_NAMES: Array = [ - undefined, "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "MODULO", "POWER", - "EQUAL", "NOT_EQUAL", "LESS", "LESS_EQUAL", "GREATER", "GREATER_EQUAL", - "AND", "OR", "NOT", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACKET", - "RBRACKET", "COMMA", "SEMICOLON", "COLON", "DOT", "UNDERSCORE", "IDENTIFIER", - "NUMBER", "STRING", "TRUE", "FALSE", "NULL", "DATE", "TIME", "DATETIME", - "WS", "COMMENT", "MULTILINE_COMMENT", - ]; - public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(FormulaParser._LITERAL_NAMES, FormulaParser._SYMBOLIC_NAMES, []); - - // @Override - // @NotNull - public get vocabulary(): Vocabulary { - return FormulaParser.VOCABULARY; - } - // tslint:enable:no-trailing-whitespace - - // @Override public get grammarFileName(): string { return "FormulaParser.g4"; } - - // @Override + public get literalNames(): (string | null)[] { return FormulaParser.literalNames; } + public get symbolicNames(): (string | null)[] { return FormulaParser.symbolicNames; } public get ruleNames(): string[] { return FormulaParser.ruleNames; } - - // @Override - public get serializedATN(): string { return FormulaParser._serializedATN; } + public get serializedATN(): number[] { return FormulaParser._serializedATN; } protected createFailedPredicateException(predicate?: string, message?: string): FailedPredicateException { return new FailedPredicateException(this, predicate, message); @@ -112,14 +116,14 @@ export class FormulaParser extends Parser { constructor(input: TokenStream) { super(input); - this._interp = new ParserATNSimulator(FormulaParser._ATN, this); + this._interp = new ParserATNSimulator(this, FormulaParser._ATN, FormulaParser.DecisionsToDFA, new PredictionContextCache()); } // @RuleVersion(0) public formula(): FormulaContext { - let _localctx: FormulaContext = new FormulaContext(this._ctx, this.state); - this.enterRule(_localctx, 0, FormulaParser.RULE_formula); + let localctx: FormulaContext = new FormulaContext(this, this._ctx, this.state); + this.enterRule(localctx, 0, FormulaParser.RULE_formula); try { - this.enterOuterAlt(_localctx, 1); + this.enterOuterAlt(localctx, 1); { this.state = 10; this.expression(0); @@ -129,7 +133,7 @@ export class FormulaParser extends Parser { } catch (re) { if (re instanceof RecognitionException) { - _localctx.exception = re; + localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { @@ -139,7 +143,7 @@ export class FormulaParser extends Parser { finally { this.exitRule(); } - return _localctx; + return localctx; } public expression(): ExpressionContext; @@ -152,23 +156,23 @@ export class FormulaParser extends Parser { let _parentctx: ParserRuleContext = this._ctx; let _parentState: number = this.state; - let _localctx: ExpressionContext = new ExpressionContext(this._ctx, _parentState); - let _prevctx: ExpressionContext = _localctx; + let localctx: ExpressionContext = new ExpressionContext(this, this._ctx, _parentState); + let _prevctx: ExpressionContext = localctx; let _startState: number = 2; - this.enterRecursionRule(_localctx, 2, FormulaParser.RULE_expression, _p); + this.enterRecursionRule(localctx, 2, FormulaParser.RULE_expression, _p); let _la: number; try { let _alt: number; - this.enterOuterAlt(_localctx, 1); + this.enterOuterAlt(localctx, 1); { this.state = 30; this._errHandler.sync(this); switch (this._input.LA(1)) { - case FormulaParser.NOT: + case 15: { - _localctx = new NotExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new NotExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 14; this.match(FormulaParser.NOT); @@ -176,101 +180,101 @@ export class FormulaParser extends Parser { this.expression(12); } break; - case FormulaParser.IDENTIFIER: + case 27: { - _localctx = new FunctionExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new FunctionExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 16; this.functionCall(); } break; - case FormulaParser.LBRACE: + case 18: { - _localctx = new VariableExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new VariableExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 17; this.variable(); } break; - case FormulaParser.NUMBER: + case 28: { - _localctx = new NumberExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new NumberExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 18; this.match(FormulaParser.NUMBER); } break; - case FormulaParser.STRING: + case 29: { - _localctx = new StringExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new StringExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 19; this.match(FormulaParser.STRING); } break; - case FormulaParser.TRUE: + case 30: { - _localctx = new TrueExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new TrueExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 20; this.match(FormulaParser.TRUE); } break; - case FormulaParser.FALSE: + case 31: { - _localctx = new FalseExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new FalseExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 21; this.match(FormulaParser.FALSE); } break; - case FormulaParser.NULL: + case 32: { - _localctx = new NullExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new NullExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 22; this.match(FormulaParser.NULL); } break; - case FormulaParser.DATE: + case 33: { - _localctx = new DateExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new DateExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 23; this.match(FormulaParser.DATE); } break; - case FormulaParser.TIME: + case 34: { - _localctx = new TimeExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new TimeExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 24; this.match(FormulaParser.TIME); } break; - case FormulaParser.DATETIME: + case 35: { - _localctx = new DateTimeExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new DateTimeExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 25; this.match(FormulaParser.DATETIME); } break; - case FormulaParser.LPAREN: + case 16: { - _localctx = new ParenExprContext(_localctx); - this._ctx = _localctx; - _prevctx = _localctx; + localctx = new ParenExprContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; this.state = 26; this.match(FormulaParser.LPAREN); this.state = 27; @@ -282,76 +286,68 @@ export class FormulaParser extends Parser { default: throw new NoViableAltException(this); } - this._ctx._stop = this._input.tryLT(-1); + this._ctx.stop = this._input.LT(-1); this.state = 52; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 2, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { if (this._parseListeners != null) { this.triggerExitRuleEvent(); } - _prevctx = _localctx; + _prevctx = localctx; { this.state = 50; this._errHandler.sync(this); - switch ( this.interpreter.adaptivePredict(this._input, 1, this._ctx) ) { + switch ( this._interp.adaptivePredict(this._input, 1, this._ctx) ) { case 1: { - _localctx = new MulDivModExprContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, FormulaParser.RULE_expression); + localctx = new MulDivModExprContext(this, new ExpressionContext(this, _parentctx, _parentState)); + this.pushNewRecursionContext(localctx, _startState, FormulaParser.RULE_expression); this.state = 32; if (!(this.precpred(this._ctx, 18))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 18)"); } this.state = 33; - (_localctx as MulDivModExprContext)._op = this._input.LT(1); + (localctx as MulDivModExprContext)._op = this._input.LT(1); _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << FormulaParser.MULTIPLY) | (1 << FormulaParser.DIVIDE) | (1 << FormulaParser.MODULO))) !== 0))) { - (_localctx as MulDivModExprContext)._op = this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - + if(!((((_la) & ~0x1F) === 0 && ((1 << _la) & 56) !== 0))) { + (localctx as MulDivModExprContext)._op = this._errHandler.recoverInline(this); + } + else { this._errHandler.reportMatch(this); - this.consume(); + this.consume(); } this.state = 34; this.expression(19); } break; - case 2: { - _localctx = new AddSubExprContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, FormulaParser.RULE_expression); + localctx = new AddSubExprContext(this, new ExpressionContext(this, _parentctx, _parentState)); + this.pushNewRecursionContext(localctx, _startState, FormulaParser.RULE_expression); this.state = 35; if (!(this.precpred(this._ctx, 17))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 17)"); } this.state = 36; - (_localctx as AddSubExprContext)._op = this._input.LT(1); + (localctx as AddSubExprContext)._op = this._input.LT(1); _la = this._input.LA(1); - if (!(_la === FormulaParser.ADD || _la === FormulaParser.SUBTRACT)) { - (_localctx as AddSubExprContext)._op = this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - + if(!(_la===1 || _la===2)) { + (localctx as AddSubExprContext)._op = this._errHandler.recoverInline(this); + } + else { this._errHandler.reportMatch(this); - this.consume(); + this.consume(); } this.state = 37; this.expression(18); } break; - case 3: { - _localctx = new PowerExprContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, FormulaParser.RULE_expression); + localctx = new PowerExprContext(this, new ExpressionContext(this, _parentctx, _parentState)); + this.pushNewRecursionContext(localctx, _startState, FormulaParser.RULE_expression); this.state = 38; if (!(this.precpred(this._ctx, 16))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 16)"); @@ -362,37 +358,32 @@ export class FormulaParser extends Parser { this.expression(17); } break; - case 4: { - _localctx = new ComparisonExprContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, FormulaParser.RULE_expression); + localctx = new ComparisonExprContext(this, new ExpressionContext(this, _parentctx, _parentState)); + this.pushNewRecursionContext(localctx, _startState, FormulaParser.RULE_expression); this.state = 41; if (!(this.precpred(this._ctx, 15))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 15)"); } this.state = 42; - (_localctx as ComparisonExprContext)._op = this._input.LT(1); + (localctx as ComparisonExprContext)._op = this._input.LT(1); _la = this._input.LA(1); - if (!((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << FormulaParser.EQUAL) | (1 << FormulaParser.NOT_EQUAL) | (1 << FormulaParser.LESS) | (1 << FormulaParser.LESS_EQUAL) | (1 << FormulaParser.GREATER) | (1 << FormulaParser.GREATER_EQUAL))) !== 0))) { - (_localctx as ComparisonExprContext)._op = this._errHandler.recoverInline(this); - } else { - if (this._input.LA(1) === Token.EOF) { - this.matchedEOF = true; - } - + if(!((((_la) & ~0x1F) === 0 && ((1 << _la) & 8064) !== 0))) { + (localctx as ComparisonExprContext)._op = this._errHandler.recoverInline(this); + } + else { this._errHandler.reportMatch(this); - this.consume(); + this.consume(); } this.state = 43; this.expression(16); } break; - case 5: { - _localctx = new AndExprContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, FormulaParser.RULE_expression); + localctx = new AndExprContext(this, new ExpressionContext(this, _parentctx, _parentState)); + this.pushNewRecursionContext(localctx, _startState, FormulaParser.RULE_expression); this.state = 44; if (!(this.precpred(this._ctx, 14))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 14)"); @@ -403,11 +394,10 @@ export class FormulaParser extends Parser { this.expression(15); } break; - case 6: { - _localctx = new OrExprContext(new ExpressionContext(_parentctx, _parentState)); - this.pushNewRecursionContext(_localctx, _startState, FormulaParser.RULE_expression); + localctx = new OrExprContext(this, new ExpressionContext(this, _parentctx, _parentState)); + this.pushNewRecursionContext(localctx, _startState, FormulaParser.RULE_expression); this.state = 47; if (!(this.precpred(this._ctx, 13))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 13)"); @@ -423,13 +413,13 @@ export class FormulaParser extends Parser { } this.state = 54; this._errHandler.sync(this); - _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); + _alt = this._interp.adaptivePredict(this._input, 2, this._ctx); } } } catch (re) { if (re instanceof RecognitionException) { - _localctx.exception = re; + localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { @@ -439,15 +429,15 @@ export class FormulaParser extends Parser { finally { this.unrollRecursionContexts(_parentctx); } - return _localctx; + return localctx; } // @RuleVersion(0) public functionCall(): FunctionCallContext { - let _localctx: FunctionCallContext = new FunctionCallContext(this._ctx, this.state); - this.enterRule(_localctx, 4, FormulaParser.RULE_functionCall); + let localctx: FunctionCallContext = new FunctionCallContext(this, this._ctx, this.state); + this.enterRule(localctx, 4, FormulaParser.RULE_functionCall); let _la: number; try { - this.enterOuterAlt(_localctx, 1); + this.enterOuterAlt(localctx, 1); { this.state = 55; this.match(FormulaParser.IDENTIFIER); @@ -456,7 +446,7 @@ export class FormulaParser extends Parser { this.state = 58; this._errHandler.sync(this); _la = this._input.LA(1); - if (((((_la - 15)) & ~0x1F) === 0 && ((1 << (_la - 15)) & ((1 << (FormulaParser.NOT - 15)) | (1 << (FormulaParser.LPAREN - 15)) | (1 << (FormulaParser.LBRACE - 15)) | (1 << (FormulaParser.IDENTIFIER - 15)) | (1 << (FormulaParser.NUMBER - 15)) | (1 << (FormulaParser.STRING - 15)) | (1 << (FormulaParser.TRUE - 15)) | (1 << (FormulaParser.FALSE - 15)) | (1 << (FormulaParser.NULL - 15)) | (1 << (FormulaParser.DATE - 15)) | (1 << (FormulaParser.TIME - 15)) | (1 << (FormulaParser.DATETIME - 15)))) !== 0)) { + if (((((_la - 15)) & ~0x1F) === 0 && ((1 << (_la - 15)) & 2093067) !== 0)) { { this.state = 57; this.argumentList(); @@ -469,7 +459,7 @@ export class FormulaParser extends Parser { } catch (re) { if (re instanceof RecognitionException) { - _localctx.exception = re; + localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { @@ -479,22 +469,22 @@ export class FormulaParser extends Parser { finally { this.exitRule(); } - return _localctx; + return localctx; } // @RuleVersion(0) public argumentList(): ArgumentListContext { - let _localctx: ArgumentListContext = new ArgumentListContext(this._ctx, this.state); - this.enterRule(_localctx, 6, FormulaParser.RULE_argumentList); + let localctx: ArgumentListContext = new ArgumentListContext(this, this._ctx, this.state); + this.enterRule(localctx, 6, FormulaParser.RULE_argumentList); let _la: number; try { - this.enterOuterAlt(_localctx, 1); + this.enterOuterAlt(localctx, 1); { this.state = 62; this.expression(0); this.state = 67; this._errHandler.sync(this); _la = this._input.LA(1); - while (_la === FormulaParser.COMMA) { + while (_la===22) { { { this.state = 63; @@ -511,7 +501,7 @@ export class FormulaParser extends Parser { } catch (re) { if (re instanceof RecognitionException) { - _localctx.exception = re; + localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { @@ -521,14 +511,14 @@ export class FormulaParser extends Parser { finally { this.exitRule(); } - return _localctx; + return localctx; } // @RuleVersion(0) public variable(): VariableContext { - let _localctx: VariableContext = new VariableContext(this._ctx, this.state); - this.enterRule(_localctx, 8, FormulaParser.RULE_variable); + let localctx: VariableContext = new VariableContext(this, this._ctx, this.state); + this.enterRule(localctx, 8, FormulaParser.RULE_variable); try { - this.enterOuterAlt(_localctx, 1); + this.enterOuterAlt(localctx, 1); { this.state = 70; this.match(FormulaParser.LBRACE); @@ -544,7 +534,7 @@ export class FormulaParser extends Parser { } catch (re) { if (re instanceof RecognitionException) { - _localctx.exception = re; + localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { @@ -554,97 +544,88 @@ export class FormulaParser extends Parser { finally { this.exitRule(); } - return _localctx; + return localctx; } - public sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { + public sempred(localctx: RuleContext, ruleIndex: number, predIndex: number): boolean { switch (ruleIndex) { case 1: - return this.expression_sempred(_localctx as ExpressionContext, predIndex); + return this.expression_sempred(localctx as ExpressionContext, predIndex); } return true; } - private expression_sempred(_localctx: ExpressionContext, predIndex: number): boolean { + private expression_sempred(localctx: ExpressionContext, predIndex: number): boolean { switch (predIndex) { case 0: return this.precpred(this._ctx, 18); - case 1: return this.precpred(this._ctx, 17); - case 2: return this.precpred(this._ctx, 16); - case 3: return this.precpred(this._ctx, 15); - case 4: return this.precpred(this._ctx, 14); - case 5: return this.precpred(this._ctx, 13); } return true; } - public static readonly _serializedATN: string = - "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x03(O\x04\x02\t\x02" + - "\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06\x03\x02\x03\x02" + - "\x03\x02\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" + - "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" + - "\x05\x03!\n\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" + - "\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03" + - "\x03\x03\x03\x03\x07\x035\n\x03\f\x03\x0E\x038\v\x03\x03\x04\x03\x04\x03" + - "\x04\x05\x04=\n\x04\x03\x04\x03\x04\x03\x05\x03\x05\x03\x05\x07\x05D\n" + - "\x05\f\x05\x0E\x05G\v\x05\x03\x06\x03\x06\x03\x06\x03\x06\x03\x06\x03" + - "\x06\x03\x06\x02\x02\x03\x04\x07\x02\x02\x04\x02\x06\x02\b\x02\n\x02\x02" + - "\x05\x03\x02\x05\x07\x03\x02\x03\x04\x03\x02\t\x0E\x02\\\x02\f\x03\x02" + - "\x02\x02\x04 \x03\x02\x02\x02\x069\x03\x02\x02\x02\b@\x03\x02\x02\x02" + - "\nH\x03\x02\x02\x02\f\r\x05\x04\x03\x02\r\x0E\x07\x02\x02\x03\x0E\x03" + - "\x03\x02\x02\x02\x0F\x10\b\x03\x01\x02\x10\x11\x07\x11\x02\x02\x11!\x05" + - "\x04\x03\x0E\x12!\x05\x06\x04\x02\x13!\x05\n\x06\x02\x14!\x07\x1E\x02" + - "\x02\x15!\x07\x1F\x02\x02\x16!\x07 \x02\x02\x17!\x07!\x02\x02\x18!\x07" + - "\"\x02\x02\x19!\x07#\x02\x02\x1A!\x07$\x02\x02\x1B!\x07%\x02\x02\x1C\x1D" + - "\x07\x12\x02\x02\x1D\x1E\x05\x04\x03\x02\x1E\x1F\x07\x13\x02\x02\x1F!" + - "\x03\x02\x02\x02 \x0F\x03\x02\x02\x02 \x12\x03\x02\x02\x02 \x13\x03\x02" + - "\x02\x02 \x14\x03\x02\x02\x02 \x15\x03\x02\x02\x02 \x16\x03\x02\x02\x02" + - " \x17\x03\x02\x02\x02 \x18\x03\x02\x02\x02 \x19\x03\x02\x02\x02 \x1A\x03" + - "\x02\x02\x02 \x1B\x03\x02\x02\x02 \x1C\x03\x02\x02\x02!6\x03\x02\x02\x02" + - "\"#\f\x14\x02\x02#$\t\x02\x02\x02$5\x05\x04\x03\x15%&\f\x13\x02\x02&\'" + - "\t\x03\x02\x02\'5\x05\x04\x03\x14()\f\x12\x02\x02)*\x07\b\x02\x02*5\x05" + - "\x04\x03\x13+,\f\x11\x02\x02,-\t\x04\x02\x02-5\x05\x04\x03\x12./\f\x10" + - "\x02\x02/0\x07\x0F\x02\x0205\x05\x04\x03\x1112\f\x0F\x02\x0223\x07\x10" + - "\x02\x0235\x05\x04\x03\x104\"\x03\x02\x02\x024%\x03\x02\x02\x024(\x03" + - "\x02\x02\x024+\x03\x02\x02\x024.\x03\x02\x02\x0241\x03\x02\x02\x0258\x03" + - "\x02\x02\x0264\x03\x02\x02\x0267\x03\x02\x02\x027\x05\x03\x02\x02\x02" + - "86\x03\x02\x02\x029:\x07\x1D\x02\x02:<\x07\x12\x02\x02;=\x05\b\x05\x02" + - "<;\x03\x02\x02\x02<=\x03\x02\x02\x02=>\x03\x02\x02\x02>?\x07\x13\x02\x02" + - "?\x07\x03\x02\x02\x02@E\x05\x04\x03\x02AB\x07\x18\x02\x02BD\x05\x04\x03" + - "\x02CA\x03\x02\x02\x02DG\x03\x02\x02\x02EC\x03\x02\x02\x02EF\x03\x02\x02" + - "\x02F\t\x03\x02\x02\x02GE\x03\x02\x02\x02HI\x07\x14\x02\x02IJ\x07\x14" + - "\x02\x02JK\x07\x1D\x02\x02KL\x07\x15\x02\x02LM\x07\x15\x02\x02M\v\x03" + - "\x02\x02\x02\x07 46 new DFA(ds, index) ); + } export class FormulaContext extends ParserRuleContext { + constructor(parser?: FormulaParser, parent?: ParserRuleContext, invokingState?: number) { + super(parent, invokingState); + this.parser = parser; + } public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } - public EOF(): TerminalNode { return this.getToken(FormulaParser.EOF, 0); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); + public EOF(): TerminalNode { + return this.getToken(FormulaParser.EOF, 0); + } + public get ruleIndex(): number { + return FormulaParser.RULE_formula; } - // @Override - public get ruleIndex(): number { return FormulaParser.RULE_formula; } // @Override public accept(visitor: FormulaParserVisitor): Result { if (visitor.visitFormula) { @@ -657,356 +638,390 @@ export class FormulaContext extends ParserRuleContext { export class ExpressionContext extends ParserRuleContext { - constructor(parent: ParserRuleContext | undefined, invokingState: number) { + constructor(parser?: FormulaParser, parent?: ParserRuleContext, invokingState?: number) { super(parent, invokingState); + this.parser = parser; } - // @Override - public get ruleIndex(): number { return FormulaParser.RULE_expression; } - public copyFrom(ctx: ExpressionContext): void { + public get ruleIndex(): number { + return FormulaParser.RULE_expression; + } + public override copyFrom(ctx: ExpressionContext): void { super.copyFrom(ctx); } } -export class MulDivModExprContext extends ExpressionContext { - public _op!: Token; - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } +export class AndExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - public MULTIPLY(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.MULTIPLY, 0); } - public DIVIDE(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.DIVIDE, 0); } - public MODULO(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.MODULO, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public AND(): TerminalNode { + return this.getToken(FormulaParser.AND, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitMulDivModExpr) { - return visitor.visitMulDivModExpr(this); + if (visitor.visitAndExpr) { + return visitor.visitAndExpr(this); } else { return visitor.visitChildren(this); } } } -export class AddSubExprContext extends ExpressionContext { - public _op!: Token; - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } +export class StringExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public ADD(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.ADD, 0); } - public SUBTRACT(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.SUBTRACT, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public STRING(): TerminalNode { + return this.getToken(FormulaParser.STRING, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitAddSubExpr) { - return visitor.visitAddSubExpr(this); + if (visitor.visitStringExpr) { + return visitor.visitStringExpr(this); } else { return visitor.visitChildren(this); } } } -export class PowerExprContext extends ExpressionContext { - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } +export class FunctionExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public POWER(): TerminalNode { return this.getToken(FormulaParser.POWER, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public functionCall(): FunctionCallContext { + return this.getTypedRuleContext(FunctionCallContext, 0) as FunctionCallContext; } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitPowerExpr) { - return visitor.visitPowerExpr(this); + if (visitor.visitFunctionExpr) { + return visitor.visitFunctionExpr(this); } else { return visitor.visitChildren(this); } } } -export class ComparisonExprContext extends ExpressionContext { - public _op!: Token; - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } +export class TrueExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public EQUAL(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.EQUAL, 0); } - public NOT_EQUAL(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.NOT_EQUAL, 0); } - public LESS(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.LESS, 0); } - public LESS_EQUAL(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.LESS_EQUAL, 0); } - public GREATER(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.GREATER, 0); } - public GREATER_EQUAL(): TerminalNode | undefined { return this.tryGetToken(FormulaParser.GREATER_EQUAL, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public TRUE(): TerminalNode { + return this.getToken(FormulaParser.TRUE, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitComparisonExpr) { - return visitor.visitComparisonExpr(this); + if (visitor.visitTrueExpr) { + return visitor.visitTrueExpr(this); } else { return visitor.visitChildren(this); } } } -export class AndExprContext extends ExpressionContext { - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } +export class TimeExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - public AND(): TerminalNode { return this.getToken(FormulaParser.AND, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public TIME(): TerminalNode { + return this.getToken(FormulaParser.TIME, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitAndExpr) { - return visitor.visitAndExpr(this); + if (visitor.visitTimeExpr) { + return visitor.visitTimeExpr(this); } else { return visitor.visitChildren(this); } } } -export class OrExprContext extends ExpressionContext { - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } +export class ComparisonExprContext extends ExpressionContext { + public _op!: Token; + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + } + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public EQUAL(): TerminalNode { + return this.getToken(FormulaParser.EQUAL, 0); + } + public NOT_EQUAL(): TerminalNode { + return this.getToken(FormulaParser.NOT_EQUAL, 0); + } + public LESS(): TerminalNode { + return this.getToken(FormulaParser.LESS, 0); + } + public LESS_EQUAL(): TerminalNode { + return this.getToken(FormulaParser.LESS_EQUAL, 0); } - public OR(): TerminalNode { return this.getToken(FormulaParser.OR, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public GREATER(): TerminalNode { + return this.getToken(FormulaParser.GREATER, 0); + } + public GREATER_EQUAL(): TerminalNode { + return this.getToken(FormulaParser.GREATER_EQUAL, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitOrExpr) { - return visitor.visitOrExpr(this); + if (visitor.visitComparisonExpr) { + return visitor.visitComparisonExpr(this); } else { return visitor.visitChildren(this); } } } -export class NotExprContext extends ExpressionContext { - public NOT(): TerminalNode { return this.getToken(FormulaParser.NOT, 0); } - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); +export class DateExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public DATE(): TerminalNode { + return this.getToken(FormulaParser.DATE, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitNotExpr) { - return visitor.visitNotExpr(this); + if (visitor.visitDateExpr) { + return visitor.visitDateExpr(this); } else { return visitor.visitChildren(this); } } } -export class FunctionExprContext extends ExpressionContext { - public functionCall(): FunctionCallContext { - return this.getRuleContext(0, FunctionCallContext); +export class OrExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public OR(): TerminalNode { + return this.getToken(FormulaParser.OR, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitFunctionExpr) { - return visitor.visitFunctionExpr(this); + if (visitor.visitOrExpr) { + return visitor.visitOrExpr(this); } else { return visitor.visitChildren(this); } } } -export class VariableExprContext extends ExpressionContext { - public variable(): VariableContext { - return this.getRuleContext(0, VariableContext); +export class FalseExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public FALSE(): TerminalNode { + return this.getToken(FormulaParser.FALSE, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitVariableExpr) { - return visitor.visitVariableExpr(this); + if (visitor.visitFalseExpr) { + return visitor.visitFalseExpr(this); } else { return visitor.visitChildren(this); } } } -export class NumberExprContext extends ExpressionContext { - public NUMBER(): TerminalNode { return this.getToken(FormulaParser.NUMBER, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class NullExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public NULL(): TerminalNode { + return this.getToken(FormulaParser.NULL, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitNumberExpr) { - return visitor.visitNumberExpr(this); + if (visitor.visitNullExpr) { + return visitor.visitNullExpr(this); } else { return visitor.visitChildren(this); } } } -export class StringExprContext extends ExpressionContext { - public STRING(): TerminalNode { return this.getToken(FormulaParser.STRING, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class DateTimeExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public DATETIME(): TerminalNode { + return this.getToken(FormulaParser.DATETIME, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitStringExpr) { - return visitor.visitStringExpr(this); + if (visitor.visitDateTimeExpr) { + return visitor.visitDateTimeExpr(this); } else { return visitor.visitChildren(this); } } } -export class TrueExprContext extends ExpressionContext { - public TRUE(): TerminalNode { return this.getToken(FormulaParser.TRUE, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class PowerExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + } + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public POWER(): TerminalNode { + return this.getToken(FormulaParser.POWER, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitTrueExpr) { - return visitor.visitTrueExpr(this); + if (visitor.visitPowerExpr) { + return visitor.visitPowerExpr(this); } else { return visitor.visitChildren(this); } } } -export class FalseExprContext extends ExpressionContext { - public FALSE(): TerminalNode { return this.getToken(FormulaParser.FALSE, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class NumberExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public NUMBER(): TerminalNode { + return this.getToken(FormulaParser.NUMBER, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitFalseExpr) { - return visitor.visitFalseExpr(this); + if (visitor.visitNumberExpr) { + return visitor.visitNumberExpr(this); } else { return visitor.visitChildren(this); } } } -export class NullExprContext extends ExpressionContext { - public NULL(): TerminalNode { return this.getToken(FormulaParser.NULL, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class MulDivModExprContext extends ExpressionContext { + public _op!: Token; + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + } + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public MULTIPLY(): TerminalNode { + return this.getToken(FormulaParser.MULTIPLY, 0); + } + public DIVIDE(): TerminalNode { + return this.getToken(FormulaParser.DIVIDE, 0); + } + public MODULO(): TerminalNode { + return this.getToken(FormulaParser.MODULO, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitNullExpr) { - return visitor.visitNullExpr(this); + if (visitor.visitMulDivModExpr) { + return visitor.visitMulDivModExpr(this); } else { return visitor.visitChildren(this); } } } -export class DateExprContext extends ExpressionContext { - public DATE(): TerminalNode { return this.getToken(FormulaParser.DATE, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class VariableExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public variable(): VariableContext { + return this.getTypedRuleContext(VariableContext, 0) as VariableContext; } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitDateExpr) { - return visitor.visitDateExpr(this); + if (visitor.visitVariableExpr) { + return visitor.visitVariableExpr(this); } else { return visitor.visitChildren(this); } } } -export class TimeExprContext extends ExpressionContext { - public TIME(): TerminalNode { return this.getToken(FormulaParser.TIME, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class NotExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public NOT(): TerminalNode { + return this.getToken(FormulaParser.NOT, 0); + } + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitTimeExpr) { - return visitor.visitTimeExpr(this); + if (visitor.visitNotExpr) { + return visitor.visitNotExpr(this); } else { return visitor.visitChildren(this); } } } -export class DateTimeExprContext extends ExpressionContext { - public DATETIME(): TerminalNode { return this.getToken(FormulaParser.DATETIME, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); +export class ParenExprContext extends ExpressionContext { + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public LPAREN(): TerminalNode { + return this.getToken(FormulaParser.LPAREN, 0); + } + public expression(): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, 0) as ExpressionContext; + } + public RPAREN(): TerminalNode { + return this.getToken(FormulaParser.RPAREN, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitDateTimeExpr) { - return visitor.visitDateTimeExpr(this); + if (visitor.visitParenExpr) { + return visitor.visitParenExpr(this); } else { return visitor.visitChildren(this); } } } -export class ParenExprContext extends ExpressionContext { - public LPAREN(): TerminalNode { return this.getToken(FormulaParser.LPAREN, 0); } - public expression(): ExpressionContext { - return this.getRuleContext(0, ExpressionContext); +export class AddSubExprContext extends ExpressionContext { + public _op!: Token; + constructor(parser: FormulaParser, ctx: ExpressionContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; + } + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public ADD(): TerminalNode { + return this.getToken(FormulaParser.ADD, 0); } - public RPAREN(): TerminalNode { return this.getToken(FormulaParser.RPAREN, 0); } - constructor(ctx: ExpressionContext) { - super(ctx.parent, ctx.invokingState); - this.copyFrom(ctx); + public SUBTRACT(): TerminalNode { + return this.getToken(FormulaParser.SUBTRACT, 0); } // @Override public accept(visitor: FormulaParserVisitor): Result { - if (visitor.visitParenExpr) { - return visitor.visitParenExpr(this); + if (visitor.visitAddSubExpr) { + return visitor.visitAddSubExpr(this); } else { return visitor.visitChildren(this); } @@ -1015,17 +1030,25 @@ export class ParenExprContext extends ExpressionContext { export class FunctionCallContext extends ParserRuleContext { - public IDENTIFIER(): TerminalNode { return this.getToken(FormulaParser.IDENTIFIER, 0); } - public LPAREN(): TerminalNode { return this.getToken(FormulaParser.LPAREN, 0); } - public RPAREN(): TerminalNode { return this.getToken(FormulaParser.RPAREN, 0); } - public argumentList(): ArgumentListContext | undefined { - return this.tryGetRuleContext(0, ArgumentListContext); - } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { + constructor(parser?: FormulaParser, parent?: ParserRuleContext, invokingState?: number) { super(parent, invokingState); + this.parser = parser; + } + public IDENTIFIER(): TerminalNode { + return this.getToken(FormulaParser.IDENTIFIER, 0); + } + public LPAREN(): TerminalNode { + return this.getToken(FormulaParser.LPAREN, 0); + } + public RPAREN(): TerminalNode { + return this.getToken(FormulaParser.RPAREN, 0); + } + public argumentList(): ArgumentListContext { + return this.getTypedRuleContext(ArgumentListContext, 0) as ArgumentListContext; + } + public get ruleIndex(): number { + return FormulaParser.RULE_functionCall; } - // @Override - public get ruleIndex(): number { return FormulaParser.RULE_functionCall; } // @Override public accept(visitor: FormulaParserVisitor): Result { if (visitor.visitFunctionCall) { @@ -1038,29 +1061,25 @@ export class FunctionCallContext extends ParserRuleContext { export class ArgumentListContext extends ParserRuleContext { - public expression(): ExpressionContext[]; - public expression(i: number): ExpressionContext; - public expression(i?: number): ExpressionContext | ExpressionContext[] { - if (i === undefined) { - return this.getRuleContexts(ExpressionContext); - } else { - return this.getRuleContext(i, ExpressionContext); - } + constructor(parser?: FormulaParser, parent?: ParserRuleContext, invokingState?: number) { + super(parent, invokingState); + this.parser = parser; } - public COMMA(): TerminalNode[]; - public COMMA(i: number): TerminalNode; - public COMMA(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(FormulaParser.COMMA); - } else { - return this.getToken(FormulaParser.COMMA, i); - } + public expression_list(): ExpressionContext[] { + return this.getTypedRuleContexts(ExpressionContext) as ExpressionContext[]; } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); + public expression(i: number): ExpressionContext { + return this.getTypedRuleContext(ExpressionContext, i) as ExpressionContext; + } + public COMMA_list(): TerminalNode[] { + return this.getTokens(FormulaParser.COMMA); + } + public COMMA(i: number): TerminalNode { + return this.getToken(FormulaParser.COMMA, i); + } + public get ruleIndex(): number { + return FormulaParser.RULE_argumentList; } - // @Override - public get ruleIndex(): number { return FormulaParser.RULE_argumentList; } // @Override public accept(visitor: FormulaParserVisitor): Result { if (visitor.visitArgumentList) { @@ -1073,30 +1092,28 @@ export class ArgumentListContext extends ParserRuleContext { export class VariableContext extends ParserRuleContext { - public LBRACE(): TerminalNode[]; - public LBRACE(i: number): TerminalNode; - public LBRACE(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(FormulaParser.LBRACE); - } else { - return this.getToken(FormulaParser.LBRACE, i); - } + constructor(parser?: FormulaParser, parent?: ParserRuleContext, invokingState?: number) { + super(parent, invokingState); + this.parser = parser; } - public IDENTIFIER(): TerminalNode { return this.getToken(FormulaParser.IDENTIFIER, 0); } - public RBRACE(): TerminalNode[]; - public RBRACE(i: number): TerminalNode; - public RBRACE(i?: number): TerminalNode | TerminalNode[] { - if (i === undefined) { - return this.getTokens(FormulaParser.RBRACE); - } else { - return this.getToken(FormulaParser.RBRACE, i); - } + public LBRACE_list(): TerminalNode[] { + return this.getTokens(FormulaParser.LBRACE); } - constructor(parent: ParserRuleContext | undefined, invokingState: number) { - super(parent, invokingState); + public LBRACE(i: number): TerminalNode { + return this.getToken(FormulaParser.LBRACE, i); + } + public IDENTIFIER(): TerminalNode { + return this.getToken(FormulaParser.IDENTIFIER, 0); + } + public RBRACE_list(): TerminalNode[] { + return this.getTokens(FormulaParser.RBRACE); + } + public RBRACE(i: number): TerminalNode { + return this.getToken(FormulaParser.RBRACE, i); + } + public get ruleIndex(): number { + return FormulaParser.RULE_variable; } - // @Override - public get ruleIndex(): number { return FormulaParser.RULE_variable; } // @Override public accept(visitor: FormulaParserVisitor): Result { if (visitor.visitVariable) { @@ -1106,5 +1123,3 @@ export class VariableContext extends ParserRuleContext { } } } - - diff --git a/packages/formula/src/grammar/FormulaParserVisitor.ts b/packages/formula/src/grammar/FormulaParserVisitor.ts index 31cb9c694..232b7227b 100644 --- a/packages/formula/src/grammar/FormulaParserVisitor.ts +++ b/packages/formula/src/grammar/FormulaParserVisitor.ts @@ -1,31 +1,30 @@ -// Generated from src/grammar/FormulaParser.g4 by ANTLR 4.9.0-SNAPSHOT - - -import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; - -import { MulDivModExprContext } from "./FormulaParser"; -import { AddSubExprContext } from "./FormulaParser"; -import { PowerExprContext } from "./FormulaParser"; -import { ComparisonExprContext } from "./FormulaParser"; -import { AndExprContext } from "./FormulaParser"; -import { OrExprContext } from "./FormulaParser"; -import { NotExprContext } from "./FormulaParser"; -import { FunctionExprContext } from "./FormulaParser"; -import { VariableExprContext } from "./FormulaParser"; -import { NumberExprContext } from "./FormulaParser"; -import { StringExprContext } from "./FormulaParser"; -import { TrueExprContext } from "./FormulaParser"; -import { FalseExprContext } from "./FormulaParser"; -import { NullExprContext } from "./FormulaParser"; -import { DateExprContext } from "./FormulaParser"; -import { TimeExprContext } from "./FormulaParser"; -import { DateTimeExprContext } from "./FormulaParser"; -import { ParenExprContext } from "./FormulaParser"; -import { FormulaContext } from "./FormulaParser"; -import { ExpressionContext } from "./FormulaParser"; -import { FunctionCallContext } from "./FormulaParser"; -import { ArgumentListContext } from "./FormulaParser"; -import { VariableContext } from "./FormulaParser"; +// Generated from src/grammar/FormulaParser.g4 by ANTLR 4.13.2 + +import {ParseTreeVisitor} from 'antlr4'; + + +import { FormulaContext } from "./FormulaParser.js"; +import { AndExprContext } from "./FormulaParser.js"; +import { StringExprContext } from "./FormulaParser.js"; +import { FunctionExprContext } from "./FormulaParser.js"; +import { TrueExprContext } from "./FormulaParser.js"; +import { TimeExprContext } from "./FormulaParser.js"; +import { ComparisonExprContext } from "./FormulaParser.js"; +import { DateExprContext } from "./FormulaParser.js"; +import { OrExprContext } from "./FormulaParser.js"; +import { FalseExprContext } from "./FormulaParser.js"; +import { NullExprContext } from "./FormulaParser.js"; +import { DateTimeExprContext } from "./FormulaParser.js"; +import { PowerExprContext } from "./FormulaParser.js"; +import { NumberExprContext } from "./FormulaParser.js"; +import { MulDivModExprContext } from "./FormulaParser.js"; +import { VariableExprContext } from "./FormulaParser.js"; +import { NotExprContext } from "./FormulaParser.js"; +import { ParenExprContext } from "./FormulaParser.js"; +import { AddSubExprContext } from "./FormulaParser.js"; +import { FunctionCallContext } from "./FormulaParser.js"; +import { ArgumentListContext } from "./FormulaParser.js"; +import { VariableContext } from "./FormulaParser.js"; /** @@ -35,143 +34,125 @@ import { VariableContext } from "./FormulaParser"; * @param The return type of the visit operation. Use `void` for * operations with no return type. */ -export interface FormulaParserVisitor extends ParseTreeVisitor { +export default class FormulaParserVisitor extends ParseTreeVisitor { /** - * Visit a parse tree produced by the `MulDivModExpr` - * labeled alternative in `FormulaParser.expression`. + * Visit a parse tree produced by `FormulaParser.formula`. * @param ctx the parse tree * @return the visitor result */ - visitMulDivModExpr?: (ctx: MulDivModExprContext) => Result; - + visitFormula?: (ctx: FormulaContext) => Result; /** - * Visit a parse tree produced by the `AddSubExpr` + * Visit a parse tree produced by the `AndExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitAddSubExpr?: (ctx: AddSubExprContext) => Result; - + visitAndExpr?: (ctx: AndExprContext) => Result; /** - * Visit a parse tree produced by the `PowerExpr` + * Visit a parse tree produced by the `StringExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitPowerExpr?: (ctx: PowerExprContext) => Result; - + visitStringExpr?: (ctx: StringExprContext) => Result; /** - * Visit a parse tree produced by the `ComparisonExpr` + * Visit a parse tree produced by the `FunctionExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitComparisonExpr?: (ctx: ComparisonExprContext) => Result; - + visitFunctionExpr?: (ctx: FunctionExprContext) => Result; /** - * Visit a parse tree produced by the `AndExpr` + * Visit a parse tree produced by the `TrueExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitAndExpr?: (ctx: AndExprContext) => Result; - + visitTrueExpr?: (ctx: TrueExprContext) => Result; /** - * Visit a parse tree produced by the `OrExpr` + * Visit a parse tree produced by the `TimeExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitOrExpr?: (ctx: OrExprContext) => Result; - + visitTimeExpr?: (ctx: TimeExprContext) => Result; /** - * Visit a parse tree produced by the `NotExpr` + * Visit a parse tree produced by the `ComparisonExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitNotExpr?: (ctx: NotExprContext) => Result; - + visitComparisonExpr?: (ctx: ComparisonExprContext) => Result; /** - * Visit a parse tree produced by the `FunctionExpr` + * Visit a parse tree produced by the `DateExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitFunctionExpr?: (ctx: FunctionExprContext) => Result; - + visitDateExpr?: (ctx: DateExprContext) => Result; /** - * Visit a parse tree produced by the `VariableExpr` + * Visit a parse tree produced by the `OrExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitVariableExpr?: (ctx: VariableExprContext) => Result; - + visitOrExpr?: (ctx: OrExprContext) => Result; /** - * Visit a parse tree produced by the `NumberExpr` + * Visit a parse tree produced by the `FalseExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitNumberExpr?: (ctx: NumberExprContext) => Result; - + visitFalseExpr?: (ctx: FalseExprContext) => Result; /** - * Visit a parse tree produced by the `StringExpr` + * Visit a parse tree produced by the `NullExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitStringExpr?: (ctx: StringExprContext) => Result; - + visitNullExpr?: (ctx: NullExprContext) => Result; /** - * Visit a parse tree produced by the `TrueExpr` + * Visit a parse tree produced by the `DateTimeExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitTrueExpr?: (ctx: TrueExprContext) => Result; - + visitDateTimeExpr?: (ctx: DateTimeExprContext) => Result; /** - * Visit a parse tree produced by the `FalseExpr` + * Visit a parse tree produced by the `PowerExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitFalseExpr?: (ctx: FalseExprContext) => Result; - + visitPowerExpr?: (ctx: PowerExprContext) => Result; /** - * Visit a parse tree produced by the `NullExpr` + * Visit a parse tree produced by the `NumberExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitNullExpr?: (ctx: NullExprContext) => Result; - + visitNumberExpr?: (ctx: NumberExprContext) => Result; /** - * Visit a parse tree produced by the `DateExpr` + * Visit a parse tree produced by the `MulDivModExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitDateExpr?: (ctx: DateExprContext) => Result; - + visitMulDivModExpr?: (ctx: MulDivModExprContext) => Result; /** - * Visit a parse tree produced by the `TimeExpr` + * Visit a parse tree produced by the `VariableExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitTimeExpr?: (ctx: TimeExprContext) => Result; - + visitVariableExpr?: (ctx: VariableExprContext) => Result; /** - * Visit a parse tree produced by the `DateTimeExpr` + * Visit a parse tree produced by the `NotExpr` * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitDateTimeExpr?: (ctx: DateTimeExprContext) => Result; - + visitNotExpr?: (ctx: NotExprContext) => Result; /** * Visit a parse tree produced by the `ParenExpr` * labeled alternative in `FormulaParser.expression`. @@ -179,35 +160,25 @@ export interface FormulaParserVisitor extends ParseTreeVisitor { * @return the visitor result */ visitParenExpr?: (ctx: ParenExprContext) => Result; - /** - * Visit a parse tree produced by `FormulaParser.formula`. - * @param ctx the parse tree - * @return the visitor result - */ - visitFormula?: (ctx: FormulaContext) => Result; - - /** - * Visit a parse tree produced by `FormulaParser.expression`. + * Visit a parse tree produced by the `AddSubExpr` + * labeled alternative in `FormulaParser.expression`. * @param ctx the parse tree * @return the visitor result */ - visitExpression?: (ctx: ExpressionContext) => Result; - + visitAddSubExpr?: (ctx: AddSubExprContext) => Result; /** * Visit a parse tree produced by `FormulaParser.functionCall`. * @param ctx the parse tree * @return the visitor result */ visitFunctionCall?: (ctx: FunctionCallContext) => Result; - /** * Visit a parse tree produced by `FormulaParser.argumentList`. * @param ctx the parse tree * @return the visitor result */ visitArgumentList?: (ctx: ArgumentListContext) => Result; - /** * Visit a parse tree produced by `FormulaParser.variable`. * @param ctx the parse tree diff --git a/packages/formula/src/index.ts b/packages/formula/src/index.ts index 4befc2ca9..96bd91161 100644 --- a/packages/formula/src/index.ts +++ b/packages/formula/src/index.ts @@ -1,10 +1,9 @@ -export { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor" -export { type ParseTree } from "antlr4ts/tree/ParseTree" +export * from "antlr4" export * from "./formula.constants" export * from "./formula.visitor" export * from "./formula/formula.type" export * from "./grammar/FormulaLexer" export * from "./grammar/FormulaParser" -export * from "./grammar/FormulaParserVisitor" +export { default as FormulaParserVisitor } from "./grammar/FormulaParserVisitor" export * from "./types" export * from "./util" diff --git a/packages/formula/src/util.ts b/packages/formula/src/util.ts index 6d1c5326a..1c0802d50 100644 --- a/packages/formula/src/util.ts +++ b/packages/formula/src/util.ts @@ -1,10 +1,10 @@ -import { CharStreams, CommonTokenStream } from "antlr4ts" +import { CharStream, CommonTokenStream } from "antlr4" import { FormulaVisitor } from "./formula.visitor" -import { FormulaLexer } from "./grammar/FormulaLexer" -import { FormulaParser } from "./grammar/FormulaParser" +import FormulaLexer from "./grammar/FormulaLexer" +import FormulaParser from "./grammar/FormulaParser" export function createParser(input: string) { - const inputStream = CharStreams.fromString(input) + const inputStream = new CharStream(input) const lexer = new FormulaLexer(inputStream) const tokenStream = new CommonTokenStream(lexer) return new FormulaParser(tokenStream) diff --git a/packages/persistence/src/underlying/underlying-formula.visitor.ts b/packages/persistence/src/underlying/underlying-formula.visitor.ts index e88837483..27184e0ce 100644 --- a/packages/persistence/src/underlying/underlying-formula.visitor.ts +++ b/packages/persistence/src/underlying/underlying-formula.visitor.ts @@ -1,10 +1,10 @@ import { - AbstractParseTreeVisitor, AddSubExprContext, AndExprContext, ArgumentListContext, ComparisonExprContext, FormulaContext, + FormulaParserVisitor, FunctionCallContext, FunctionExprContext, MulDivModExprContext, @@ -16,12 +16,11 @@ import { VariableContext, VariableExprContext, type FormulaFunction, - type FormulaParserVisitor, } from "@undb/formula" import { AUTO_INCREMENT_TYPE, FieldIdVo, ID_TYPE, type TableDo } from "@undb/table" import { match } from "ts-pattern" -export class UnderlyingFormulaVisitor extends AbstractParseTreeVisitor implements FormulaParserVisitor { +export class UnderlyingFormulaVisitor extends FormulaParserVisitor { constructor(private readonly table: TableDo) { super() } @@ -30,40 +29,40 @@ export class UnderlyingFormulaVisitor extends AbstractParseTreeVisitor i return "" } - visitNumberExpr(ctx: NumberExprContext): string { - return ctx.NUMBER().text + visitNumberExpr = (ctx: NumberExprContext): string => { + return ctx.NUMBER().getText() } - visitStringExpr(ctx: StringExprContext): string { - return ctx.STRING().text + visitStringExpr = (ctx: StringExprContext): string => { + return ctx.STRING().getText() } - visitComparisonExpr(ctx: ComparisonExprContext): string { + visitComparisonExpr = (ctx: ComparisonExprContext): string => { return this.visit(ctx.expression(0)) + ctx._op.text + this.visit(ctx.expression(1)) } - visitAndExpr(ctx: AndExprContext): string { + visitAndExpr = (ctx: AndExprContext): string => { return this.visit(ctx.expression(0)) + " AND " + this.visit(ctx.expression(1)) } - visitOrExpr(ctx: OrExprContext): string { + visitOrExpr = (ctx: OrExprContext): string => { return this.visit(ctx.expression(0)) + " OR " + this.visit(ctx.expression(1)) } - visitNotExpr(ctx: NotExprContext): string { + visitNotExpr = (ctx: NotExprContext): string => { return "NOT " + this.visit(ctx.expression()) } - visitAddSubExpr(ctx: AddSubExprContext): string { + visitAddSubExpr = (ctx: AddSubExprContext): string => { return this.visit(ctx.expression(0)) + ctx._op.text + this.visit(ctx.expression(1)) } - visitMulDivModExpr(ctx: MulDivModExprContext): string { + visitMulDivModExpr = (ctx: MulDivModExprContext): string => { return this.visit(ctx.expression(0)) + ctx._op.text + this.visit(ctx.expression(1)) } - visitVariable(ctx: VariableContext): string { - const fieldId = ctx.IDENTIFIER().text + visitVariable = (ctx: VariableContext): string => { + const fieldId = ctx.IDENTIFIER().getText() const field = this.table.schema .getFieldById(new FieldIdVo(fieldId)) .expect(`variable ${fieldId} not found in table ${this.table.name.value}`) @@ -75,31 +74,31 @@ export class UnderlyingFormulaVisitor extends AbstractParseTreeVisitor i return fieldId } - visitFormula(ctx: FormulaContext): string { + visitFormula = (ctx: FormulaContext): string => { const expr = ctx.expression() return this.visit(expr) } - visitFunctionExpr(ctx: FunctionExprContext): string { + visitFunctionExpr = (ctx: FunctionExprContext): string => { return this.visit(ctx.functionCall()) } - visitVariableExpr(ctx: VariableExprContext): string { + visitVariableExpr = (ctx: VariableExprContext): string => { return this.visit(ctx.variable()) } - visitParenExpr(ctx: ParenExprContext): string { + visitParenExpr = (ctx: ParenExprContext): string => { return this.visit(ctx.expression()) } private arguments(ctx: FunctionCallContext): string[] { return ctx .argumentList()! - .expression() + .expression_list() .map((expr) => this.visit(expr)) } - visitFunctionCall(ctx: FunctionCallContext): string { - const functionName = ctx.IDENTIFIER().text as FormulaFunction + visitFunctionCall = (ctx: FunctionCallContext): string => { + const functionName = ctx.IDENTIFIER().getText() as FormulaFunction return match(functionName) .with("ADD", "SUM", () => { const fn = this.arguments(ctx).join(" + ") @@ -182,9 +181,9 @@ export class UnderlyingFormulaVisitor extends AbstractParseTreeVisitor i }) } - visitArgumentList(ctx: ArgumentListContext): string { + visitArgumentList = (ctx: ArgumentListContext): string => { return ctx - .expression() + .expression_list() .map((expr) => this.visit(expr)) .join(", ") } diff --git a/packages/table/src/modules/schema/fields/variants/formula-field/formula-field.visitor.ts b/packages/table/src/modules/schema/fields/variants/formula-field/formula-field.visitor.ts deleted file mode 100644 index 8c2aa0dad..000000000 --- a/packages/table/src/modules/schema/fields/variants/formula-field/formula-field.visitor.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - AbstractParseTreeVisitor, - FormulaContext, - FunctionCallContext, - type FormulaFunction, - type FormulaParserVisitor, -} from "@undb/formula" -import { globalFunctionRegistry } from "@undb/formula/src/formula/registry" -import type { TableDo } from "../../../../../table.do" - -export class FormulaFieldVisitor extends AbstractParseTreeVisitor implements FormulaParserVisitor { - constructor(private readonly table: TableDo) { - super() - } - protected defaultResult(): void { - return undefined - } - - visitFormula(ctx: FormulaContext): void { - this.visit(ctx.expression()) - } - - visitFunctionCall(ctx: FunctionCallContext): void { - const name = ctx.IDENTIFIER().text as FormulaFunction - // const fields = ctx - // .argumentList() - // ?.expression() - // .filter((exp) => exp instanceof VariableExprContext) - // .map((exp) => exp.variable().IDENTIFIER().text) - // .map((fieldId) => this.table.schema.getFieldByIdOrName(fieldId).into(null)) - // .filter((f) => !!f) - - const fn = globalFunctionRegistry.get(name) - if (!fn) { - throw new Error(`Function ${name} not found`) - } - } -}