public override ProgNode VisitProg([NotNull] ProgContext context) { var statements = context.statements().Invoke(VisitStatements); statements ??= new List <StatementNode>(); return(new ProgNode(statements, GetLocation(context))); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(_ctx, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 5; _errHandler.Sync(this); _la = _input.La(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << OBRACKET) | (1L << SHIFT_RIGHT) | (1L << SHIFT_LEFT) | (1L << UPPER) | (1L << LOWER) | (1L << SUBSTRING) | (1L << STRING))) != 0)) { { State = 4; expression(0); } } State = 7; Match(Eof); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 21; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la == R_VAR) { { { State = 12; f_defi(); State = 16; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la == NEWLINE) { { { State = 13; Match(NEWLINE); } } State = 18; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } } } State = 23; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public override int GetHashCode() { int hashCode = 0; unchecked { if (ProgContext != null) { hashCode += 1000000007 * ProgContext.GetHashCode(); } hashCode += 1000000009 * EntryPoint.GetHashCode(); if (Closure != null) { hashCode += 1000000021 * Closure.GetHashCode(); } } return(hashCode); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(_ctx, State); EnterRule(_localctx, 0, RULE_prog); try { int _alt; EnterOuterAlt(_localctx, 1); { State = 7; _errHandler.Sync(this); _alt = 1; do { switch (_alt) { case 1: { { State = 6; expr(0); } } break; default: throw new NoViableAltException(this); } State = 9; _errHandler.Sync(this); _alt = Interpreter.AdaptivePredict(_input, 0, _ctx); } while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(_ctx, State); EnterRule(_localctx, 0, RULE_prog); try { State = 27; _errHandler.Sync(this); switch (Interpreter.AdaptivePredict(_input, 0, _ctx)) { case 1: EnterOuterAlt(_localctx, 1); { State = 24; start(); } break; case 2: EnterOuterAlt(_localctx, 2); { State = 25; propositions(0); } break; case 3: EnterOuterAlt(_localctx, 3); { State = 26; end(); } break; } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); try { EnterOuterAlt(_localctx, 1); { State = 10; element(); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
/// <summary> /// 编译公式,默认 /// </summary> /// <param name="exp">公式</param> /// <returns></returns> public bool Parse(string exp) { if (string.IsNullOrWhiteSpace(exp)) { LastError = "Parameter exp invalid !"; return(false); } //try { var stream = new CaseChangingCharStream(new AntlrInputStream(exp)); var lexer = new mathLexer(stream); var tokens = new CommonTokenStream(lexer); var parser = new mathParser(tokens); var antlrErrorListener = new AntlrErrorListener(); parser.RemoveErrorListeners(); parser.AddErrorListener(antlrErrorListener); var context = parser.prog(); var end = context.Stop.StopIndex; if (end + 1 < exp.Length) { _context = null; LastError = "Parameter exp invalid !"; return(false); } if (antlrErrorListener.IsError) { _context = null; LastError = antlrErrorListener.ErrorMsg; return(false); } _context = context; return(true); //} catch (Exception ex) { // LastError = ex.Message; // return false; //} }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 20; statement(); State = 25; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la == EOL) { { { State = 21; Match(EOL); State = 22; statement(); } } State = 27; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } State = 28; Match(Eof); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 9; ErrorHandler.Sync(this); _la = TokenStream.La(1); while (_la == T__4 || _la == INT) { { { State = 4; expr(0); State = 5; Match(NEWLINE); } } State = 11; ErrorHandler.Sync(this); _la = TokenStream.La(1); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 11; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { State = 10; stat(); } } State = 13; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__1) | (1L << ASSIGN) | (1L << SIN) | (1L << COS) | (1L << TAN) | (1L << LN) | (1L << LOG) | (1L << SQRT) | (1L << LL) | (1L << ID) | (1L << NUM) | (1L << NL))) != 0)); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 15; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { State = 14; elem(); } } State = 17; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INITIALISE) | (1L << FINALISE) | (1L << GAMETYPE) | (1L << PC) | (1L << ATTACKSTYLE))) != 0)); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 17; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { State = 16; elem(); } } State = 19; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << START) | (1L << FLATPATH) | (1L << LOWPLATFORM) | (1L << HIGHPLATFORM) | (1L << PATHGAP) | (1L << FINISHLINE))) != 0)); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(_ctx, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 7; _errHandler.Sync(this); _la = _input.La(1); do { { { State = 6; stat(); } } State = 9; _errHandler.Sync(this); _la = _input.La(1); } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << 2) | (1L << ID) | (1L << INT) | (1L << NEWLINE))) != 0)); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(_ctx, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 5; _errHandler.Sync(this); _la = _input.La(1); do { { { State = 4; expr(0); } } State = 7; _errHandler.Sync(this); _la = _input.La(1); } while (_la == T__0 || _la == INT); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.ReportError(this, re); _errHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 9; ErrorHandler.Sync(this); _la = TokenStream.La(1); do { { { State = 8; cmd(); } } State = 11; ErrorHandler.Sync(this); _la = TokenStream.La(1); } while (_la == MOV || _la == ROT); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 7; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { State = 6; stmt(); } } State = 9; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NOP) | (1L << IADD) | (1L << ISUB) | (1L << IMUL) | (1L << ILT) | (1L << IEQ) | (1L << BR) | (1L << BRT) | (1L << BRF) | (1L << ICONST) | (1L << LOAD) | (1L << GLOAD) | (1L << STORE) | (1L << GSTORE) | (1L << PRINT) | (1L << POP) | (1L << CALL) | (1L << RET) | (1L << HALT) | (1L << LABEL) | (1L << NEWLINE))) != 0)); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 9; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { State = 8; cmd(); } } State = 11; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ID) | (1L << NUM) | (1L << LBRACK))) != 0)); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public override object VisitProg([NotNull] ProgContext context) { return(Visit(context.expression())); }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 22; ErrorHandler.Sync(this); _la = TokenStream.La(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__7) | (1L << T__14) | (1L << T__15) | (1L << T__25) | (1L << T__30) | (1L << T__34) | (1L << T__35) | (1L << T__37) | (1L << T__39) | (1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45) | (1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << HEX) | (1L << INT) | (1L << FLOAT) | (1L << COMPLEX) | (1L << STRING) | (1L << ID) | (1L << NL))) != 0)) { { State = 20; switch (TokenStream.La(1)) { case T__7: case T__14: case T__15: case T__25: case T__30: case T__34: case T__35: case T__37: case T__39: case T__41: case T__42: case T__43: case T__44: case T__45: case T__46: case T__47: case T__48: case T__49: case T__50: case T__51: case HEX: case INT: case FLOAT: case COMPLEX: case STRING: case ID: { State = 16; expr_or_assign(); State = 17; _la = TokenStream.La(1); if ( !(_la==T__0 || _la==NL) ) { ErrorHandler.RecoverInline(this); } else { Consume(); } } break; case NL: { State = 19; Match(NL); } break; default: throw new NoViableAltException(this); } } State = 24; ErrorHandler.Sync(this); _la = TokenStream.La(1); } State = 25; Match(Eof); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }
public ProgContext prog() { ProgContext _localctx = new ProgContext(Context, State); EnterRule(_localctx, 0, RULE_prog); int _la; try { EnterOuterAlt(_localctx, 1); { State = 9; ErrorHandler.Sync(this); _la = TokenStream.La(1); do { { { State = 8; cmd(); } } State = 11; ErrorHandler.Sync(this); _la = TokenStream.La(1); } while ( _la==MOV || _la==ROT ); } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return _localctx; }