From 88db36ed412f5b535fed1381e2d8db6ad26490cd Mon Sep 17 00:00:00 2001 From: mgreminger Date: Fri, 25 Oct 2024 15:06:15 -0500 Subject: [PATCH] feat: initial implementation of summation syntax Tests and virtual keyboard button needs to be added. Indexing of matrices within a sum also needs to be fixed. --- public/dimensional_analysis.py | 6 +- src/constants.ts | 1 + src/parser/LatexParser.g4 | 1 + src/parser/LatexParser.ts | 711 ++++++++++++++++--------------- src/parser/LatexParserVisitor.ts | 8 + src/parser/LatexToSympy.ts | 38 ++ 6 files changed, 422 insertions(+), 343 deletions(-) diff --git a/public/dimensional_analysis.py b/public/dimensional_analysis.py index bd2cd7007..162501803 100644 --- a/public/dimensional_analysis.py +++ b/public/dimensional_analysis.py @@ -63,7 +63,8 @@ ceiling, sign, sqrt, - factorial + factorial, + summation ) class ExprWithAssumptions(Expr): @@ -1183,6 +1184,8 @@ def custom_integral_dims(local_expr: Expr, global_expr: Expr, dummy_integral_var else: return global_expr * integral_var # type: ignore +def custom_summation(operand: Expr, dummy_var: Symbol, start: Expr, end: Expr): + return summation(operand, (dummy_var, start, end)) CP = None @@ -1491,6 +1494,7 @@ def get_next_id(self): cast(Function, Function('_Integral')) : {"dim_func": custom_integral_dims, "sympy_func": custom_integral}, cast(Function, Function('_range')) : {"dim_func": custom_range, "sympy_func": custom_range}, cast(Function, Function('_factorial')) : {"dim_func": factorial, "sympy_func": CustomFactorial}, + cast(Function, Function('_summation')) : {"dim_func": custom_summation, "sympy_func": custom_summation}, } global_placeholder_set = set(global_placeholder_map.keys()) diff --git a/src/constants.ts b/src/constants.ts index ed8898fcc..9dbb9d10f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,6 +6,7 @@ export const INLINE_SHORTCUTS = { '~': '\\approx', 'sqrt': '\\sqrt{#?}', '$int': '\\int _{#?}^{#?}\\left(#?\\right)\\mathrm{d}\\left(#?\\right)', + '$sum': '\\sum_{#?=#?}^{#?}\left(#?\\right)', '$prime': '\\frac{\\mathrm{d}}{\\mathrm{d}\\left(#?\\right)}\\left(#?\\right)', '$doubleprime': '\\frac{\\mathrm{d}^{2}}{\\mathrm{d}\\left(#?\\right)^{2}}\\left(#?\\right)', '$tripleprime': '\\frac{\\mathrm{d}^{3}}{\\mathrm{d}\\left(#?\\right)^{3}}\\left(#?\\right)', diff --git a/src/parser/LatexParser.g4 b/src/parser/LatexParser.g4 index 5809ef8e8..da74ba1dd 100644 --- a/src/parser/LatexParser.g4 +++ b/src/parser/LatexParser.g4 @@ -94,6 +94,7 @@ expr: id CARET_SINGLE_CHAR_ID_UNDERSCORE_SUBSCRIPT #exp | integral_cmd #integral | derivative_cmd #derivative | n_derivative_cmd #nDerivative + | summation_cmd #summation | BACKSLASH? CMD_LN L_PAREN expr R_PAREN #ln | BACKSLASH? CMD_LOG L_PAREN expr R_PAREN #log | CMD_SLASH_LOG_UNDERSCORE L_BRACE expr R_BRACE L_PAREN expr R_PAREN #baseLog diff --git a/src/parser/LatexParser.ts b/src/parser/LatexParser.ts index d3b859037..ab48c473a 100644 --- a/src/parser/LatexParser.ts +++ b/src/parser/LatexParser.ts @@ -2240,7 +2240,7 @@ export default class LatexParser extends Parser { let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 603; + this.state = 604; this._errHandler.sync(this); switch ( this._interp.adaptivePredict(this._input, 47, this._ctx) ) { case 1: @@ -2393,82 +2393,91 @@ export default class LatexParser extends Parser { } break; case 12: + { + localctx = new SummationContext(this, localctx); + this._ctx = localctx; + _prevctx = localctx; + this.state = 511; + this.summation_cmd(); + } + break; + case 13: { localctx = new LnContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 512; + this.state = 513; this._errHandler.sync(this); _la = this._input.LA(1); if (_la===29) { { - this.state = 511; + this.state = 512; this.match(LatexParser.BACKSLASH); } } - this.state = 514; - this.match(LatexParser.CMD_LN); this.state = 515; - this.match(LatexParser.L_PAREN); + this.match(LatexParser.CMD_LN); this.state = 516; - this.expr(0); + this.match(LatexParser.L_PAREN); this.state = 517; + this.expr(0); + this.state = 518; this.match(LatexParser.R_PAREN); } break; - case 13: + case 14: { localctx = new LogContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 520; + this.state = 521; this._errHandler.sync(this); _la = this._input.LA(1); if (_la===29) { { - this.state = 519; + this.state = 520; this.match(LatexParser.BACKSLASH); } } - this.state = 522; - this.match(LatexParser.CMD_LOG); this.state = 523; - this.match(LatexParser.L_PAREN); + this.match(LatexParser.CMD_LOG); this.state = 524; - this.expr(0); + this.match(LatexParser.L_PAREN); this.state = 525; + this.expr(0); + this.state = 526; this.match(LatexParser.R_PAREN); } break; - case 14: + case 15: { localctx = new BaseLogContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 527; - this.match(LatexParser.CMD_SLASH_LOG_UNDERSCORE); this.state = 528; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.CMD_SLASH_LOG_UNDERSCORE); this.state = 529; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 530; - this.match(LatexParser.R_BRACE); + this.expr(0); this.state = 531; - this.match(LatexParser.L_PAREN); + this.match(LatexParser.R_BRACE); this.state = 532; - this.expr(0); + this.match(LatexParser.L_PAREN); this.state = 533; + this.expr(0); + this.state = 534; this.match(LatexParser.R_PAREN); } break; - case 15: + case 16: { localctx = new BaseLogSingleCharContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 535; + this.state = 536; _la = this._input.LA(1); if(!(_la===47 || _la===48)) { this._errHandler.recoverInline(this); @@ -2477,242 +2486,242 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 536; - this.match(LatexParser.L_PAREN); this.state = 537; - this.expr(0); + this.match(LatexParser.L_PAREN); this.state = 538; + this.expr(0); + this.state = 539; this.match(LatexParser.R_PAREN); } break; - case 16: + case 17: { localctx = new NormContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 540; - this.match(LatexParser.DOUBLE_VBAR); this.state = 541; - this.expr(0); + this.match(LatexParser.DOUBLE_VBAR); this.state = 542; + this.expr(0); + this.state = 543; this.match(LatexParser.DOUBLE_VBAR); } break; - case 17: + case 18: { localctx = new AbsContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 544; - this.match(LatexParser.VBAR); this.state = 545; - this.expr(0); + this.match(LatexParser.VBAR); this.state = 546; + this.expr(0); + this.state = 547; this.match(LatexParser.VBAR); } break; - case 18: + case 19: { localctx = new NumberWithUnitsExprContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 548; + this.state = 549; this.number_with_units(); } break; - case 19: + case 20: { localctx = new NumberExprContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 549; + this.state = 550; this.number_(); } break; - case 20: + case 21: { localctx = new UnaryMinusContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 550; - this.match(LatexParser.SUB); this.state = 551; + this.match(LatexParser.SUB); + this.state = 552; this.expr(30); } break; - case 21: + case 22: { localctx = new DivideContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 552; - this.match(LatexParser.CMD_FRAC); this.state = 553; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.CMD_FRAC); this.state = 554; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 555; - this.match(LatexParser.R_BRACE); + this.expr(0); this.state = 556; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.R_BRACE); this.state = 557; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 558; + this.expr(0); + this.state = 559; this.match(LatexParser.R_BRACE); } break; - case 22: + case 23: { localctx = new DivideIntsContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 560; + this.state = 561; this.match(LatexParser.CMD_FRAC_INTS); } break; - case 23: + case 24: { localctx = new VariableContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 561; + this.state = 562; this.id(); } break; - case 24: + case 25: { localctx = new UserFunctionContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 562; + this.state = 563; this.user_function(); } break; - case 25: + case 26: { localctx = new BuiltinFunctionContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 563; + this.state = 564; this.builtin_function(); } break; - case 26: + case 27: { localctx = new PiExprContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 564; + this.state = 565; this.match(LatexParser.PI); } break; - case 27: + case 28: { localctx = new SubExprContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 565; - this.match(LatexParser.L_PAREN); this.state = 566; - this.expr(0); + this.match(LatexParser.L_PAREN); this.state = 567; + this.expr(0); + this.state = 568; this.match(LatexParser.R_PAREN); } break; - case 28: + case 29: { localctx = new MissingMultiplicationContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 569; - this.number_(); this.state = 570; + this.number_(); + this.state = 571; this.expr(12); } break; - case 29: + case 30: { localctx = new MissingMultiplicationContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 572; - this.number_with_units(); this.state = 573; + this.number_with_units(); + this.state = 574; this.expr(11); } break; - case 30: + case 31: { localctx = new MissingMultiplicationContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 575; - this.match(LatexParser.PI); this.state = 576; + this.match(LatexParser.PI); + this.state = 577; this.expr(10); } break; - case 31: + case 32: { localctx = new EmptyPlaceholderContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 577; + this.state = 578; this.match(LatexParser.CMD_PLACEHOLDER); - this.state = 580; + this.state = 581; this._errHandler.sync(this); switch ( this._interp.adaptivePredict(this._input, 43, this._ctx) ) { case 1: { - this.state = 578; - this.match(LatexParser.L_BRACE); this.state = 579; + this.match(LatexParser.L_BRACE); + this.state = 580; this.match(LatexParser.R_BRACE); } break; } } break; - case 32: + case 33: { localctx = new RemoveOperatorFontContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 587; + this.state = 588; this._errHandler.sync(this); switch ( this._interp.adaptivePredict(this._input, 44, this._ctx) ) { case 1: { - this.state = 582; - this.match(LatexParser.CMD_MATHRM); this.state = 583; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.CMD_MATHRM); this.state = 584; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 585; + this.expr(0); + this.state = 586; this.match(LatexParser.R_BRACE); } break; } - this.state = 592; + this.state = 593; this._errHandler.sync(this); switch (this._input.LA(1)) { case 62: { - this.state = 589; + this.state = 590; this.match(LatexParser.DECIMAL_POINT); } break; case 54: case 65: { - this.state = 590; + this.state = 591; this.number_(); } break; case 56: { - this.state = 591; + this.state = 592; this.match(LatexParser.EQ); } break; @@ -2721,32 +2730,32 @@ export default class LatexParser extends Parser { default: break; } - this.state = 594; - this.match(LatexParser.CMD_MATHRM); this.state = 595; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.CMD_MATHRM); this.state = 596; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 597; + this.expr(0); + this.state = 598; this.match(LatexParser.R_BRACE); - this.state = 601; + this.state = 602; this._errHandler.sync(this); switch ( this._interp.adaptivePredict(this._input, 46, this._ctx) ) { case 1: { - this.state = 598; + this.state = 599; this.match(LatexParser.DECIMAL_POINT); } break; case 2: { - this.state = 599; + this.state = 600; this.number_(); } break; case 3: { - this.state = 600; + this.state = 601; this.match(LatexParser.EQ); } break; @@ -2755,7 +2764,7 @@ export default class LatexParser extends Parser { break; } this._ctx.stop = this._input.LT(-1); - this.state = 669; + this.state = 670; this._errHandler.sync(this); _alt = this._interp.adaptivePredict(this._input, 49, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { @@ -2765,20 +2774,20 @@ export default class LatexParser extends Parser { } _prevctx = localctx; { - this.state = 667; + this.state = 668; this._errHandler.sync(this); switch ( this._interp.adaptivePredict(this._input, 48, this._ctx) ) { case 1: { localctx = new MatrixMultiplyContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 605; + this.state = 606; if (!(this.precpred(this._ctx, 29))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 29)"); } - this.state = 606; - this.match(LatexParser.CMD_TIMES); this.state = 607; + this.match(LatexParser.CMD_TIMES); + this.state = 608; this.expr(30); } break; @@ -2786,13 +2795,13 @@ export default class LatexParser extends Parser { { localctx = new MultiplyContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 608; + this.state = 609; if (!(this.precpred(this._ctx, 28))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 28)"); } - this.state = 609; - this.match(LatexParser.CMD_CDOT); this.state = 610; + this.match(LatexParser.CMD_CDOT); + this.state = 611; this.expr(29); } break; @@ -2800,13 +2809,13 @@ export default class LatexParser extends Parser { { localctx = new SubtractContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 611; + this.state = 612; if (!(this.precpred(this._ctx, 25))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 25)"); } - this.state = 612; - this.match(LatexParser.SUB); this.state = 613; + this.match(LatexParser.SUB); + this.state = 614; this.expr(26); } break; @@ -2814,13 +2823,13 @@ export default class LatexParser extends Parser { { localctx = new AddContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 614; + this.state = 615; if (!(this.precpred(this._ctx, 24))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 24)"); } - this.state = 615; - this.match(LatexParser.ADD); this.state = 616; + this.match(LatexParser.ADD); + this.state = 617; this.expr(25); } break; @@ -2828,11 +2837,11 @@ export default class LatexParser extends Parser { { localctx = new ExponentContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 617; - if (!(this.precpred(this._ctx, 51))) { - throw this.createFailedPredicateException("this.precpred(this._ctx, 51)"); - } this.state = 618; + if (!(this.precpred(this._ctx, 52))) { + throw this.createFailedPredicateException("this.precpred(this._ctx, 52)"); + } + this.state = 619; _la = this._input.LA(1); if(!(_la===63 || _la===64)) { this._errHandler.recoverInline(this); @@ -2847,17 +2856,17 @@ export default class LatexParser extends Parser { { localctx = new ExponentContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 619; - if (!(this.precpred(this._ctx, 50))) { - throw this.createFailedPredicateException("this.precpred(this._ctx, 50)"); - } this.state = 620; - this.match(LatexParser.CARET); + if (!(this.precpred(this._ctx, 51))) { + throw this.createFailedPredicateException("this.precpred(this._ctx, 51)"); + } this.state = 621; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.CARET); this.state = 622; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 623; + this.expr(0); + this.state = 624; this.match(LatexParser.R_BRACE); } break; @@ -2865,21 +2874,21 @@ export default class LatexParser extends Parser { { localctx = new IndexContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 625; - if (!(this.precpred(this._ctx, 49))) { - throw this.createFailedPredicateException("this.precpred(this._ctx, 49)"); - } this.state = 626; - this.match(LatexParser.UNDERSCORE); + if (!(this.precpred(this._ctx, 50))) { + throw this.createFailedPredicateException("this.precpred(this._ctx, 50)"); + } this.state = 627; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.UNDERSCORE); this.state = 628; - this.expr(0); + this.match(LatexParser.L_BRACE); this.state = 629; - this.match(LatexParser.COMMA); - this.state = 630; this.expr(0); + this.state = 630; + this.match(LatexParser.COMMA); this.state = 631; + this.expr(0); + this.state = 632; this.match(LatexParser.R_BRACE); } break; @@ -2887,11 +2896,11 @@ export default class LatexParser extends Parser { { localctx = new TransposeContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 633; - if (!(this.precpred(this._ctx, 48))) { - throw this.createFailedPredicateException("this.precpred(this._ctx, 48)"); - } this.state = 634; + if (!(this.precpred(this._ctx, 49))) { + throw this.createFailedPredicateException("this.precpred(this._ctx, 49)"); + } + this.state = 635; this.match(LatexParser.TRANSPOSE); } break; @@ -2899,11 +2908,11 @@ export default class LatexParser extends Parser { { localctx = new FactorialContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 635; - if (!(this.precpred(this._ctx, 47))) { - throw this.createFailedPredicateException("this.precpred(this._ctx, 47)"); - } this.state = 636; + if (!(this.precpred(this._ctx, 48))) { + throw this.createFailedPredicateException("this.precpred(this._ctx, 48)"); + } + this.state = 637; this.match(LatexParser.EXCLAMATION); } break; @@ -2911,15 +2920,15 @@ export default class LatexParser extends Parser { { localctx = new EmptySubscriptContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 637; + this.state = 638; if (!(this.precpred(this._ctx, 18))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 18)"); } - this.state = 638; - this.match(LatexParser.UNDERSCORE); this.state = 639; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.UNDERSCORE); this.state = 640; + this.match(LatexParser.L_BRACE); + this.state = 641; this.match(LatexParser.R_BRACE); } break; @@ -2927,15 +2936,15 @@ export default class LatexParser extends Parser { { localctx = new EmptySuperscriptContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 641; + this.state = 642; if (!(this.precpred(this._ctx, 17))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 17)"); } - this.state = 642; - this.match(LatexParser.CARET); this.state = 643; - this.match(LatexParser.L_BRACE); + this.match(LatexParser.CARET); this.state = 644; + this.match(LatexParser.L_BRACE); + this.state = 645; this.match(LatexParser.R_BRACE); } break; @@ -2943,11 +2952,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 645; + this.state = 646; if (!(this.precpred(this._ctx, 16))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 16)"); } - this.state = 646; + this.state = 647; this.id(); } break; @@ -2955,11 +2964,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 647; + this.state = 648; if (!(this.precpred(this._ctx, 15))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 15)"); } - this.state = 648; + this.state = 649; this.number_(); } break; @@ -2967,11 +2976,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 649; + this.state = 650; if (!(this.precpred(this._ctx, 14))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 14)"); } - this.state = 650; + this.state = 651; this.number_with_units(); } break; @@ -2979,11 +2988,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 651; + this.state = 652; if (!(this.precpred(this._ctx, 13))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 13)"); } - this.state = 652; + this.state = 653; this.match(LatexParser.PI); } break; @@ -2991,11 +3000,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 653; + this.state = 654; if (!(this.precpred(this._ctx, 9))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 9)"); } - this.state = 654; + this.state = 655; this.user_function(); } break; @@ -3003,11 +3012,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 655; + this.state = 656; if (!(this.precpred(this._ctx, 8))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 8)"); } - this.state = 656; + this.state = 657; this.builtin_function(); } break; @@ -3015,11 +3024,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 657; + this.state = 658; if (!(this.precpred(this._ctx, 7))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 7)"); } - this.state = 658; + this.state = 659; this.trig_function(); } break; @@ -3027,11 +3036,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 659; + this.state = 660; if (!(this.precpred(this._ctx, 6))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 6)"); } - this.state = 660; + this.state = 661; this.indefinite_integral_cmd(); } break; @@ -3039,11 +3048,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 661; + this.state = 662; if (!(this.precpred(this._ctx, 5))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 5)"); } - this.state = 662; + this.state = 663; this.integral_cmd(); } break; @@ -3051,11 +3060,11 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 663; + this.state = 664; if (!(this.precpred(this._ctx, 4))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 4)"); } - this.state = 664; + this.state = 665; this.derivative_cmd(); } break; @@ -3063,18 +3072,18 @@ export default class LatexParser extends Parser { { localctx = new MissingMultiplicationContext(this, new ExprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_expr); - this.state = 665; + this.state = 666; if (!(this.precpred(this._ctx, 3))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 3)"); } - this.state = 666; + this.state = 667; this.n_derivative_cmd(); } break; } } } - this.state = 671; + this.state = 672; this._errHandler.sync(this); _alt = this._interp.adaptivePredict(this._input, 49, this._ctx); } @@ -3102,7 +3111,7 @@ export default class LatexParser extends Parser { try { this.enterOuterAlt(localctx, 1); { - this.state = 672; + this.state = 673; _la = this._input.LA(1); if(!(_la===1 || _la===2)) { this._errHandler.recoverInline(this); @@ -3111,9 +3120,9 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 673; - this.u_expr(0); this.state = 674; + this.u_expr(0); + this.state = 675; _la = this._input.LA(1); if(!(_la===78 || _la===79)) { this._errHandler.recoverInline(this); @@ -3146,7 +3155,7 @@ export default class LatexParser extends Parser { try { this.enterOuterAlt(localctx, 1); { - this.state = 676; + this.state = 677; _la = this._input.LA(1); if(!(_la===1 || _la===2)) { this._errHandler.recoverInline(this); @@ -3155,7 +3164,7 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 677; + this.state = 678; localctx._numRows = this._input.LT(1); _la = this._input.LA(1); if(!(_la===92 || _la===93)) { @@ -3165,7 +3174,7 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 678; + this.state = 679; _la = this._input.LA(1); if(!(_la===83 || _la===85)) { this._errHandler.recoverInline(this); @@ -3174,7 +3183,7 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 679; + this.state = 680; localctx._numColumns = this._input.LT(1); _la = this._input.LA(1); if(!(_la===92 || _la===93)) { @@ -3184,7 +3193,7 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 680; + this.state = 681; _la = this._input.LA(1); if(!(_la===78 || _la===79)) { this._errHandler.recoverInline(this); @@ -3215,17 +3224,17 @@ export default class LatexParser extends Parser { this.enterRule(localctx, 66, LatexParser.RULE_u_fraction); let _la: number; try { - this.state = 690; + this.state = 691; this._errHandler.sync(this); switch (this._input.LA(1)) { case 80: this.enterOuterAlt(localctx, 1); { - this.state = 682; - this.match(LatexParser.U_CMD_FRAC); this.state = 683; - this.match(LatexParser.U_L_BRACE); + this.match(LatexParser.U_CMD_FRAC); this.state = 684; + this.match(LatexParser.U_L_BRACE); + this.state = 685; _la = this._input.LA(1); if(!(_la===92 || _la===93)) { this._errHandler.recoverInline(this); @@ -3234,20 +3243,20 @@ export default class LatexParser extends Parser { this._errHandler.reportMatch(this); this.consume(); } - this.state = 685; - this.match(LatexParser.U_R_BRACE); this.state = 686; - this.match(LatexParser.U_L_BRACE); + this.match(LatexParser.U_R_BRACE); this.state = 687; - this.match(LatexParser.U_NUMBER); + this.match(LatexParser.U_L_BRACE); this.state = 688; + this.match(LatexParser.U_NUMBER); + this.state = 689; this.match(LatexParser.U_R_BRACE); } break; case 81: this.enterOuterAlt(localctx, 2); { - this.state = 689; + this.state = 690; this.match(LatexParser.U_CMD_FRAC_INTS); } break; @@ -3288,7 +3297,7 @@ export default class LatexParser extends Parser { let _alt: number; this.enterOuterAlt(localctx, 1); { - this.state = 714; + this.state = 715; this._errHandler.sync(this); switch (this._input.LA(1)) { case 84: @@ -3297,13 +3306,13 @@ export default class LatexParser extends Parser { this._ctx = localctx; _prevctx = localctx; - this.state = 693; - this.match(LatexParser.U_CMD_SQRT); this.state = 694; - this.match(LatexParser.U_L_BRACE); + this.match(LatexParser.U_CMD_SQRT); this.state = 695; - this.expr(0); + this.match(LatexParser.U_L_BRACE); this.state = 696; + this.expr(0); + this.state = 697; this.match(LatexParser.U_R_BRACE); } break; @@ -3312,11 +3321,11 @@ export default class LatexParser extends Parser { localctx = new UnitDivideContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 698; - this.match(LatexParser.U_CMD_FRAC); this.state = 699; + this.match(LatexParser.U_CMD_FRAC); + this.state = 700; this.match(LatexParser.U_L_BRACE); - this.state = 702; + this.state = 703; this._errHandler.sync(this); switch (this._input.LA(1)) { case 80: @@ -3324,26 +3333,26 @@ export default class LatexParser extends Parser { case 87: case 88: { - this.state = 700; + this.state = 701; this.u_expr(0); } break; case 92: { - this.state = 701; + this.state = 702; this.match(LatexParser.U_ONE); } break; default: throw new NoViableAltException(this); } - this.state = 704; - this.match(LatexParser.U_R_BRACE); this.state = 705; - this.match(LatexParser.U_L_BRACE); + this.match(LatexParser.U_R_BRACE); this.state = 706; - this.u_expr(0); + this.match(LatexParser.U_L_BRACE); this.state = 707; + this.u_expr(0); + this.state = 708; this.match(LatexParser.U_R_BRACE); } break; @@ -3352,7 +3361,7 @@ export default class LatexParser extends Parser { localctx = new UnitNameContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 709; + this.state = 710; this.match(LatexParser.U_NAME); } break; @@ -3361,11 +3370,11 @@ export default class LatexParser extends Parser { localctx = new UnitSubExprContext(this, localctx); this._ctx = localctx; _prevctx = localctx; - this.state = 710; - this.match(LatexParser.U_L_PAREN); this.state = 711; - this.u_expr(0); + this.match(LatexParser.U_L_PAREN); this.state = 712; + this.u_expr(0); + this.state = 713; this.match(LatexParser.U_R_PAREN); } break; @@ -3373,7 +3382,7 @@ export default class LatexParser extends Parser { throw new NoViableAltException(this); } this._ctx.stop = this._input.LT(-1); - this.state = 738; + this.state = 739; this._errHandler.sync(this); _alt = this._interp.adaptivePredict(this._input, 54, this._ctx); while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) { @@ -3383,20 +3392,20 @@ export default class LatexParser extends Parser { } _prevctx = localctx; { - this.state = 736; + this.state = 737; this._errHandler.sync(this); switch ( this._interp.adaptivePredict(this._input, 53, this._ctx) ) { case 1: { localctx = new UnitMultiplyContext(this, new U_exprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_u_expr); - this.state = 716; + this.state = 717; if (!(this.precpred(this._ctx, 4))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 4)"); } - this.state = 717; - this.match(LatexParser.U_CMD_CDOT); this.state = 718; + this.match(LatexParser.U_CMD_CDOT); + this.state = 719; this.u_expr(5); } break; @@ -3404,13 +3413,13 @@ export default class LatexParser extends Parser { { localctx = new UnitExponentContext(this, new U_exprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_u_expr); - this.state = 719; + this.state = 720; if (!(this.precpred(this._ctx, 9))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 9)"); } - this.state = 720; - this.match(LatexParser.U_CARET); this.state = 721; + this.match(LatexParser.U_CARET); + this.state = 722; this.match(LatexParser.U_NUMBER); } break; @@ -3418,17 +3427,17 @@ export default class LatexParser extends Parser { { localctx = new UnitExponentContext(this, new U_exprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_u_expr); - this.state = 722; + this.state = 723; if (!(this.precpred(this._ctx, 8))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 8)"); } - this.state = 723; - this.match(LatexParser.U_CARET); this.state = 724; - this.match(LatexParser.U_L_BRACE); + this.match(LatexParser.U_CARET); this.state = 725; - this.match(LatexParser.U_NUMBER); + this.match(LatexParser.U_L_BRACE); this.state = 726; + this.match(LatexParser.U_NUMBER); + this.state = 727; this.match(LatexParser.U_R_BRACE); } break; @@ -3436,13 +3445,13 @@ export default class LatexParser extends Parser { { localctx = new UnitFractionalExponentContext(this, new U_exprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_u_expr); - this.state = 727; + this.state = 728; if (!(this.precpred(this._ctx, 7))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 7)"); } - this.state = 728; - this.match(LatexParser.U_CARET); this.state = 729; + this.match(LatexParser.U_CARET); + this.state = 730; this.u_fraction(); } break; @@ -3450,24 +3459,24 @@ export default class LatexParser extends Parser { { localctx = new UnitFractionalExponentContext(this, new U_exprContext(this, _parentctx, _parentState)); this.pushNewRecursionContext(localctx, _startState, LatexParser.RULE_u_expr); - this.state = 730; + this.state = 731; if (!(this.precpred(this._ctx, 6))) { throw this.createFailedPredicateException("this.precpred(this._ctx, 6)"); } - this.state = 731; - this.match(LatexParser.U_CARET); this.state = 732; - this.match(LatexParser.U_L_BRACE); + this.match(LatexParser.U_CARET); this.state = 733; - this.u_fraction(); + this.match(LatexParser.U_L_BRACE); this.state = 734; + this.u_fraction(); + this.state = 735; this.match(LatexParser.U_R_BRACE); } break; } } } - this.state = 740; + this.state = 741; this._errHandler.sync(this); _alt = this._interp.adaptivePredict(this._input, 54, this._ctx); } @@ -3508,15 +3517,15 @@ export default class LatexParser extends Parser { case 3: return this.precpred(this._ctx, 24); case 4: - return this.precpred(this._ctx, 51); + return this.precpred(this._ctx, 52); case 5: - return this.precpred(this._ctx, 50); + return this.precpred(this._ctx, 51); case 6: - return this.precpred(this._ctx, 49); + return this.precpred(this._ctx, 50); case 7: - return this.precpred(this._ctx, 48); + return this.precpred(this._ctx, 49); case 8: - return this.precpred(this._ctx, 47); + return this.precpred(this._ctx, 48); case 9: return this.precpred(this._ctx, 18); case 10: @@ -3562,7 +3571,7 @@ export default class LatexParser extends Parser { return true; } - public static readonly _serializedATN: number[] = [4,1,100,742,2,0,7,0, + public static readonly _serializedATN: number[] = [4,1,100,743,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, @@ -3599,43 +3608,43 @@ export default class LatexParser extends Parser { 1,29,1,29,1,29,5,29,468,8,29,10,29,12,29,471,9,29,1,29,1,29,1,30,1,30,1, 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30, 1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,5,30,500,8,30,10,30,12,30,503,9, - 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,3,30,513,8,30,1,30,1,30,1,30, - 1,30,1,30,1,30,3,30,521,8,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, + 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,3,30,514,8,30,1,30,1,30, + 1,30,1,30,1,30,1,30,3,30,522,8,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30, 1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30, - 1,30,1,30,1,30,1,30,1,30,1,30,3,30,581,8,30,1,30,1,30,1,30,1,30,1,30,3, - 30,588,8,30,1,30,1,30,1,30,3,30,593,8,30,1,30,1,30,1,30,1,30,1,30,1,30, - 1,30,3,30,602,8,30,3,30,604,8,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30, + 1,30,1,30,1,30,1,30,1,30,1,30,1,30,3,30,582,8,30,1,30,1,30,1,30,1,30,1, + 30,3,30,589,8,30,1,30,1,30,1,30,3,30,594,8,30,1,30,1,30,1,30,1,30,1,30, + 1,30,1,30,3,30,603,8,30,3,30,605,8,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30, 1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30, 1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, - 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,5,30,668,8,30,10,30, - 12,30,671,9,30,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32,1,33,1, - 33,1,33,1,33,1,33,1,33,1,33,1,33,3,33,691,8,33,1,34,1,34,1,34,1,34,1,34, - 1,34,1,34,1,34,1,34,1,34,3,34,703,8,34,1,34,1,34,1,34,1,34,1,34,1,34,1, - 34,1,34,1,34,1,34,3,34,715,8,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34, - 1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,5,34,737,8, - 34,10,34,12,34,740,9,34,1,34,2,151,158,2,60,68,35,0,2,4,6,8,10,12,14,16, - 18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64, - 66,68,0,11,1,0,31,43,1,0,15,16,1,0,63,64,2,0,57,57,59,59,1,0,25,26,1,0, - 57,60,1,0,47,48,1,0,1,2,1,0,78,79,1,0,92,93,2,0,83,83,85,85,839,0,87,1, - 0,0,0,2,101,1,0,0,0,4,119,1,0,0,0,6,151,1,0,0,0,8,165,1,0,0,0,10,168,1, - 0,0,0,12,175,1,0,0,0,14,181,1,0,0,0,16,186,1,0,0,0,18,193,1,0,0,0,20,198, - 1,0,0,0,22,203,1,0,0,0,24,209,1,0,0,0,26,224,1,0,0,0,28,231,1,0,0,0,30, - 245,1,0,0,0,32,268,1,0,0,0,34,293,1,0,0,0,36,312,1,0,0,0,38,340,1,0,0,0, - 40,394,1,0,0,0,42,398,1,0,0,0,44,400,1,0,0,0,46,407,1,0,0,0,48,413,1,0, - 0,0,50,420,1,0,0,0,52,424,1,0,0,0,54,430,1,0,0,0,56,438,1,0,0,0,58,461, - 1,0,0,0,60,603,1,0,0,0,62,672,1,0,0,0,64,676,1,0,0,0,66,690,1,0,0,0,68, - 714,1,0,0,0,70,88,3,14,7,0,71,88,3,16,8,0,72,88,3,18,9,0,73,88,3,20,10, - 0,74,88,3,22,11,0,75,88,3,62,31,0,76,88,3,10,5,0,77,88,3,8,4,0,78,88,3, - 44,22,0,79,88,3,46,23,0,80,88,3,48,24,0,81,88,3,60,30,0,82,88,3,42,21,0, - 83,88,3,24,12,0,84,88,3,6,3,0,85,88,3,2,1,0,86,88,3,4,2,0,87,70,1,0,0,0, - 87,71,1,0,0,0,87,72,1,0,0,0,87,73,1,0,0,0,87,74,1,0,0,0,87,75,1,0,0,0,87, - 76,1,0,0,0,87,77,1,0,0,0,87,78,1,0,0,0,87,79,1,0,0,0,87,80,1,0,0,0,87,81, - 1,0,0,0,87,82,1,0,0,0,87,83,1,0,0,0,87,84,1,0,0,0,87,85,1,0,0,0,87,86,1, - 0,0,0,87,88,1,0,0,0,88,89,1,0,0,0,89,90,5,0,0,1,90,1,1,0,0,0,91,92,5,6, - 0,0,92,93,3,60,30,0,93,94,5,61,0,0,94,95,3,60,30,0,95,96,5,7,0,0,96,102, + 30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,5,30,669,8,30, + 10,30,12,30,672,9,30,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,32, + 1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,3,33,692,8,33,1,34,1,34,1,34,1, + 34,1,34,1,34,1,34,1,34,1,34,1,34,3,34,704,8,34,1,34,1,34,1,34,1,34,1,34, + 1,34,1,34,1,34,1,34,1,34,3,34,716,8,34,1,34,1,34,1,34,1,34,1,34,1,34,1, + 34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,5,34, + 738,8,34,10,34,12,34,741,9,34,1,34,2,151,158,2,60,68,35,0,2,4,6,8,10,12, + 14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60, + 62,64,66,68,0,11,1,0,31,43,1,0,15,16,1,0,63,64,2,0,57,57,59,59,1,0,25,26, + 1,0,57,60,1,0,47,48,1,0,1,2,1,0,78,79,1,0,92,93,2,0,83,83,85,85,841,0,87, + 1,0,0,0,2,101,1,0,0,0,4,119,1,0,0,0,6,151,1,0,0,0,8,165,1,0,0,0,10,168, + 1,0,0,0,12,175,1,0,0,0,14,181,1,0,0,0,16,186,1,0,0,0,18,193,1,0,0,0,20, + 198,1,0,0,0,22,203,1,0,0,0,24,209,1,0,0,0,26,224,1,0,0,0,28,231,1,0,0,0, + 30,245,1,0,0,0,32,268,1,0,0,0,34,293,1,0,0,0,36,312,1,0,0,0,38,340,1,0, + 0,0,40,394,1,0,0,0,42,398,1,0,0,0,44,400,1,0,0,0,46,407,1,0,0,0,48,413, + 1,0,0,0,50,420,1,0,0,0,52,424,1,0,0,0,54,430,1,0,0,0,56,438,1,0,0,0,58, + 461,1,0,0,0,60,604,1,0,0,0,62,673,1,0,0,0,64,677,1,0,0,0,66,691,1,0,0,0, + 68,715,1,0,0,0,70,88,3,14,7,0,71,88,3,16,8,0,72,88,3,18,9,0,73,88,3,20, + 10,0,74,88,3,22,11,0,75,88,3,62,31,0,76,88,3,10,5,0,77,88,3,8,4,0,78,88, + 3,44,22,0,79,88,3,46,23,0,80,88,3,48,24,0,81,88,3,60,30,0,82,88,3,42,21, + 0,83,88,3,24,12,0,84,88,3,6,3,0,85,88,3,2,1,0,86,88,3,4,2,0,87,70,1,0,0, + 0,87,71,1,0,0,0,87,72,1,0,0,0,87,73,1,0,0,0,87,74,1,0,0,0,87,75,1,0,0,0, + 87,76,1,0,0,0,87,77,1,0,0,0,87,78,1,0,0,0,87,79,1,0,0,0,87,80,1,0,0,0,87, + 81,1,0,0,0,87,82,1,0,0,0,87,83,1,0,0,0,87,84,1,0,0,0,87,85,1,0,0,0,87,86, + 1,0,0,0,87,88,1,0,0,0,88,89,1,0,0,0,89,90,5,0,0,1,90,1,1,0,0,0,91,92,5, + 6,0,0,92,93,3,60,30,0,93,94,5,61,0,0,94,95,3,60,30,0,95,96,5,7,0,0,96,102, 1,0,0,0,97,98,3,60,30,0,98,99,5,61,0,0,99,100,3,60,30,0,100,102,1,0,0,0, 101,91,1,0,0,0,101,97,1,0,0,0,102,104,1,0,0,0,103,105,5,30,0,0,104,103, 1,0,0,0,104,105,1,0,0,0,105,106,1,0,0,0,106,117,5,56,0,0,107,108,5,6,0, @@ -3731,88 +3740,89 @@ export default class LatexParser extends Parser { 462,463,1,0,0,0,463,464,5,6,0,0,464,469,3,60,30,0,465,466,5,61,0,0,466, 468,3,60,30,0,467,465,1,0,0,0,468,471,1,0,0,0,469,467,1,0,0,0,469,470,1, 0,0,0,470,472,1,0,0,0,471,469,1,0,0,0,472,473,5,7,0,0,473,59,1,0,0,0,474, - 475,6,30,-1,0,475,476,3,8,4,0,476,477,5,71,0,0,477,604,1,0,0,0,478,479, - 3,8,4,0,479,480,7,2,0,0,480,481,5,70,0,0,481,604,1,0,0,0,482,483,3,8,4, + 475,6,30,-1,0,475,476,3,8,4,0,476,477,5,71,0,0,477,605,1,0,0,0,478,479, + 3,8,4,0,479,480,7,2,0,0,480,481,5,70,0,0,481,605,1,0,0,0,482,483,3,8,4, 0,483,484,5,55,0,0,484,485,5,4,0,0,485,486,3,60,30,0,486,487,5,5,0,0,487, - 488,5,70,0,0,488,604,1,0,0,0,489,604,5,24,0,0,490,491,5,23,0,0,491,492, - 5,4,0,0,492,493,3,60,30,0,493,494,5,5,0,0,494,604,1,0,0,0,495,496,5,66, + 488,5,70,0,0,488,605,1,0,0,0,489,605,5,24,0,0,490,491,5,23,0,0,491,492, + 5,4,0,0,492,493,3,60,30,0,493,494,5,5,0,0,494,605,1,0,0,0,495,496,5,66, 0,0,496,501,3,54,27,0,497,498,5,69,0,0,498,500,3,54,27,0,499,497,1,0,0, 0,500,503,1,0,0,0,501,499,1,0,0,0,501,502,1,0,0,0,502,504,1,0,0,0,503,501, - 1,0,0,0,504,505,5,67,0,0,505,604,1,0,0,0,506,604,3,28,14,0,507,604,3,30, - 15,0,508,604,3,32,16,0,509,604,3,36,18,0,510,604,3,38,19,0,511,513,5,29, - 0,0,512,511,1,0,0,0,512,513,1,0,0,0,513,514,1,0,0,0,514,515,5,44,0,0,515, - 516,5,6,0,0,516,517,3,60,30,0,517,518,5,7,0,0,518,604,1,0,0,0,519,521,5, - 29,0,0,520,519,1,0,0,0,520,521,1,0,0,0,521,522,1,0,0,0,522,523,5,45,0,0, - 523,524,5,6,0,0,524,525,3,60,30,0,525,526,5,7,0,0,526,604,1,0,0,0,527,528, - 5,46,0,0,528,529,5,4,0,0,529,530,3,60,30,0,530,531,5,5,0,0,531,532,5,6, - 0,0,532,533,3,60,30,0,533,534,5,7,0,0,534,604,1,0,0,0,535,536,7,6,0,0,536, - 537,5,6,0,0,537,538,3,60,30,0,538,539,5,7,0,0,539,604,1,0,0,0,540,541,5, - 9,0,0,541,542,3,60,30,0,542,543,5,9,0,0,543,604,1,0,0,0,544,545,5,8,0,0, - 545,546,3,60,30,0,546,547,5,8,0,0,547,604,1,0,0,0,548,604,3,12,6,0,549, - 604,3,10,5,0,550,551,5,54,0,0,551,604,3,60,30,30,552,553,5,19,0,0,553,554, - 5,4,0,0,554,555,3,60,30,0,555,556,5,5,0,0,556,557,5,4,0,0,557,558,3,60, - 30,0,558,559,5,5,0,0,559,604,1,0,0,0,560,604,5,20,0,0,561,604,3,8,4,0,562, - 604,3,56,28,0,563,604,3,58,29,0,564,604,5,12,0,0,565,566,5,6,0,0,566,567, - 3,60,30,0,567,568,5,7,0,0,568,604,1,0,0,0,569,570,3,10,5,0,570,571,3,60, - 30,12,571,604,1,0,0,0,572,573,3,12,6,0,573,574,3,60,30,11,574,604,1,0,0, - 0,575,576,5,12,0,0,576,604,3,60,30,10,577,580,5,27,0,0,578,579,5,4,0,0, - 579,581,5,5,0,0,580,578,1,0,0,0,580,581,1,0,0,0,581,604,1,0,0,0,582,583, - 5,18,0,0,583,584,5,4,0,0,584,585,3,60,30,0,585,586,5,5,0,0,586,588,1,0, - 0,0,587,582,1,0,0,0,587,588,1,0,0,0,588,592,1,0,0,0,589,593,5,62,0,0,590, - 593,3,10,5,0,591,593,5,56,0,0,592,589,1,0,0,0,592,590,1,0,0,0,592,591,1, - 0,0,0,592,593,1,0,0,0,593,594,1,0,0,0,594,595,5,18,0,0,595,596,5,4,0,0, - 596,597,3,60,30,0,597,601,5,5,0,0,598,602,5,62,0,0,599,602,3,10,5,0,600, - 602,5,56,0,0,601,598,1,0,0,0,601,599,1,0,0,0,601,600,1,0,0,0,601,602,1, - 0,0,0,602,604,1,0,0,0,603,474,1,0,0,0,603,478,1,0,0,0,603,482,1,0,0,0,603, - 489,1,0,0,0,603,490,1,0,0,0,603,495,1,0,0,0,603,506,1,0,0,0,603,507,1,0, - 0,0,603,508,1,0,0,0,603,509,1,0,0,0,603,510,1,0,0,0,603,512,1,0,0,0,603, - 520,1,0,0,0,603,527,1,0,0,0,603,535,1,0,0,0,603,540,1,0,0,0,603,544,1,0, - 0,0,603,548,1,0,0,0,603,549,1,0,0,0,603,550,1,0,0,0,603,552,1,0,0,0,603, - 560,1,0,0,0,603,561,1,0,0,0,603,562,1,0,0,0,603,563,1,0,0,0,603,564,1,0, - 0,0,603,565,1,0,0,0,603,569,1,0,0,0,603,572,1,0,0,0,603,575,1,0,0,0,603, - 577,1,0,0,0,603,587,1,0,0,0,604,669,1,0,0,0,605,606,10,29,0,0,606,607,5, - 22,0,0,607,668,3,60,30,30,608,609,10,28,0,0,609,610,5,21,0,0,610,668,3, - 60,30,29,611,612,10,25,0,0,612,613,5,54,0,0,613,668,3,60,30,26,614,615, - 10,24,0,0,615,616,5,53,0,0,616,668,3,60,30,25,617,618,10,51,0,0,618,668, - 7,2,0,0,619,620,10,50,0,0,620,621,5,55,0,0,621,622,5,4,0,0,622,623,3,60, - 30,0,623,624,5,5,0,0,624,668,1,0,0,0,625,626,10,49,0,0,626,627,5,10,0,0, - 627,628,5,4,0,0,628,629,3,60,30,0,629,630,5,61,0,0,630,631,3,60,30,0,631, - 632,5,5,0,0,632,668,1,0,0,0,633,634,10,48,0,0,634,668,5,28,0,0,635,636, - 10,47,0,0,636,668,5,11,0,0,637,638,10,18,0,0,638,639,5,10,0,0,639,640,5, - 4,0,0,640,668,5,5,0,0,641,642,10,17,0,0,642,643,5,55,0,0,643,644,5,4,0, - 0,644,668,5,5,0,0,645,646,10,16,0,0,646,668,3,8,4,0,647,648,10,15,0,0,648, - 668,3,10,5,0,649,650,10,14,0,0,650,668,3,12,6,0,651,652,10,13,0,0,652,668, - 5,12,0,0,653,654,10,9,0,0,654,668,3,56,28,0,655,656,10,8,0,0,656,668,3, - 58,29,0,657,658,10,7,0,0,658,668,3,28,14,0,659,660,10,6,0,0,660,668,3,30, - 15,0,661,662,10,5,0,0,662,668,3,32,16,0,663,664,10,4,0,0,664,668,3,36,18, - 0,665,666,10,3,0,0,666,668,3,38,19,0,667,605,1,0,0,0,667,608,1,0,0,0,667, - 611,1,0,0,0,667,614,1,0,0,0,667,617,1,0,0,0,667,619,1,0,0,0,667,625,1,0, - 0,0,667,633,1,0,0,0,667,635,1,0,0,0,667,637,1,0,0,0,667,641,1,0,0,0,667, - 645,1,0,0,0,667,647,1,0,0,0,667,649,1,0,0,0,667,651,1,0,0,0,667,653,1,0, - 0,0,667,655,1,0,0,0,667,657,1,0,0,0,667,659,1,0,0,0,667,661,1,0,0,0,667, - 663,1,0,0,0,667,665,1,0,0,0,668,671,1,0,0,0,669,667,1,0,0,0,669,670,1,0, - 0,0,670,61,1,0,0,0,671,669,1,0,0,0,672,673,7,7,0,0,673,674,3,68,34,0,674, - 675,7,8,0,0,675,63,1,0,0,0,676,677,7,7,0,0,677,678,7,9,0,0,678,679,7,10, - 0,0,679,680,7,9,0,0,680,681,7,8,0,0,681,65,1,0,0,0,682,683,5,80,0,0,683, - 684,5,90,0,0,684,685,7,9,0,0,685,686,5,91,0,0,686,687,5,90,0,0,687,688, - 5,93,0,0,688,691,5,91,0,0,689,691,5,81,0,0,690,682,1,0,0,0,690,689,1,0, - 0,0,691,67,1,0,0,0,692,693,6,34,-1,0,693,694,5,84,0,0,694,695,5,90,0,0, - 695,696,3,60,30,0,696,697,5,91,0,0,697,715,1,0,0,0,698,699,5,80,0,0,699, - 702,5,90,0,0,700,703,3,68,34,0,701,703,5,92,0,0,702,700,1,0,0,0,702,701, - 1,0,0,0,703,704,1,0,0,0,704,705,5,91,0,0,705,706,5,90,0,0,706,707,3,68, - 34,0,707,708,5,91,0,0,708,715,1,0,0,0,709,715,5,87,0,0,710,711,5,88,0,0, - 711,712,3,68,34,0,712,713,5,89,0,0,713,715,1,0,0,0,714,692,1,0,0,0,714, - 698,1,0,0,0,714,709,1,0,0,0,714,710,1,0,0,0,715,738,1,0,0,0,716,717,10, - 4,0,0,717,718,5,82,0,0,718,737,3,68,34,5,719,720,10,9,0,0,720,721,5,86, - 0,0,721,737,5,93,0,0,722,723,10,8,0,0,723,724,5,86,0,0,724,725,5,90,0,0, - 725,726,5,93,0,0,726,737,5,91,0,0,727,728,10,7,0,0,728,729,5,86,0,0,729, - 737,3,66,33,0,730,731,10,6,0,0,731,732,5,86,0,0,732,733,5,90,0,0,733,734, - 3,66,33,0,734,735,5,91,0,0,735,737,1,0,0,0,736,716,1,0,0,0,736,719,1,0, - 0,0,736,722,1,0,0,0,736,727,1,0,0,0,736,730,1,0,0,0,737,740,1,0,0,0,738, - 736,1,0,0,0,738,739,1,0,0,0,739,69,1,0,0,0,740,738,1,0,0,0,55,87,101,104, - 117,133,146,151,158,163,168,175,181,191,196,201,209,219,231,245,256,268, - 276,287,306,320,330,348,356,366,377,394,398,405,411,418,435,445,453,461, - 469,501,512,520,580,587,592,601,603,667,669,690,702,714,736,738]; + 1,0,0,0,504,505,5,67,0,0,505,605,1,0,0,0,506,605,3,28,14,0,507,605,3,30, + 15,0,508,605,3,32,16,0,509,605,3,36,18,0,510,605,3,38,19,0,511,605,3,34, + 17,0,512,514,5,29,0,0,513,512,1,0,0,0,513,514,1,0,0,0,514,515,1,0,0,0,515, + 516,5,44,0,0,516,517,5,6,0,0,517,518,3,60,30,0,518,519,5,7,0,0,519,605, + 1,0,0,0,520,522,5,29,0,0,521,520,1,0,0,0,521,522,1,0,0,0,522,523,1,0,0, + 0,523,524,5,45,0,0,524,525,5,6,0,0,525,526,3,60,30,0,526,527,5,7,0,0,527, + 605,1,0,0,0,528,529,5,46,0,0,529,530,5,4,0,0,530,531,3,60,30,0,531,532, + 5,5,0,0,532,533,5,6,0,0,533,534,3,60,30,0,534,535,5,7,0,0,535,605,1,0,0, + 0,536,537,7,6,0,0,537,538,5,6,0,0,538,539,3,60,30,0,539,540,5,7,0,0,540, + 605,1,0,0,0,541,542,5,9,0,0,542,543,3,60,30,0,543,544,5,9,0,0,544,605,1, + 0,0,0,545,546,5,8,0,0,546,547,3,60,30,0,547,548,5,8,0,0,548,605,1,0,0,0, + 549,605,3,12,6,0,550,605,3,10,5,0,551,552,5,54,0,0,552,605,3,60,30,30,553, + 554,5,19,0,0,554,555,5,4,0,0,555,556,3,60,30,0,556,557,5,5,0,0,557,558, + 5,4,0,0,558,559,3,60,30,0,559,560,5,5,0,0,560,605,1,0,0,0,561,605,5,20, + 0,0,562,605,3,8,4,0,563,605,3,56,28,0,564,605,3,58,29,0,565,605,5,12,0, + 0,566,567,5,6,0,0,567,568,3,60,30,0,568,569,5,7,0,0,569,605,1,0,0,0,570, + 571,3,10,5,0,571,572,3,60,30,12,572,605,1,0,0,0,573,574,3,12,6,0,574,575, + 3,60,30,11,575,605,1,0,0,0,576,577,5,12,0,0,577,605,3,60,30,10,578,581, + 5,27,0,0,579,580,5,4,0,0,580,582,5,5,0,0,581,579,1,0,0,0,581,582,1,0,0, + 0,582,605,1,0,0,0,583,584,5,18,0,0,584,585,5,4,0,0,585,586,3,60,30,0,586, + 587,5,5,0,0,587,589,1,0,0,0,588,583,1,0,0,0,588,589,1,0,0,0,589,593,1,0, + 0,0,590,594,5,62,0,0,591,594,3,10,5,0,592,594,5,56,0,0,593,590,1,0,0,0, + 593,591,1,0,0,0,593,592,1,0,0,0,593,594,1,0,0,0,594,595,1,0,0,0,595,596, + 5,18,0,0,596,597,5,4,0,0,597,598,3,60,30,0,598,602,5,5,0,0,599,603,5,62, + 0,0,600,603,3,10,5,0,601,603,5,56,0,0,602,599,1,0,0,0,602,600,1,0,0,0,602, + 601,1,0,0,0,602,603,1,0,0,0,603,605,1,0,0,0,604,474,1,0,0,0,604,478,1,0, + 0,0,604,482,1,0,0,0,604,489,1,0,0,0,604,490,1,0,0,0,604,495,1,0,0,0,604, + 506,1,0,0,0,604,507,1,0,0,0,604,508,1,0,0,0,604,509,1,0,0,0,604,510,1,0, + 0,0,604,511,1,0,0,0,604,513,1,0,0,0,604,521,1,0,0,0,604,528,1,0,0,0,604, + 536,1,0,0,0,604,541,1,0,0,0,604,545,1,0,0,0,604,549,1,0,0,0,604,550,1,0, + 0,0,604,551,1,0,0,0,604,553,1,0,0,0,604,561,1,0,0,0,604,562,1,0,0,0,604, + 563,1,0,0,0,604,564,1,0,0,0,604,565,1,0,0,0,604,566,1,0,0,0,604,570,1,0, + 0,0,604,573,1,0,0,0,604,576,1,0,0,0,604,578,1,0,0,0,604,588,1,0,0,0,605, + 670,1,0,0,0,606,607,10,29,0,0,607,608,5,22,0,0,608,669,3,60,30,30,609,610, + 10,28,0,0,610,611,5,21,0,0,611,669,3,60,30,29,612,613,10,25,0,0,613,614, + 5,54,0,0,614,669,3,60,30,26,615,616,10,24,0,0,616,617,5,53,0,0,617,669, + 3,60,30,25,618,619,10,52,0,0,619,669,7,2,0,0,620,621,10,51,0,0,621,622, + 5,55,0,0,622,623,5,4,0,0,623,624,3,60,30,0,624,625,5,5,0,0,625,669,1,0, + 0,0,626,627,10,50,0,0,627,628,5,10,0,0,628,629,5,4,0,0,629,630,3,60,30, + 0,630,631,5,61,0,0,631,632,3,60,30,0,632,633,5,5,0,0,633,669,1,0,0,0,634, + 635,10,49,0,0,635,669,5,28,0,0,636,637,10,48,0,0,637,669,5,11,0,0,638,639, + 10,18,0,0,639,640,5,10,0,0,640,641,5,4,0,0,641,669,5,5,0,0,642,643,10,17, + 0,0,643,644,5,55,0,0,644,645,5,4,0,0,645,669,5,5,0,0,646,647,10,16,0,0, + 647,669,3,8,4,0,648,649,10,15,0,0,649,669,3,10,5,0,650,651,10,14,0,0,651, + 669,3,12,6,0,652,653,10,13,0,0,653,669,5,12,0,0,654,655,10,9,0,0,655,669, + 3,56,28,0,656,657,10,8,0,0,657,669,3,58,29,0,658,659,10,7,0,0,659,669,3, + 28,14,0,660,661,10,6,0,0,661,669,3,30,15,0,662,663,10,5,0,0,663,669,3,32, + 16,0,664,665,10,4,0,0,665,669,3,36,18,0,666,667,10,3,0,0,667,669,3,38,19, + 0,668,606,1,0,0,0,668,609,1,0,0,0,668,612,1,0,0,0,668,615,1,0,0,0,668,618, + 1,0,0,0,668,620,1,0,0,0,668,626,1,0,0,0,668,634,1,0,0,0,668,636,1,0,0,0, + 668,638,1,0,0,0,668,642,1,0,0,0,668,646,1,0,0,0,668,648,1,0,0,0,668,650, + 1,0,0,0,668,652,1,0,0,0,668,654,1,0,0,0,668,656,1,0,0,0,668,658,1,0,0,0, + 668,660,1,0,0,0,668,662,1,0,0,0,668,664,1,0,0,0,668,666,1,0,0,0,669,672, + 1,0,0,0,670,668,1,0,0,0,670,671,1,0,0,0,671,61,1,0,0,0,672,670,1,0,0,0, + 673,674,7,7,0,0,674,675,3,68,34,0,675,676,7,8,0,0,676,63,1,0,0,0,677,678, + 7,7,0,0,678,679,7,9,0,0,679,680,7,10,0,0,680,681,7,9,0,0,681,682,7,8,0, + 0,682,65,1,0,0,0,683,684,5,80,0,0,684,685,5,90,0,0,685,686,7,9,0,0,686, + 687,5,91,0,0,687,688,5,90,0,0,688,689,5,93,0,0,689,692,5,91,0,0,690,692, + 5,81,0,0,691,683,1,0,0,0,691,690,1,0,0,0,692,67,1,0,0,0,693,694,6,34,-1, + 0,694,695,5,84,0,0,695,696,5,90,0,0,696,697,3,60,30,0,697,698,5,91,0,0, + 698,716,1,0,0,0,699,700,5,80,0,0,700,703,5,90,0,0,701,704,3,68,34,0,702, + 704,5,92,0,0,703,701,1,0,0,0,703,702,1,0,0,0,704,705,1,0,0,0,705,706,5, + 91,0,0,706,707,5,90,0,0,707,708,3,68,34,0,708,709,5,91,0,0,709,716,1,0, + 0,0,710,716,5,87,0,0,711,712,5,88,0,0,712,713,3,68,34,0,713,714,5,89,0, + 0,714,716,1,0,0,0,715,693,1,0,0,0,715,699,1,0,0,0,715,710,1,0,0,0,715,711, + 1,0,0,0,716,739,1,0,0,0,717,718,10,4,0,0,718,719,5,82,0,0,719,738,3,68, + 34,5,720,721,10,9,0,0,721,722,5,86,0,0,722,738,5,93,0,0,723,724,10,8,0, + 0,724,725,5,86,0,0,725,726,5,90,0,0,726,727,5,93,0,0,727,738,5,91,0,0,728, + 729,10,7,0,0,729,730,5,86,0,0,730,738,3,66,33,0,731,732,10,6,0,0,732,733, + 5,86,0,0,733,734,5,90,0,0,734,735,3,66,33,0,735,736,5,91,0,0,736,738,1, + 0,0,0,737,717,1,0,0,0,737,720,1,0,0,0,737,723,1,0,0,0,737,728,1,0,0,0,737, + 731,1,0,0,0,738,741,1,0,0,0,739,737,1,0,0,0,739,740,1,0,0,0,740,69,1,0, + 0,0,741,739,1,0,0,0,55,87,101,104,117,133,146,151,158,163,168,175,181,191, + 196,201,209,219,231,245,256,268,276,287,306,320,330,348,356,366,377,394, + 398,405,411,418,435,445,453,461,469,501,513,521,581,588,593,602,604,668, + 670,691,703,715,737,739]; private static __ATN: ATN; public static get _ATN(): ATN { @@ -5478,6 +5488,23 @@ export class SubExprContext extends ExprContext { } } } +export class SummationContext extends ExprContext { + constructor(parser: LatexParser, ctx: ExprContext) { + super(parser, ctx.parentCtx, ctx.invokingState); + super.copyFrom(ctx); + } + public summation_cmd(): Summation_cmdContext { + return this.getTypedRuleContext(Summation_cmdContext, 0) as Summation_cmdContext; + } + // @Override + public accept(visitor: LatexParserVisitor): Result { + if (visitor.visitSummation) { + return visitor.visitSummation(this); + } else { + return visitor.visitChildren(this); + } + } +} export class NormContext extends ExprContext { constructor(parser: LatexParser, ctx: ExprContext) { super(parser, ctx.parentCtx, ctx.invokingState); diff --git a/src/parser/LatexParserVisitor.ts b/src/parser/LatexParserVisitor.ts index 9f3596ede..73779d524 100644 --- a/src/parser/LatexParserVisitor.ts +++ b/src/parser/LatexParserVisitor.ts @@ -46,6 +46,7 @@ import { DerivativeContext } from "./LatexParser"; import { UserFunctionContext } from "./LatexParser"; import { MatrixContext } from "./LatexParser"; import { SubExprContext } from "./LatexParser"; +import { SummationContext } from "./LatexParser"; import { NormContext } from "./LatexParser"; import { EmptyPlaceholderContext } from "./LatexParser"; import { SqrtContext } from "./LatexParser"; @@ -355,6 +356,13 @@ export default class LatexParserVisitor extends ParseTreeVisitor * @return the visitor result */ visitSubExpr?: (ctx: SubExprContext) => Result; + /** + * Visit a parse tree produced by the `summation` + * labeled alternative in `LatexParser.expr`. + * @param ctx the parse tree + * @return the visitor result + */ + visitSummation?: (ctx: SummationContext) => Result; /** * Visit a parse tree produced by the `norm` * labeled alternative in `LatexParser.expr`. diff --git a/src/parser/LatexToSympy.ts b/src/parser/LatexToSympy.ts index edd7d2d34..2697392e2 100644 --- a/src/parser/LatexToSympy.ts +++ b/src/parser/LatexToSympy.ts @@ -33,6 +33,7 @@ import { type IndefiniteIntegralContext, type Indefinite_integral_cmdContext, type Integral_cmdContext, type IntegralContext, type DerivativeContext, type Derivative_cmdContext, type NDerivativeContext, type N_derivative_cmdContext, + type Summation_cmdContext, type SummationContext, type TrigFunctionContext, type UnitExponentContext, type UnitFractionalExponentContext, type SqrtContext, type LnContext, type LogContext, type AbsContext, type UnaryMinusContext, type BaseLogContext, type UnitSqrtContext, type MultiplyContext, Number_with_unitsContext, type UnitMultiplyContext, @@ -1810,6 +1811,43 @@ export class LatexToSympy extends LatexParserVisitor { + const child = ctx.children[0] as Summation_cmdContext; + + const dummyVariable = this.visitId(child.id()); + + this.currentDummyVars.add(dummyVariable); + const operand: string = this.visit(child._operand_expr) as string; + this.currentDummyVars.delete(dummyVariable); + + const start = this.visit(child._start_expr) as string; + + let end: string; + + if (child._end_expr) { + end = this.visit(child._end_expr) as string; + } else if (child.CARET_SINGLE_CHAR_ID()) { + end = this.mapVariableNames(child.CARET_SINGLE_CHAR_ID().toString()[1]); + this.params.push(end); + + if (this.inQueryStatement && !this.currentDummyVars.has(end)) { + this.subQueryReplacements.push([end, + { + type: "replacement", + location: child.CARET_SINGLE_CHAR_ID().symbol.start+1, + deletionLength: 1, + text: `{${end}}` + }]); + + this.addSubQuery(end); + } + } else { + end = child.CARET_SINGLE_CHAR_NUMBER().toString()[1]; + } + + return `_summation(Subs(${operand}, ${dummyVariable}, ${dummyVariable}__dummy_var), ${dummyVariable}__dummy_var, ${start}, ${end})`; + } + visitTrigFunction = (ctx: TrigFunctionContext) => { let trigFunctionName;