-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathmathjsParser.js
More file actions
319 lines (318 loc) · 11.9 KB
/
Copy pathmathjsParser.js
File metadata and controls
319 lines (318 loc) · 11.9 KB
1
2
import antlr4 from '../antlr4/index.web.js';const serializedATN = [4,1,20,110,2,0,7,0,2,1,7,1,2,2,7,2,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,5,1,22,8,1,10,1,12,1,25,9,1,3,1,27,8,1,1,1,1,1,1,1,1,1,1,1,5,1,34,8,1,10,1,12,1,37,9,1,1,1,3,1,40,8,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,48,8,1,10,1,12,1,51,9,1,1,1,3,1,54,8,1,1,1,1,1,1,1,3,1,59,8,1,1,1,1,1,1,1,3,1,64,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,5,1,82,8,1,10,1,12,1,85,9,1,3,1,87,8,1,1,1,3,1,90,8,1,1,1,1,1,1,1,1,1,3,1,96,8,1,1,1,1,1,1,1,5,1,101,8,1,10,1,12,1,104,9,1,1,2,1,2,1,2,1,2,1,2,0,1,2,3,0,2,4,0,2,1,0,12,14,1,0,15,17,129,0,6,1,0,0,0,2,63,1,0,0,0,4,105,1,0,0,0,6,7,3,2,1,0,7,8,5,0,0,1,8,1,1,0,0,0,9,10,6,1,-1,0,10,11,5,1,0,0,11,12,3,2,1,0,12,13,5,2,0,0,13,64,1,0,0,0,14,15,5,7,0,0,15,64,3,2,1,10,16,17,5,17,0,0,17,26,5,1,0,0,18,23,3,2,1,0,19,20,5,4,0,0,20,22,3,2,1,0,21,19,1,0,0,0,22,25,1,0,0,0,23,21,1,0,0,0,23,24,1,0,0,0,24,27,1,0,0,0,25,23,1,0,0,0,26,18,1,0,0,0,26,27,1,0,0,0,27,28,1,0,0,0,28,64,5,2,0,0,29,30,5,10,0,0,30,35,3,4,2,0,31,32,5,4,0,0,32,34,3,4,2,0,33,31,1,0,0,0,34,37,1,0,0,0,35,33,1,0,0,0,35,36,1,0,0,0,36,39,1,0,0,0,37,35,1,0,0,0,38,40,5,4,0,0,39,38,1,0,0,0,39,40,1,0,0,0,40,41,1,0,0,0,41,42,5,11,0,0,42,64,1,0,0,0,43,44,5,5,0,0,44,49,3,2,1,0,45,46,5,4,0,0,46,48,3,2,1,0,47,45,1,0,0,0,48,51,1,0,0,0,49,47,1,0,0,0,49,50,1,0,0,0,50,53,1,0,0,0,51,49,1,0,0,0,52,54,5,4,0,0,53,52,1,0,0,0,53,54,1,0,0,0,54,55,1,0,0,0,55,56,5,6,0,0,56,64,1,0,0,0,57,59,5,13,0,0,58,57,1,0,0,0,58,59,1,0,0,0,59,60,1,0,0,0,60,64,5,15,0,0,61,64,5,16,0,0,62,64,5,17,0,0,63,9,1,0,0,0,63,14,1,0,0,0,63,16,1,0,0,0,63,29,1,0,0,0,63,43,1,0,0,0,63,58,1,0,0,0,63,61,1,0,0,0,63,62,1,0,0,0,64,102,1,0,0,0,65,66,10,8,0,0,66,67,7,0,0,0,67,101,3,2,1,9,68,69,10,7,0,0,69,70,5,8,0,0,70,71,3,2,1,0,71,72,5,9,0,0,72,73,3,2,1,8,73,101,1,0,0,0,74,75,10,12,0,0,75,76,5,3,0,0,76,89,5,17,0,0,77,86,5,1,0,0,78,83,3,2,1,0,79,80,5,4,0,0,80,82,3,2,1,0,81,79,1,0,0,0,82,85,1,0,0,0,83,81,1,0,0,0,83,84,1,0,0,0,84,87,1,0,0,0,85,83,1,0,0,0,86,78,1,0,0,0,86,87,1,0,0,0,87,88,1,0,0,0,88,90,5,2,0,0,89,77,1,0,0,0,89,90,1,0,0,0,90,101,1,0,0,0,91,92,10,11,0,0,92,95,5,5,0,0,93,96,5,17,0,0,94,96,3,2,1,0,95,93,1,0,0,0,95,94,1,0,0,0,96,97,1,0,0,0,97,101,5,6,0,0,98,99,10,9,0,0,99,101,5,12,0,0,100,65,1,0,0,0,100,68,1,0,0,0,100,74,1,0,0,0,100,91,1,0,0,0,100,98,1,0,0,0,101,104,1,0,0,0,102,100,1,0,0,0,102,103,1,0,0,0,103,3,1,0,0,0,104,102,1,0,0,0,105,106,7,1,0,0,106,107,5,9,0,0,107,108,3,2,1,0,108,5,1,0,0,0,14,23,26,35,39,49,53,58,63,83,86,89,95,100,102];const atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);const decisionsToDFA = atn.decisionToState.map( (ds, index) => new antlr4.dfa.DFA(ds, index) );const sharedContextCache = new antlr4.atn.PredictionContextCache();export default class mathjsParser extends antlr4.Parser { static grammarFileName = "mathjs.g4"; static literalNames =[]; static symbolicNames =[]; static ruleNames =[]; constructor(input) { super(input); this._interp = new antlr4.atn.ParserATNSimulator(this, atn, decisionsToDFA, sharedContextCache); this.ruleNames = mathjsParser.ruleNames; this.literalNames = mathjsParser.literalNames; this.symbolicNames = mathjsParser.symbolicNames; } sempred(localctx, ruleIndex, predIndex){return true;}; A(a){this.match(a);} B(a,b){this.match(a);this.match(b);} C(a,b,c){this.match(a);this.match(b);this.match(c);} D(a,b,c,d){this.match(a);this.match(b);this.match(c);this.match(d);} E(a,b){this.state=a;this.expr(b);} I(a,b,e,f){this.match(a);this.match(b);this.state=e;this.expr(f);} J(a,e,f){this.match(a);this.state=e;this.expr(f);} R(){return this._input.LT(1);} Q(){this._errHandler.reportMatch(this);this.consume();} W(a,b,c){this.pushNewRecursionContext(a, b, c);} X(){this._errHandler.sync(this);} Y(){return this._input.LA(1);} Z(){this._errHandler.sync(this);return this._input.LA(1);} prog() { let localctx = new ProgContext(this, this._ctx, this.state); this.enterRule(localctx, 0, 0); try { this.enterOuterAlt(localctx, 1); this.E(6,0); this.match(-1); } catch (re) { if(re instanceof antlr4.error.RecognitionException) { localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return localctx; } expr(_p) { if(_p===undefined) { _p = 0; } const _parentctx = this._ctx; const _parentState = this.state; let localctx = new ExprContext(this, this._ctx, _parentState); const _startState = 2; this.enterRecursionRule(localctx, 2, 1, _p); var _la = 0; try { this.enterOuterAlt(localctx, 1); this.X(); var la_ = this._interp.adaptivePredict(this._input,7,this._ctx); switch(la_) { case 1: this.J(1,11,0); this.A(2); break; case 2: this.J(7,15,10); break; case 3: this.B(17,1); _la = this.Z(); if((((_la) & ~0x1f) === 0 && ((1 << _la) & 238754) !== 0)) { this.E(18,0); _la = this.Z(); while(_la===4) { this.J(4,20,0); _la = this.Z(); } } this.A(2); break; case 4: this.A(10); this.state = 30; this.arrayJson(); this.X(); var _alt = this._interp.adaptivePredict(this._input,2,this._ctx) while(_alt!=2 && _alt!=antlr4.atn.ATN.INVALID_ALT_NUMBER) { if(_alt===1) { this.A(4); this.state = 32; this.arrayJson(); } this.X(); _alt = this._interp.adaptivePredict(this._input,2,this._ctx); } _la = this.Z(); if(_la===4) { this.A(4); } this.A(11); break; case 5: this.J(5,44,0); this.X(); var _alt = this._interp.adaptivePredict(this._input,4,this._ctx) while(_alt!=2 && _alt!=antlr4.atn.ATN.INVALID_ALT_NUMBER) { if(_alt===1) { this.J(4,46,0); } this.X(); _alt = this._interp.adaptivePredict(this._input,4,this._ctx); } _la = this.Z(); if(_la===4) { this.A(4); } this.A(6); break; case 6: _la = this.Z(); if(_la===13) { this.A(13); } this.A(15); break; case 7: this.A(16); break; case 8: this.A(17); break; } this._ctx.stop = this._input.LT(-1); this.X(); var _alt = this._interp.adaptivePredict(this._input,13,this._ctx) while(_alt!=2 && _alt!=antlr4.atn.ATN.INVALID_ALT_NUMBER) { if(_alt===1) { if(this._parseListeners!==null) { this.triggerExitRuleEvent(); } this.X(); var la_ = this._interp.adaptivePredict(this._input,12,this._ctx); switch(la_) { case 1: localctx = new ExprContext(this, _parentctx, _parentState); this.W(localctx, _startState, 1); this.state = 65; _la = this.Y(); if(!((((_la) & ~0x1f) === 0 && ((1 << _la) & 28672) !== 0))) { this._errHandler.recoverInline(this); } else { this.Q(); } this.E(67,9); break; case 2: localctx = new ExprContext(this, _parentctx, _parentState); this.W(localctx, _startState, 1); this.J(8,70,0); this.J(9,72,8); break; case 3: localctx = new ExprContext(this, _parentctx, _parentState); this.W(localctx, _startState, 1); this.B(3,17); this.X(); var la_ = this._interp.adaptivePredict(this._input,10,this._ctx); if(la_===1) { this.A(1); _la = this.Z(); if((((_la) & ~0x1f) === 0 && ((1 << _la) & 238754) !== 0)) { this.E(78,0); _la = this.Z(); while(_la===4) { this.J(4,80,0); _la = this.Z(); } } this.A(2); } break; case 4: localctx = new ExprContext(this, _parentctx, _parentState); this.W(localctx, _startState, 1); this.A(5); this.X(); var la_ = this._interp.adaptivePredict(this._input,11,this._ctx); switch(la_) { case 1: this.A(17); break; case 2: this.E(94,0); break; } this.A(6); break; case 5: localctx = new ExprContext(this, _parentctx, _parentState); this.W(localctx, _startState, 1); this.A(12); break; } } this.X(); _alt = this._interp.adaptivePredict(this._input,13,this._ctx); } } catch( error) { if(error instanceof antlr4.error.RecognitionException) { localctx.exception = error; this._errHandler.reportError(this, error); this._errHandler.recover(this, error); } else { throw error; } } finally { this.unrollRecursionContexts(_parentctx) } return localctx; } arrayJson() { let localctx = new ArrayJsonContext(this, this._ctx, this.state); this.enterRule(localctx, 4, 2); var _la = 0; try { this.enterOuterAlt(localctx, 1); _la = this.Y(); if(!((((_la) & ~0x1f) === 0 && ((1 << _la) & 229376) !== 0))) { this._errHandler.recoverInline(this); } else { this.Q(); } this.J(9,107,0); } catch (re) { if(re instanceof antlr4.error.RecognitionException) { localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return localctx; }}class ProgContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { super(parent, invokingState); this.parser = parser; this.ruleIndex = 0; } accept(visitor) { return visitor.visitProg(this); }}class ExprContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { super(parent, invokingState); this.parser = parser; this.ruleIndex = 1; } accept(visitor) { return visitor.visitExpr(this); }}class ArrayJsonContext extends antlr4.ParserRuleContext { constructor(parser, parent, invokingState) { super(parent, invokingState); this.parser = parser; this.ruleIndex = 2; } accept(visitor) { return visitor.visitArrayJson(this); }}