Exemplo n.º 1
0
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ETPParser extends Parser {
  protected static final DFA[] _decisionToDFA;
  protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache();
  public static final int FUN = 1,
      REF = 2,
      COMMA = 3,
      LSQUARE = 4,
      RSQUARE = 5,
      LCURLY = 6,
      RCURLY = 7,
      LESSTHAN = 8,
      GREATERTHAN = 9,
      COLON = 10,
      BINSTART = 11,
      BINEND = 12,
      TRUE = 13,
      FALSE = 14,
      AT = 15,
      HASH = 16,
      DOT = 17,
      ID = 18,
      IDSTRING = 19,
      INT = 20,
      FLOAT = 21,
      PID = 22,
      REFID = 23,
      STRING = 24,
      LINE_COMMENT = 25,
      WS = 26;
  public static final String[] tokenNames = {
    "<INVALID>",
    "'Fun'",
    "'Ref'",
    "','",
    "'['",
    "']'",
    "'{'",
    "'}'",
    "'<'",
    "'>'",
    "':'",
    "'<<'",
    "'>>'",
    "'true'",
    "'false'",
    "'@'",
    "'#'",
    "'.'",
    "ID",
    "IDSTRING",
    "INT",
    "FLOAT",
    "PID",
    "REFID",
    "STRING",
    "LINE_COMMENT",
    "WS"
  };
  public static final int RULE_etp_term = 0,
      RULE_etp_int = 1,
      RULE_etp_float = 2,
      RULE_etp_string = 3,
      RULE_etp_atom = 4,
      RULE_etp_bool = 5,
      RULE_etp_list = 6,
      RULE_etp_tuple = 7,
      RULE_etp_pid = 8,
      RULE_etp_fun = 9,
      RULE_etp_binary = 10,
      RULE_etp_binary_item = 11,
      RULE_etp_ref = 12;
  public static final String[] ruleNames = {
    "etp_term", "etp_int", "etp_float", "etp_string", "etp_atom", "etp_bool",
    "etp_list", "etp_tuple", "etp_pid", "etp_fun", "etp_binary", "etp_binary_item",
    "etp_ref"
  };

  @Override
  public String getGrammarFileName() {
    return "ETP.g4";
  }

  @Override
  public String[] getTokenNames() {
    return tokenNames;
  }

  @Override
  public String[] getRuleNames() {
    return ruleNames;
  }

  @Override
  public ATN getATN() {
    return _ATN;
  }

  public ETPParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
  }

  public static class Etp_termContext extends ParserRuleContext {
    public Etp_refContext etp_ref() {
      return getRuleContext(Etp_refContext.class, 0);
    }

    public Etp_floatContext etp_float() {
      return getRuleContext(Etp_floatContext.class, 0);
    }

    public Etp_pidContext etp_pid() {
      return getRuleContext(Etp_pidContext.class, 0);
    }

    public Etp_binaryContext etp_binary() {
      return getRuleContext(Etp_binaryContext.class, 0);
    }

    public Etp_tupleContext etp_tuple() {
      return getRuleContext(Etp_tupleContext.class, 0);
    }

    public Etp_atomContext etp_atom() {
      return getRuleContext(Etp_atomContext.class, 0);
    }

    public Etp_stringContext etp_string() {
      return getRuleContext(Etp_stringContext.class, 0);
    }

    public Etp_funContext etp_fun() {
      return getRuleContext(Etp_funContext.class, 0);
    }

    public Etp_boolContext etp_bool() {
      return getRuleContext(Etp_boolContext.class, 0);
    }

    public Etp_listContext etp_list() {
      return getRuleContext(Etp_listContext.class, 0);
    }

    public Etp_intContext etp_int() {
      return getRuleContext(Etp_intContext.class, 0);
    }

    public Etp_termContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_term;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_term(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_term(this);
    }
  }

  public final Etp_termContext etp_term() throws RecognitionException {
    Etp_termContext _localctx = new Etp_termContext(_ctx, getState());
    enterRule(_localctx, 0, RULE_etp_term);
    try {
      setState(37);
      switch (getInterpreter().adaptivePredict(_input, 0, _ctx)) {
        case 1:
          enterOuterAlt(_localctx, 1);
          {
            setState(26);
            etp_atom();
          }
          break;

        case 2:
          enterOuterAlt(_localctx, 2);
          {
            setState(27);
            etp_int();
          }
          break;

        case 3:
          enterOuterAlt(_localctx, 3);
          {
            setState(28);
            etp_float();
          }
          break;

        case 4:
          enterOuterAlt(_localctx, 4);
          {
            setState(29);
            etp_string();
          }
          break;

        case 5:
          enterOuterAlt(_localctx, 5);
          {
            setState(30);
            etp_bool();
          }
          break;

        case 6:
          enterOuterAlt(_localctx, 6);
          {
            setState(31);
            etp_list();
          }
          break;

        case 7:
          enterOuterAlt(_localctx, 7);
          {
            setState(32);
            etp_tuple();
          }
          break;

        case 8:
          enterOuterAlt(_localctx, 8);
          {
            setState(33);
            etp_binary();
          }
          break;

        case 9:
          enterOuterAlt(_localctx, 9);
          {
            setState(34);
            etp_pid();
          }
          break;

        case 10:
          enterOuterAlt(_localctx, 10);
          {
            setState(35);
            etp_fun();
          }
          break;

        case 11:
          enterOuterAlt(_localctx, 11);
          {
            setState(36);
            etp_ref();
          }
          break;
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_intContext extends ParserRuleContext {
    public TerminalNode INT() {
      return getToken(ETPParser.INT, 0);
    }

    public Etp_intContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_int;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_int(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_int(this);
    }
  }

  public final Etp_intContext etp_int() throws RecognitionException {
    Etp_intContext _localctx = new Etp_intContext(_ctx, getState());
    enterRule(_localctx, 2, RULE_etp_int);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(39);
        match(INT);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_floatContext extends ParserRuleContext {
    public TerminalNode FLOAT() {
      return getToken(ETPParser.FLOAT, 0);
    }

    public Etp_floatContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_float;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_float(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_float(this);
    }
  }

  public final Etp_floatContext etp_float() throws RecognitionException {
    Etp_floatContext _localctx = new Etp_floatContext(_ctx, getState());
    enterRule(_localctx, 4, RULE_etp_float);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(41);
        match(FLOAT);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_stringContext extends ParserRuleContext {
    public TerminalNode STRING() {
      return getToken(ETPParser.STRING, 0);
    }

    public Etp_stringContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_string;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_string(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_string(this);
    }
  }

  public final Etp_stringContext etp_string() throws RecognitionException {
    Etp_stringContext _localctx = new Etp_stringContext(_ctx, getState());
    enterRule(_localctx, 6, RULE_etp_string);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(43);
        match(STRING);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_atomContext extends ParserRuleContext {
    public TerminalNode ID() {
      return getToken(ETPParser.ID, 0);
    }

    public TerminalNode IDSTRING() {
      return getToken(ETPParser.IDSTRING, 0);
    }

    public Etp_atomContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_atom;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_atom(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_atom(this);
    }
  }

  public final Etp_atomContext etp_atom() throws RecognitionException {
    Etp_atomContext _localctx = new Etp_atomContext(_ctx, getState());
    enterRule(_localctx, 8, RULE_etp_atom);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(45);
        _la = _input.LA(1);
        if (!(_la == ID || _la == IDSTRING)) {
          _errHandler.recoverInline(this);
        }
        consume();
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_boolContext extends ParserRuleContext {
    public TerminalNode FALSE() {
      return getToken(ETPParser.FALSE, 0);
    }

    public TerminalNode TRUE() {
      return getToken(ETPParser.TRUE, 0);
    }

    public Etp_boolContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_bool;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_bool(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_bool(this);
    }
  }

  public final Etp_boolContext etp_bool() throws RecognitionException {
    Etp_boolContext _localctx = new Etp_boolContext(_ctx, getState());
    enterRule(_localctx, 10, RULE_etp_bool);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(47);
        _la = _input.LA(1);
        if (!(_la == TRUE || _la == FALSE)) {
          _errHandler.recoverInline(this);
        }
        consume();
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_listContext extends ParserRuleContext {
    public Etp_termContext etp_term;
    public List<Etp_termContext> listitems = new ArrayList<Etp_termContext>();

    public List<Etp_termContext> etp_term() {
      return getRuleContexts(Etp_termContext.class);
    }

    public TerminalNode COMMA(int i) {
      return getToken(ETPParser.COMMA, i);
    }

    public TerminalNode LSQUARE() {
      return getToken(ETPParser.LSQUARE, 0);
    }

    public TerminalNode RSQUARE() {
      return getToken(ETPParser.RSQUARE, 0);
    }

    public List<TerminalNode> COMMA() {
      return getTokens(ETPParser.COMMA);
    }

    public Etp_termContext etp_term(int i) {
      return getRuleContext(Etp_termContext.class, i);
    }

    public Etp_listContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_list;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_list(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_list(this);
    }
  }

  public final Etp_listContext etp_list() throws RecognitionException {
    Etp_listContext _localctx = new Etp_listContext(_ctx, getState());
    enterRule(_localctx, 12, RULE_etp_list);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(49);
        match(LSQUARE);
        setState(58);
        _la = _input.LA(1);
        if ((((_la) & ~0x3f) == 0
            && ((1L << _la)
                    & ((1L << LSQUARE)
                        | (1L << LCURLY)
                        | (1L << LESSTHAN)
                        | (1L << BINSTART)
                        | (1L << TRUE)
                        | (1L << FALSE)
                        | (1L << HASH)
                        | (1L << ID)
                        | (1L << IDSTRING)
                        | (1L << INT)
                        | (1L << FLOAT)
                        | (1L << STRING)))
                != 0)) {
          {
            setState(50);
            ((Etp_listContext) _localctx).etp_term = etp_term();
            ((Etp_listContext) _localctx).listitems.add(((Etp_listContext) _localctx).etp_term);
            setState(55);
            _errHandler.sync(this);
            _la = _input.LA(1);
            while (_la == COMMA) {
              {
                {
                  setState(51);
                  match(COMMA);
                  setState(52);
                  ((Etp_listContext) _localctx).etp_term = etp_term();
                  ((Etp_listContext) _localctx)
                      .listitems.add(((Etp_listContext) _localctx).etp_term);
                }
              }
              setState(57);
              _errHandler.sync(this);
              _la = _input.LA(1);
            }
          }
        }

        setState(60);
        match(RSQUARE);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_tupleContext extends ParserRuleContext {
    public Etp_termContext etp_term;
    public List<Etp_termContext> tupleitems = new ArrayList<Etp_termContext>();

    public List<Etp_termContext> etp_term() {
      return getRuleContexts(Etp_termContext.class);
    }

    public TerminalNode LCURLY() {
      return getToken(ETPParser.LCURLY, 0);
    }

    public TerminalNode COMMA(int i) {
      return getToken(ETPParser.COMMA, i);
    }

    public List<TerminalNode> COMMA() {
      return getTokens(ETPParser.COMMA);
    }

    public Etp_termContext etp_term(int i) {
      return getRuleContext(Etp_termContext.class, i);
    }

    public TerminalNode RCURLY() {
      return getToken(ETPParser.RCURLY, 0);
    }

    public Etp_tupleContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_tuple;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_tuple(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_tuple(this);
    }
  }

  public final Etp_tupleContext etp_tuple() throws RecognitionException {
    Etp_tupleContext _localctx = new Etp_tupleContext(_ctx, getState());
    enterRule(_localctx, 14, RULE_etp_tuple);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(62);
        match(LCURLY);
        setState(71);
        _la = _input.LA(1);
        if ((((_la) & ~0x3f) == 0
            && ((1L << _la)
                    & ((1L << LSQUARE)
                        | (1L << LCURLY)
                        | (1L << LESSTHAN)
                        | (1L << BINSTART)
                        | (1L << TRUE)
                        | (1L << FALSE)
                        | (1L << HASH)
                        | (1L << ID)
                        | (1L << IDSTRING)
                        | (1L << INT)
                        | (1L << FLOAT)
                        | (1L << STRING)))
                != 0)) {
          {
            setState(63);
            ((Etp_tupleContext) _localctx).etp_term = etp_term();
            ((Etp_tupleContext) _localctx).tupleitems.add(((Etp_tupleContext) _localctx).etp_term);
            setState(68);
            _errHandler.sync(this);
            _la = _input.LA(1);
            while (_la == COMMA) {
              {
                {
                  setState(64);
                  match(COMMA);
                  setState(65);
                  ((Etp_tupleContext) _localctx).etp_term = etp_term();
                  ((Etp_tupleContext) _localctx)
                      .tupleitems.add(((Etp_tupleContext) _localctx).etp_term);
                }
              }
              setState(70);
              _errHandler.sync(this);
              _la = _input.LA(1);
            }
          }
        }

        setState(73);
        match(RCURLY);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_pidContext extends ParserRuleContext {
    public TerminalNode LESSTHAN() {
      return getToken(ETPParser.LESSTHAN, 0);
    }

    public TerminalNode PID() {
      return getToken(ETPParser.PID, 0);
    }

    public TerminalNode GREATERTHAN() {
      return getToken(ETPParser.GREATERTHAN, 0);
    }

    public Etp_pidContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_pid;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_pid(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_pid(this);
    }
  }

  public final Etp_pidContext etp_pid() throws RecognitionException {
    Etp_pidContext _localctx = new Etp_pidContext(_ctx, getState());
    enterRule(_localctx, 16, RULE_etp_pid);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(75);
        match(LESSTHAN);
        setState(76);
        match(PID);
        setState(77);
        match(GREATERTHAN);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_funContext extends ParserRuleContext {
    public TerminalNode HASH() {
      return getToken(ETPParser.HASH, 0);
    }

    public TerminalNode LESSTHAN() {
      return getToken(ETPParser.LESSTHAN, 0);
    }

    public TerminalNode FUN() {
      return getToken(ETPParser.FUN, 0);
    }

    public TerminalNode GREATERTHAN() {
      return getToken(ETPParser.GREATERTHAN, 0);
    }

    public Etp_funContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_fun;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_fun(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_fun(this);
    }
  }

  public final Etp_funContext etp_fun() throws RecognitionException {
    Etp_funContext _localctx = new Etp_funContext(_ctx, getState());
    enterRule(_localctx, 18, RULE_etp_fun);
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
        setState(79);
        match(HASH);
        setState(80);
        match(FUN);
        setState(81);
        match(LESSTHAN);
        setState(85);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input, 5, _ctx);
        while (_alt != 1 && _alt != -1) {
          if (_alt == 1 + 1) {
            {
              {
                setState(82);
                matchWildcard();
              }
            }
          }
          setState(87);
          _errHandler.sync(this);
          _alt = getInterpreter().adaptivePredict(_input, 5, _ctx);
        }
        setState(88);
        match(GREATERTHAN);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_binaryContext extends ParserRuleContext {
    public Etp_binary_itemContext etp_binary_item;
    public List<Etp_binary_itemContext> segments = new ArrayList<Etp_binary_itemContext>();

    public TerminalNode COMMA(int i) {
      return getToken(ETPParser.COMMA, i);
    }

    public TerminalNode BINSTART() {
      return getToken(ETPParser.BINSTART, 0);
    }

    public List<TerminalNode> COMMA() {
      return getTokens(ETPParser.COMMA);
    }

    public TerminalNode BINEND() {
      return getToken(ETPParser.BINEND, 0);
    }

    public List<Etp_binary_itemContext> etp_binary_item() {
      return getRuleContexts(Etp_binary_itemContext.class);
    }

    public Etp_binary_itemContext etp_binary_item(int i) {
      return getRuleContext(Etp_binary_itemContext.class, i);
    }

    public Etp_binaryContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_binary;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_binary(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_binary(this);
    }
  }

  public final Etp_binaryContext etp_binary() throws RecognitionException {
    Etp_binaryContext _localctx = new Etp_binaryContext(_ctx, getState());
    enterRule(_localctx, 20, RULE_etp_binary);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(90);
        match(BINSTART);
        setState(99);
        _la = _input.LA(1);
        if (_la == INT || _la == STRING) {
          {
            setState(91);
            ((Etp_binaryContext) _localctx).etp_binary_item = etp_binary_item();
            ((Etp_binaryContext) _localctx)
                .segments.add(((Etp_binaryContext) _localctx).etp_binary_item);
            setState(96);
            _errHandler.sync(this);
            _la = _input.LA(1);
            while (_la == COMMA) {
              {
                {
                  setState(92);
                  match(COMMA);
                  setState(93);
                  ((Etp_binaryContext) _localctx).etp_binary_item = etp_binary_item();
                  ((Etp_binaryContext) _localctx)
                      .segments.add(((Etp_binaryContext) _localctx).etp_binary_item);
                }
              }
              setState(98);
              _errHandler.sync(this);
              _la = _input.LA(1);
            }
          }
        }

        setState(101);
        match(BINEND);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_binary_itemContext extends ParserRuleContext {
    public Token val;
    public Token size;

    public TerminalNode COLON() {
      return getToken(ETPParser.COLON, 0);
    }

    public List<TerminalNode> INT() {
      return getTokens(ETPParser.INT);
    }

    public TerminalNode INT(int i) {
      return getToken(ETPParser.INT, i);
    }

    public TerminalNode STRING() {
      return getToken(ETPParser.STRING, 0);
    }

    public Etp_binary_itemContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_binary_item;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_binary_item(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_binary_item(this);
    }
  }

  public final Etp_binary_itemContext etp_binary_item() throws RecognitionException {
    Etp_binary_itemContext _localctx = new Etp_binary_itemContext(_ctx, getState());
    enterRule(_localctx, 22, RULE_etp_binary_item);
    int _la;
    try {
      setState(109);
      switch (_input.LA(1)) {
        case INT:
          enterOuterAlt(_localctx, 1);
          {
            setState(103);
            ((Etp_binary_itemContext) _localctx).val = match(INT);
            setState(106);
            _la = _input.LA(1);
            if (_la == COLON) {
              {
                setState(104);
                match(COLON);
                setState(105);
                ((Etp_binary_itemContext) _localctx).size = match(INT);
              }
            }
          }
          break;
        case STRING:
          enterOuterAlt(_localctx, 2);
          {
            setState(108);
            match(STRING);
          }
          break;
        default:
          throw new NoViableAltException(this);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class Etp_refContext extends ParserRuleContext {
    public TerminalNode HASH() {
      return getToken(ETPParser.HASH, 0);
    }

    public TerminalNode LESSTHAN() {
      return getToken(ETPParser.LESSTHAN, 0);
    }

    public TerminalNode REFID() {
      return getToken(ETPParser.REFID, 0);
    }

    public TerminalNode REF() {
      return getToken(ETPParser.REF, 0);
    }

    public TerminalNode GREATERTHAN() {
      return getToken(ETPParser.GREATERTHAN, 0);
    }

    public Etp_refContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_etp_ref;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).enterEtp_ref(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ETPListener) ((ETPListener) listener).exitEtp_ref(this);
    }
  }

  public final Etp_refContext etp_ref() throws RecognitionException {
    Etp_refContext _localctx = new Etp_refContext(_ctx, getState());
    enterRule(_localctx, 24, RULE_etp_ref);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(111);
        match(HASH);
        setState(112);
        match(REF);
        setState(113);
        match(LESSTHAN);
        setState(114);
        match(REFID);
        setState(115);
        match(GREATERTHAN);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static final String _serializedATN =
      "\2\3\34x\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t"
          + "\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\3\2\3\2\3\2\3\2\3\2\3\2"
          + "\3\2\3\2\3\2\3\2\3\2\5\2(\n\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7"
          + "\3\b\3\b\3\b\3\b\7\b8\n\b\f\b\16\b;\13\b\5\b=\n\b\3\b\3\b\3\t\3\t\3\t"
          + "\3\t\7\tE\n\t\f\t\16\tH\13\t\5\tJ\n\t\3\t\3\t\3\n\3\n\3\n\3\n\3\13\3\13"
          + "\3\13\3\13\7\13V\n\13\f\13\16\13Y\13\13\3\13\3\13\3\f\3\f\3\f\3\f\7\f"
          + "a\n\f\f\f\16\fd\13\f\5\ff\n\f\3\f\3\f\3\r\3\r\3\r\5\rm\n\r\3\r\5\rp\n"
          + "\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3W\17\2\4\6\b\n\f\16\20\22\24\26"
          + "\30\32\2\4\3\24\25\3\17\20}\2\'\3\2\2\2\4)\3\2\2\2\6+\3\2\2\2\b-\3\2\2"
          + "\2\n/\3\2\2\2\f\61\3\2\2\2\16\63\3\2\2\2\20@\3\2\2\2\22M\3\2\2\2\24Q\3"
          + "\2\2\2\26\\\3\2\2\2\30o\3\2\2\2\32q\3\2\2\2\34(\5\n\6\2\35(\5\4\3\2\36"
          + "(\5\6\4\2\37(\5\b\5\2 (\5\f\7\2!(\5\16\b\2\"(\5\20\t\2#(\5\26\f\2$(\5"
          + "\22\n\2%(\5\24\13\2&(\5\32\16\2\'\34\3\2\2\2\'\35\3\2\2\2\'\36\3\2\2\2"
          + "\'\37\3\2\2\2\' \3\2\2\2\'!\3\2\2\2\'\"\3\2\2\2\'#\3\2\2\2\'$\3\2\2\2"
          + "\'%\3\2\2\2\'&\3\2\2\2(\3\3\2\2\2)*\7\26\2\2*\5\3\2\2\2+,\7\27\2\2,\7"
          + "\3\2\2\2-.\7\32\2\2.\t\3\2\2\2/\60\t\2\2\2\60\13\3\2\2\2\61\62\t\3\2\2"
          + "\62\r\3\2\2\2\63<\7\6\2\2\649\5\2\2\2\65\66\7\5\2\2\668\5\2\2\2\67\65"
          + "\3\2\2\28;\3\2\2\29\67\3\2\2\29:\3\2\2\2:=\3\2\2\2;9\3\2\2\2<\64\3\2\2"
          + "\2<=\3\2\2\2=>\3\2\2\2>?\7\7\2\2?\17\3\2\2\2@I\7\b\2\2AF\5\2\2\2BC\7\5"
          + "\2\2CE\5\2\2\2DB\3\2\2\2EH\3\2\2\2FD\3\2\2\2FG\3\2\2\2GJ\3\2\2\2HF\3\2"
          + "\2\2IA\3\2\2\2IJ\3\2\2\2JK\3\2\2\2KL\7\t\2\2L\21\3\2\2\2MN\7\n\2\2NO\7"
          + "\30\2\2OP\7\13\2\2P\23\3\2\2\2QR\7\22\2\2RS\7\3\2\2SW\7\n\2\2TV\13\2\2"
          + "\2UT\3\2\2\2VY\3\2\2\2WX\3\2\2\2WU\3\2\2\2XZ\3\2\2\2YW\3\2\2\2Z[\7\13"
          + "\2\2[\25\3\2\2\2\\e\7\r\2\2]b\5\30\r\2^_\7\5\2\2_a\5\30\r\2`^\3\2\2\2"
          + "ad\3\2\2\2b`\3\2\2\2bc\3\2\2\2cf\3\2\2\2db\3\2\2\2e]\3\2\2\2ef\3\2\2\2"
          + "fg\3\2\2\2gh\7\16\2\2h\27\3\2\2\2il\7\26\2\2jk\7\f\2\2km\7\26\2\2lj\3"
          + "\2\2\2lm\3\2\2\2mp\3\2\2\2np\7\32\2\2oi\3\2\2\2on\3\2\2\2p\31\3\2\2\2"
          + "qr\7\22\2\2rs\7\4\2\2st\7\n\2\2tu\7\31\2\2uv\7\13\2\2v\33\3\2\2\2\f\'"
          + "9<FIWbelo";
  public static final ATN _ATN = ATNSimulator.deserialize(_serializedATN.toCharArray());

  static {
    _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
  }
}
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ExtractedLittleParser extends Parser {
  protected static final DFA[] _decisionToDFA;
  protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache();
  public static final int T__1 = 1, T__0 = 2;
  public static final String[] tokenNames = {"<INVALID>", "'+'", "'e'"};
  public static final int RULE_s = 0, RULE_e = 1;
  public static final String[] ruleNames = {"s", "e"};

  @Override
  public String getGrammarFileName() {
    return "ExtractedLittle.g4";
  }

  @Override
  public String[] getTokenNames() {
    return tokenNames;
  }

  @Override
  public String[] getRuleNames() {
    return ruleNames;
  }

  @Override
  public ATN getATN() {
    return _ATN;
  }

  public ExtractedLittleParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
  }

  public static class SContext extends ParserRuleContext {
    public EContext e() {
      return getRuleContext(EContext.class, 0);
    }

    public SContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_s;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ExtractedLittleListener)
        ((ExtractedLittleListener) listener).enterS(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ExtractedLittleListener)
        ((ExtractedLittleListener) listener).exitS(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof ExtractedLittleVisitor)
        return ((ExtractedLittleVisitor<? extends T>) visitor).visitS(this);
      else return visitor.visitChildren(this);
    }
  }

  public final SContext s() throws RecognitionException {
    SContext _localctx = new SContext(_ctx, getState());
    enterRule(_localctx, 0, RULE_s);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(4);
        e(0);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class EContext extends ParserRuleContext {
    public int _p;

    public EContext e(int i) {
      return getRuleContext(EContext.class, i);
    }

    public List<EContext> e() {
      return getRuleContexts(EContext.class);
    }

    public EContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    public EContext(ParserRuleContext parent, int invokingState, int _p) {
      super(parent, invokingState);
      this._p = _p;
    }

    @Override
    public int getRuleIndex() {
      return RULE_e;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ExtractedLittleListener)
        ((ExtractedLittleListener) listener).enterE(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ExtractedLittleListener)
        ((ExtractedLittleListener) listener).exitE(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof ExtractedLittleVisitor)
        return ((ExtractedLittleVisitor<? extends T>) visitor).visitE(this);
      else return visitor.visitChildren(this);
    }
  }

  public final EContext e(int _p) throws RecognitionException {
    ParserRuleContext _parentctx = _ctx;
    int _parentState = getState();
    EContext _localctx = new EContext(_ctx, _parentState, _p);
    EContext _prevctx = _localctx;
    int _startState = 2;
    enterRecursionRule(_localctx, RULE_e);
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
        {
          setState(7);
          match(2);
        }
        _ctx.stop = _input.LT(-1);
        setState(14);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input, 0, _ctx);
        while (_alt != 2 && _alt != -1) {
          if (_alt == 1) {
            if (_parseListeners != null) triggerExitRuleEvent();
            _prevctx = _localctx;
            {
              {
                _localctx = new EContext(_parentctx, _parentState, _p);
                pushNewRecursionContext(_localctx, _startState, RULE_e);
                setState(9);
                if (!(2 >= _localctx._p)) throw new FailedPredicateException(this, "2 >= $_p");
                setState(10);
                match(1);
                setState(11);
                e(3);
              }
            }
          }
          setState(16);
          _errHandler.sync(this);
          _alt = getInterpreter().adaptivePredict(_input, 0, _ctx);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      unrollRecursionContexts(_parentctx);
    }
    return _localctx;
  }

  public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
    switch (ruleIndex) {
      case 1:
        return e_sempred((EContext) _localctx, predIndex);
    }
    return true;
  }

  private boolean e_sempred(EContext _localctx, int predIndex) {
    switch (predIndex) {
      case 0:
        return 2 >= _localctx._p;
    }
    return true;
  }

  public static final String _serializedATN =
      "\3\uacf5\uee8c\u4f5d\u8b0d\u4a45\u78bd\u1b2f\u3378\3\4\24\4\2\t\2\4\3"
          + "\t\3\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\7\3\17\n\3\f\3\16\3\22\13\3\3\3\2"
          + "\4\2\4\2\2\22\2\6\3\2\2\2\4\b\3\2\2\2\6\7\5\4\3\2\7\3\3\2\2\2\b\t\b\3"
          + "\1\2\t\n\7\4\2\2\n\20\3\2\2\2\13\f\6\3\2\3\f\r\7\3\2\2\r\17\5\4\3\2\16"
          + "\13\3\2\2\2\17\22\3\2\2\2\20\16\3\2\2\2\20\21\3\2\2\2\21\5\3\2\2\2\22"
          + "\20\3\2\2\2\3\20";
  public static final ATN _ATN = ATNSimulator.deserialize(_serializedATN.toCharArray());

  static {
    _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
    for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
      _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
    }
  }
}
Exemplo n.º 3
0
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ExprParser extends Parser {
  protected static final DFA[] _decisionToDFA;
  protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache();
  public static final int T__6 = 1,
      T__5 = 2,
      T__4 = 3,
      T__3 = 4,
      T__2 = 5,
      T__1 = 6,
      T__0 = 7,
      ID = 8,
      INT = 9,
      NEWLINE = 10,
      WS = 11;
  public static final String[] tokenNames = {
    "<INVALID>", "')'", "'+'", "'*'", "'-'", "'('", "'/'", "'='", "ID", "INT", "NEWLINE", "WS"
  };
  public static final int RULE_prog = 0, RULE_stat = 1, RULE_expr = 2;
  public static final String[] ruleNames = {"prog", "stat", "expr"};

  @Override
  public String getGrammarFileName() {
    return "Expr.g4";
  }

  @Override
  public String[] getTokenNames() {
    return tokenNames;
  }

  @Override
  public String[] getRuleNames() {
    return ruleNames;
  }

  @Override
  public ATN getATN() {
    return _ATN;
  }

  public ExprParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
  }

  public static class ProgContext extends ParserRuleContext {
    public StatContext stat(int i) {
      return getRuleContext(StatContext.class, i);
    }

    public List<StatContext> stat() {
      return getRuleContexts(StatContext.class);
    }

    public ProgContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_prog;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ExprListener) ((ExprListener) listener).enterProg(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ExprListener) ((ExprListener) listener).exitProg(this);
    }
  }

  public final ProgContext prog() throws RecognitionException {
    ProgContext _localctx = new ProgContext(_ctx, getState());
    enterRule(_localctx, 0, RULE_prog);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(7);
        _errHandler.sync(this);
        _la = _input.LA(1);
        do {
          {
            {
              setState(6);
              stat();
            }
          }
          setState(9);
          _errHandler.sync(this);
          _la = _input.LA(1);
        } while ((((_la) & ~0x3f) == 0
            && ((1L << _la) & ((1L << 5) | (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 static class StatContext extends ParserRuleContext {
    public TerminalNode NEWLINE() {
      return getToken(ExprParser.NEWLINE, 0);
    }

    public ExprContext expr() {
      return getRuleContext(ExprContext.class, 0);
    }

    public TerminalNode ID() {
      return getToken(ExprParser.ID, 0);
    }

    public StatContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_stat;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ExprListener) ((ExprListener) listener).enterStat(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ExprListener) ((ExprListener) listener).exitStat(this);
    }
  }

  public final StatContext stat() throws RecognitionException {
    StatContext _localctx = new StatContext(_ctx, getState());
    enterRule(_localctx, 2, RULE_stat);
    try {
      setState(20);
      switch (getInterpreter().adaptivePredict(_input, 1, _ctx)) {
        case 1:
          enterOuterAlt(_localctx, 1);
          {
            setState(11);
            expr(0);
            setState(12);
            match(NEWLINE);
          }
          break;

        case 2:
          enterOuterAlt(_localctx, 2);
          {
            setState(14);
            match(ID);
            setState(15);
            match(7);
            setState(16);
            expr(0);
            setState(17);
            match(NEWLINE);
          }
          break;

        case 3:
          enterOuterAlt(_localctx, 3);
          {
            setState(19);
            match(NEWLINE);
          }
          break;
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class ExprContext extends ParserRuleContext {
    public int _p;

    public TerminalNode INT() {
      return getToken(ExprParser.INT, 0);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public TerminalNode ID() {
      return getToken(ExprParser.ID, 0);
    }

    public ExprContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    public ExprContext(ParserRuleContext parent, int invokingState, int _p) {
      super(parent, invokingState);
      this._p = _p;
    }

    @Override
    public int getRuleIndex() {
      return RULE_expr;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof ExprListener) ((ExprListener) listener).enterExpr(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof ExprListener) ((ExprListener) listener).exitExpr(this);
    }
  }

  public final ExprContext expr(int _p) throws RecognitionException {
    ParserRuleContext _parentctx = _ctx;
    int _parentState = getState();
    ExprContext _localctx = new ExprContext(_ctx, _parentState, _p);
    ExprContext _prevctx = _localctx;
    int _startState = 4;
    enterRecursionRule(_localctx, RULE_expr);
    int _la;
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
        setState(29);
        switch (_input.LA(1)) {
          case INT:
            {
              setState(23);
              match(INT);
            }
            break;
          case ID:
            {
              setState(24);
              match(ID);
            }
            break;
          case 5:
            {
              setState(25);
              match(5);
              setState(26);
              expr(0);
              setState(27);
              match(1);
            }
            break;
          default:
            throw new NoViableAltException(this);
        }
        _ctx.stop = _input.LT(-1);
        setState(39);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input, 4, _ctx);
        while (_alt != 2 && _alt != -1) {
          if (_alt == 1) {
            if (_parseListeners != null) triggerExitRuleEvent();
            _prevctx = _localctx;
            {
              setState(37);
              switch (getInterpreter().adaptivePredict(_input, 3, _ctx)) {
                case 1:
                  {
                    _localctx = new ExprContext(_parentctx, _parentState, _p);
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(31);
                    if (!(5 >= _localctx._p)) throw new FailedPredicateException(this, "5 >= $_p");
                    setState(32);
                    _la = _input.LA(1);
                    if (!(_la == 3 || _la == 6)) {
                      _errHandler.recoverInline(this);
                    }
                    consume();
                    setState(33);
                    expr(6);
                  }
                  break;

                case 2:
                  {
                    _localctx = new ExprContext(_parentctx, _parentState, _p);
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(34);
                    if (!(4 >= _localctx._p)) throw new FailedPredicateException(this, "4 >= $_p");
                    setState(35);
                    _la = _input.LA(1);
                    if (!(_la == 2 || _la == 4)) {
                      _errHandler.recoverInline(this);
                    }
                    consume();
                    setState(36);
                    expr(5);
                  }
                  break;
              }
            }
          }
          setState(41);
          _errHandler.sync(this);
          _alt = getInterpreter().adaptivePredict(_input, 4, _ctx);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      unrollRecursionContexts(_parentctx);
    }
    return _localctx;
  }

  public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
    switch (ruleIndex) {
      case 2:
        return expr_sempred((ExprContext) _localctx, predIndex);
    }
    return true;
  }

  private boolean expr_sempred(ExprContext _localctx, int predIndex) {
    switch (predIndex) {
      case 0:
        return 5 >= _localctx._p;

      case 1:
        return 4 >= _localctx._p;
    }
    return true;
  }

  public static final String _serializedATN =
      "\3\uacf5\uee8c\u4f5d\u8b0d\u4a45\u78bd\u1b2f\u3378\3\r-\4\2\t\2\4\3\t"
          + "\3\4\4\t\4\3\2\6\2\n\n\2\r\2\16\2\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"
          + "\3\5\3\27\n\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4 \n\4\3\4\3\4\3\4\3\4\3\4"
          + "\3\4\7\4(\n\4\f\4\16\4+\13\4\3\4\2\5\2\4\6\2\4\4\2\5\5\b\b\4\2\4\4\6\6"
          + "\60\2\t\3\2\2\2\4\26\3\2\2\2\6\37\3\2\2\2\b\n\5\4\3\2\t\b\3\2\2\2\n\13"
          + "\3\2\2\2\13\t\3\2\2\2\13\f\3\2\2\2\f\3\3\2\2\2\r\16\5\6\4\2\16\17\7\f"
          + "\2\2\17\27\3\2\2\2\20\21\7\n\2\2\21\22\7\t\2\2\22\23\5\6\4\2\23\24\7\f"
          + "\2\2\24\27\3\2\2\2\25\27\7\f\2\2\26\r\3\2\2\2\26\20\3\2\2\2\26\25\3\2"
          + "\2\2\27\5\3\2\2\2\30\31\b\4\1\2\31 \7\13\2\2\32 \7\n\2\2\33\34\7\7\2\2"
          + "\34\35\5\6\4\2\35\36\7\3\2\2\36 \3\2\2\2\37\30\3\2\2\2\37\32\3\2\2\2\37"
          + "\33\3\2\2\2 )\3\2\2\2!\"\6\4\2\3\"#\t\2\2\2#(\5\6\4\2$%\6\4\3\3%&\t\3"
          + "\2\2&(\5\6\4\2\'!\3\2\2\2\'$\3\2\2\2(+\3\2\2\2)\'\3\2\2\2)*\3\2\2\2*\7"
          + "\3\2\2\2+)\3\2\2\2\7\13\26\37\')";
  public static final ATN _ATN = ATNSimulator.deserialize(_serializedATN.toCharArray());

  static {
    _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
    for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
      _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
    }
  }
}
Exemplo n.º 4
0
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class CymbolParser extends Parser {
  protected static final DFA[] _decisionToDFA;
  protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache();
  public static final int T__20 = 1,
      T__19 = 2,
      T__18 = 3,
      T__17 = 4,
      T__16 = 5,
      T__15 = 6,
      T__14 = 7,
      T__13 = 8,
      T__12 = 9,
      T__11 = 10,
      T__10 = 11,
      T__9 = 12,
      T__8 = 13,
      T__7 = 14,
      T__6 = 15,
      T__5 = 16,
      T__4 = 17,
      T__3 = 18,
      T__2 = 19,
      T__1 = 20,
      T__0 = 21,
      ID = 22,
      INT = 23,
      WS = 24,
      SL_COMMENT = 25;
  public static final String[] tokenNames = {
    "<INVALID>",
    "']'",
    "')'",
    "','",
    "'+'",
    "'['",
    "'-'",
    "'*'",
    "'('",
    "'if'",
    "'int'",
    "'='",
    "'return'",
    "';'",
    "'void'",
    "'{'",
    "'then'",
    "'else'",
    "'=='",
    "'}'",
    "'float'",
    "'!'",
    "ID",
    "INT",
    "WS",
    "SL_COMMENT"
  };
  public static final int RULE_file = 0,
      RULE_varDecl = 1,
      RULE_type = 2,
      RULE_functionDecl = 3,
      RULE_formalParameters = 4,
      RULE_formalParameter = 5,
      RULE_block = 6,
      RULE_stat = 7,
      RULE_expr = 8,
      RULE_exprList = 9;
  public static final String[] ruleNames = {
    "file",
    "varDecl",
    "type",
    "functionDecl",
    "formalParameters",
    "formalParameter",
    "block",
    "stat",
    "expr",
    "exprList"
  };

  @Override
  public String getGrammarFileName() {
    return "Cymbol.g4";
  }

  @Override
  public String[] getTokenNames() {
    return tokenNames;
  }

  @Override
  public String[] getRuleNames() {
    return ruleNames;
  }

  @Override
  public ATN getATN() {
    return _ATN;
  }

  public CymbolParser(TokenStream input) {
    super(input);
    _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
  }

  public static class FileContext extends ParserRuleContext {
    public FunctionDeclContext functionDecl(int i) {
      return getRuleContext(FunctionDeclContext.class, i);
    }

    public VarDeclContext varDecl(int i) {
      return getRuleContext(VarDeclContext.class, i);
    }

    public List<VarDeclContext> varDecl() {
      return getRuleContexts(VarDeclContext.class);
    }

    public List<FunctionDeclContext> functionDecl() {
      return getRuleContexts(FunctionDeclContext.class);
    }

    public FileContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_file;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterFile(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitFile(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitFile(this);
      else return visitor.visitChildren(this);
    }
  }

  public final FileContext file() throws RecognitionException {
    FileContext _localctx = new FileContext(_ctx, getState());
    enterRule(_localctx, 0, RULE_file);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(22);
        _errHandler.sync(this);
        _la = _input.LA(1);
        do {
          {
            setState(22);
            switch (getInterpreter().adaptivePredict(_input, 0, _ctx)) {
              case 1:
                {
                  setState(20);
                  functionDecl();
                }
                break;

              case 2:
                {
                  setState(21);
                  varDecl();
                }
                break;
            }
          }
          setState(24);
          _errHandler.sync(this);
          _la = _input.LA(1);
        } while ((((_la) & ~0x3f) == 0
            && ((1L << _la) & ((1L << 10) | (1L << 14) | (1L << 20))) != 0));
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class VarDeclContext extends ParserRuleContext {
    public TerminalNode ID() {
      return getToken(CymbolParser.ID, 0);
    }

    public ExprContext expr() {
      return getRuleContext(ExprContext.class, 0);
    }

    public TypeContext type() {
      return getRuleContext(TypeContext.class, 0);
    }

    public VarDeclContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_varDecl;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterVarDecl(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitVarDecl(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitVarDecl(this);
      else return visitor.visitChildren(this);
    }
  }

  public final VarDeclContext varDecl() throws RecognitionException {
    VarDeclContext _localctx = new VarDeclContext(_ctx, getState());
    enterRule(_localctx, 2, RULE_varDecl);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(26);
        type();
        setState(27);
        match(ID);
        setState(30);
        _la = _input.LA(1);
        if (_la == 11) {
          {
            setState(28);
            match(11);
            setState(29);
            expr(0);
          }
        }

        setState(32);
        match(13);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class TypeContext extends ParserRuleContext {
    public TypeContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_type;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterType(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitType(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitType(this);
      else return visitor.visitChildren(this);
    }
  }

  public final TypeContext type() throws RecognitionException {
    TypeContext _localctx = new TypeContext(_ctx, getState());
    enterRule(_localctx, 4, RULE_type);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(34);
        _la = _input.LA(1);
        if (!((((_la) & ~0x3f) == 0
            && ((1L << _la) & ((1L << 10) | (1L << 14) | (1L << 20))) != 0))) {
          _errHandler.recoverInline(this);
        }
        consume();
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class FunctionDeclContext extends ParserRuleContext {
    public FormalParametersContext formalParameters() {
      return getRuleContext(FormalParametersContext.class, 0);
    }

    public TerminalNode ID() {
      return getToken(CymbolParser.ID, 0);
    }

    public BlockContext block() {
      return getRuleContext(BlockContext.class, 0);
    }

    public TypeContext type() {
      return getRuleContext(TypeContext.class, 0);
    }

    public FunctionDeclContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_functionDecl;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterFunctionDecl(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitFunctionDecl(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitFunctionDecl(this);
      else return visitor.visitChildren(this);
    }
  }

  public final FunctionDeclContext functionDecl() throws RecognitionException {
    FunctionDeclContext _localctx = new FunctionDeclContext(_ctx, getState());
    enterRule(_localctx, 6, RULE_functionDecl);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(36);
        type();
        setState(37);
        match(ID);
        setState(38);
        match(8);
        setState(39);
        formalParameters();
        setState(40);
        match(2);
        setState(41);
        block();
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class FormalParametersContext extends ParserRuleContext {
    public FormalParameterContext formalParameter(int i) {
      return getRuleContext(FormalParameterContext.class, i);
    }

    public List<FormalParameterContext> formalParameter() {
      return getRuleContexts(FormalParameterContext.class);
    }

    public FormalParametersContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_formalParameters;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener)
        ((CymbolListener) listener).enterFormalParameters(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener)
        ((CymbolListener) listener).exitFormalParameters(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitFormalParameters(this);
      else return visitor.visitChildren(this);
    }
  }

  public final FormalParametersContext formalParameters() throws RecognitionException {
    FormalParametersContext _localctx = new FormalParametersContext(_ctx, getState());
    enterRule(_localctx, 8, RULE_formalParameters);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(43);
        formalParameter();
        setState(48);
        _errHandler.sync(this);
        _la = _input.LA(1);
        while (_la == 3) {
          {
            {
              setState(44);
              match(3);
              setState(45);
              formalParameter();
            }
          }
          setState(50);
          _errHandler.sync(this);
          _la = _input.LA(1);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class FormalParameterContext extends ParserRuleContext {
    public TerminalNode ID() {
      return getToken(CymbolParser.ID, 0);
    }

    public TypeContext type() {
      return getRuleContext(TypeContext.class, 0);
    }

    public FormalParameterContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_formalParameter;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener)
        ((CymbolListener) listener).enterFormalParameter(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitFormalParameter(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitFormalParameter(this);
      else return visitor.visitChildren(this);
    }
  }

  public final FormalParameterContext formalParameter() throws RecognitionException {
    FormalParameterContext _localctx = new FormalParameterContext(_ctx, getState());
    enterRule(_localctx, 10, RULE_formalParameter);
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(51);
        type();
        setState(52);
        match(ID);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class BlockContext extends ParserRuleContext {
    public StatContext stat(int i) {
      return getRuleContext(StatContext.class, i);
    }

    public List<StatContext> stat() {
      return getRuleContexts(StatContext.class);
    }

    public BlockContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_block;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterBlock(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitBlock(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitBlock(this);
      else return visitor.visitChildren(this);
    }
  }

  public final BlockContext block() throws RecognitionException {
    BlockContext _localctx = new BlockContext(_ctx, getState());
    enterRule(_localctx, 12, RULE_block);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(54);
        match(15);
        setState(58);
        _errHandler.sync(this);
        _la = _input.LA(1);
        while ((((_la) & ~0x3f) == 0
            && ((1L << _la)
                    & ((1L << 6)
                        | (1L << 8)
                        | (1L << 9)
                        | (1L << 10)
                        | (1L << 12)
                        | (1L << 14)
                        | (1L << 15)
                        | (1L << 20)
                        | (1L << 21)
                        | (1L << ID)
                        | (1L << INT)))
                != 0)) {
          {
            {
              setState(55);
              stat();
            }
          }
          setState(60);
          _errHandler.sync(this);
          _la = _input.LA(1);
        }
        setState(61);
        match(19);
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class StatContext extends ParserRuleContext {
    public StatContext stat(int i) {
      return getRuleContext(StatContext.class, i);
    }

    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public VarDeclContext varDecl() {
      return getRuleContext(VarDeclContext.class, 0);
    }

    public BlockContext block() {
      return getRuleContext(BlockContext.class, 0);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public List<StatContext> stat() {
      return getRuleContexts(StatContext.class);
    }

    public StatContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_stat;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterStat(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitStat(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitStat(this);
      else return visitor.visitChildren(this);
    }
  }

  public final StatContext stat() throws RecognitionException {
    StatContext _localctx = new StatContext(_ctx, getState());
    enterRule(_localctx, 14, RULE_stat);
    int _la;
    try {
      setState(86);
      switch (getInterpreter().adaptivePredict(_input, 7, _ctx)) {
        case 1:
          enterOuterAlt(_localctx, 1);
          {
            setState(63);
            block();
          }
          break;

        case 2:
          enterOuterAlt(_localctx, 2);
          {
            setState(64);
            varDecl();
          }
          break;

        case 3:
          enterOuterAlt(_localctx, 3);
          {
            setState(65);
            match(9);
            setState(66);
            expr(0);
            setState(67);
            match(16);
            setState(68);
            stat();
            setState(71);
            switch (getInterpreter().adaptivePredict(_input, 5, _ctx)) {
              case 1:
                {
                  setState(69);
                  match(17);
                  setState(70);
                  stat();
                }
                break;
            }
          }
          break;

        case 4:
          enterOuterAlt(_localctx, 4);
          {
            setState(73);
            match(12);
            setState(75);
            _la = _input.LA(1);
            if ((((_la) & ~0x3f) == 0
                && ((1L << _la) & ((1L << 6) | (1L << 8) | (1L << 21) | (1L << ID) | (1L << INT)))
                    != 0)) {
              {
                setState(74);
                expr(0);
              }
            }

            setState(77);
            match(13);
          }
          break;

        case 5:
          enterOuterAlt(_localctx, 5);
          {
            setState(78);
            expr(0);
            setState(79);
            match(11);
            setState(80);
            expr(0);
            setState(81);
            match(13);
          }
          break;

        case 6:
          enterOuterAlt(_localctx, 6);
          {
            setState(83);
            expr(0);
            setState(84);
            match(13);
          }
          break;
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public static class ExprContext extends ParserRuleContext {
    public int _p;

    public ExprContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    public ExprContext(ParserRuleContext parent, int invokingState, int _p) {
      super(parent, invokingState);
      this._p = _p;
    }

    @Override
    public int getRuleIndex() {
      return RULE_expr;
    }

    public ExprContext() {}

    public void copyFrom(ExprContext ctx) {
      super.copyFrom(ctx);
      this._p = ctx._p;
    }
  }

  public static class MultContext extends ExprContext {
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public MultContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterMult(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitMult(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitMult(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class ParensContext extends ExprContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class, 0);
    }

    public ParensContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterParens(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitParens(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitParens(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class IndexContext extends ExprContext {
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public IndexContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterIndex(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitIndex(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitIndex(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class CallContext extends ExprContext {
    public TerminalNode ID() {
      return getToken(CymbolParser.ID, 0);
    }

    public ExprListContext exprList() {
      return getRuleContext(ExprListContext.class, 0);
    }

    public CallContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterCall(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitCall(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitCall(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class AddSubContext extends ExprContext {
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public AddSubContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterAddSub(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitAddSub(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitAddSub(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class EqualContext extends ExprContext {
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public EqualContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterEqual(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitEqual(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitEqual(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class NegateContext extends ExprContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class, 0);
    }

    public NegateContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterNegate(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitNegate(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitNegate(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class VarContext extends ExprContext {
    public TerminalNode ID() {
      return getToken(CymbolParser.ID, 0);
    }

    public VarContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterVar(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitVar(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitVar(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class IntContext extends ExprContext {
    public TerminalNode INT() {
      return getToken(CymbolParser.INT, 0);
    }

    public IntContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterInt(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitInt(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitInt(this);
      else return visitor.visitChildren(this);
    }
  }

  public static class NotContext extends ExprContext {
    public ExprContext expr() {
      return getRuleContext(ExprContext.class, 0);
    }

    public NotContext(ExprContext ctx) {
      copyFrom(ctx);
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterNot(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitNot(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitNot(this);
      else return visitor.visitChildren(this);
    }
  }

  public final ExprContext expr(int _p) throws RecognitionException {
    ParserRuleContext _parentctx = _ctx;
    int _parentState = getState();
    ExprContext _localctx = new ExprContext(_ctx, _parentState, _p);
    ExprContext _prevctx = _localctx;
    int _startState = 16;
    enterRecursionRule(_localctx, RULE_expr);
    int _la;
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
        setState(105);
        switch (getInterpreter().adaptivePredict(_input, 9, _ctx)) {
          case 1:
            {
              _localctx = new NegateContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;

              setState(89);
              match(6);
              setState(90);
              expr(8);
            }
            break;

          case 2:
            {
              _localctx = new NotContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(91);
              match(21);
              setState(92);
              expr(7);
            }
            break;

          case 3:
            {
              _localctx = new CallContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(93);
              match(ID);
              setState(94);
              match(8);
              setState(96);
              _la = _input.LA(1);
              if ((((_la) & ~0x3f) == 0
                  && ((1L << _la) & ((1L << 6) | (1L << 8) | (1L << 21) | (1L << ID) | (1L << INT)))
                      != 0)) {
                {
                  setState(95);
                  exprList();
                }
              }

              setState(98);
              match(2);
            }
            break;

          case 4:
            {
              _localctx = new VarContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(99);
              match(ID);
            }
            break;

          case 5:
            {
              _localctx = new IntContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(100);
              match(INT);
            }
            break;

          case 6:
            {
              _localctx = new ParensContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(101);
              match(8);
              setState(102);
              expr(0);
              setState(103);
              match(2);
            }
            break;
        }
        _ctx.stop = _input.LT(-1);
        setState(123);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input, 11, _ctx);
        while (_alt != 2 && _alt != -1) {
          if (_alt == 1) {
            if (_parseListeners != null) triggerExitRuleEvent();
            _prevctx = _localctx;
            {
              setState(121);
              switch (getInterpreter().adaptivePredict(_input, 10, _ctx)) {
                case 1:
                  {
                    _localctx = new MultContext(new ExprContext(_parentctx, _parentState, _p));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(107);
                    if (!(6 >= _localctx._p)) throw new FailedPredicateException(this, "6 >= $_p");
                    setState(108);
                    match(7);
                    setState(109);
                    expr(7);
                  }
                  break;

                case 2:
                  {
                    _localctx = new AddSubContext(new ExprContext(_parentctx, _parentState, _p));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(110);
                    if (!(5 >= _localctx._p)) throw new FailedPredicateException(this, "5 >= $_p");
                    setState(111);
                    _la = _input.LA(1);
                    if (!(_la == 4 || _la == 6)) {
                      _errHandler.recoverInline(this);
                    }
                    consume();
                    setState(112);
                    expr(6);
                  }
                  break;

                case 3:
                  {
                    _localctx = new EqualContext(new ExprContext(_parentctx, _parentState, _p));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(113);
                    if (!(4 >= _localctx._p)) throw new FailedPredicateException(this, "4 >= $_p");
                    setState(114);
                    match(18);
                    setState(115);
                    expr(5);
                  }
                  break;

                case 4:
                  {
                    _localctx = new IndexContext(new ExprContext(_parentctx, _parentState, _p));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(116);
                    if (!(9 >= _localctx._p)) throw new FailedPredicateException(this, "9 >= $_p");
                    setState(117);
                    match(5);
                    setState(118);
                    expr(0);
                    setState(119);
                    match(1);
                  }
                  break;
              }
            }
          }
          setState(125);
          _errHandler.sync(this);
          _alt = getInterpreter().adaptivePredict(_input, 11, _ctx);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      unrollRecursionContexts(_parentctx);
    }
    return _localctx;
  }

  public static class ExprListContext extends ParserRuleContext {
    public ExprContext expr(int i) {
      return getRuleContext(ExprContext.class, i);
    }

    public List<ExprContext> expr() {
      return getRuleContexts(ExprContext.class);
    }

    public ExprListContext(ParserRuleContext parent, int invokingState) {
      super(parent, invokingState);
    }

    @Override
    public int getRuleIndex() {
      return RULE_exprList;
    }

    @Override
    public void enterRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).enterExprList(this);
    }

    @Override
    public void exitRule(ParseTreeListener listener) {
      if (listener instanceof CymbolListener) ((CymbolListener) listener).exitExprList(this);
    }

    @Override
    public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
      if (visitor instanceof CymbolVisitor)
        return ((CymbolVisitor<? extends T>) visitor).visitExprList(this);
      else return visitor.visitChildren(this);
    }
  }

  public final ExprListContext exprList() throws RecognitionException {
    ExprListContext _localctx = new ExprListContext(_ctx, getState());
    enterRule(_localctx, 18, RULE_exprList);
    int _la;
    try {
      enterOuterAlt(_localctx, 1);
      {
        setState(126);
        expr(0);
        setState(131);
        _errHandler.sync(this);
        _la = _input.LA(1);
        while (_la == 3) {
          {
            {
              setState(127);
              match(3);
              setState(128);
              expr(0);
            }
          }
          setState(133);
          _errHandler.sync(this);
          _la = _input.LA(1);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      exitRule();
    }
    return _localctx;
  }

  public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
    switch (ruleIndex) {
      case 8:
        return expr_sempred((ExprContext) _localctx, predIndex);
    }
    return true;
  }

  private boolean expr_sempred(ExprContext _localctx, int predIndex) {
    switch (predIndex) {
      case 0:
        return 6 >= _localctx._p;

      case 1:
        return 5 >= _localctx._p;

      case 2:
        return 4 >= _localctx._p;

      case 3:
        return 9 >= _localctx._p;
    }
    return true;
  }

  public static final String _serializedATN =
      "\2\3\33\u0089\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b"
          + "\4\t\t\t\4\n\t\n\4\13\t\13\3\2\3\2\6\2\31\n\2\r\2\16\2\32\3\3\3\3\3\3"
          + "\3\3\5\3!\n\3\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6"
          + "\7\6\61\n\6\f\6\16\6\64\13\6\3\7\3\7\3\7\3\b\3\b\7\b;\n\b\f\b\16\b>\13"
          + "\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\5\tJ\n\t\3\t\3\t\5\tN\n\t\3"
          + "\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\5\tY\n\t\3\n\3\n\3\n\3\n\3\n\3\n\3"
          + "\n\3\n\5\nc\n\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\5\nl\n\n\3\n\3\n\3\n\3\n\3"
          + "\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\7\n|\n\n\f\n\16\n\177\13\n\3\13"
          + "\3\13\3\13\7\13\u0084\n\13\f\13\16\13\u0087\13\13\3\13\2\f\2\4\6\b\n\f"
          + "\16\20\22\24\2\4\5\f\f\20\20\26\26\4\6\6\b\b\u0095\2\30\3\2\2\2\4\34\3"
          + "\2\2\2\6$\3\2\2\2\b&\3\2\2\2\n-\3\2\2\2\f\65\3\2\2\2\168\3\2\2\2\20X\3"
          + "\2\2\2\22k\3\2\2\2\24\u0080\3\2\2\2\26\31\5\b\5\2\27\31\5\4\3\2\30\26"
          + "\3\2\2\2\30\27\3\2\2\2\31\32\3\2\2\2\32\30\3\2\2\2\32\33\3\2\2\2\33\3"
          + "\3\2\2\2\34\35\5\6\4\2\35 \7\30\2\2\36\37\7\r\2\2\37!\5\22\n\2 \36\3\2"
          + "\2\2 !\3\2\2\2!\"\3\2\2\2\"#\7\17\2\2#\5\3\2\2\2$%\t\2\2\2%\7\3\2\2\2"
          + "&\'\5\6\4\2\'(\7\30\2\2()\7\n\2\2)*\5\n\6\2*+\7\4\2\2+,\5\16\b\2,\t\3"
          + "\2\2\2-\62\5\f\7\2./\7\5\2\2/\61\5\f\7\2\60.\3\2\2\2\61\64\3\2\2\2\62"
          + "\60\3\2\2\2\62\63\3\2\2\2\63\13\3\2\2\2\64\62\3\2\2\2\65\66\5\6\4\2\66"
          + "\67\7\30\2\2\67\r\3\2\2\28<\7\21\2\29;\5\20\t\2:9\3\2\2\2;>\3\2\2\2<:"
          + "\3\2\2\2<=\3\2\2\2=?\3\2\2\2><\3\2\2\2?@\7\25\2\2@\17\3\2\2\2AY\5\16\b"
          + "\2BY\5\4\3\2CD\7\13\2\2DE\5\22\n\2EF\7\22\2\2FI\5\20\t\2GH\7\23\2\2HJ"
          + "\5\20\t\2IG\3\2\2\2IJ\3\2\2\2JY\3\2\2\2KM\7\16\2\2LN\5\22\n\2ML\3\2\2"
          + "\2MN\3\2\2\2NO\3\2\2\2OY\7\17\2\2PQ\5\22\n\2QR\7\r\2\2RS\5\22\n\2ST\7"
          + "\17\2\2TY\3\2\2\2UV\5\22\n\2VW\7\17\2\2WY\3\2\2\2XA\3\2\2\2XB\3\2\2\2"
          + "XC\3\2\2\2XK\3\2\2\2XP\3\2\2\2XU\3\2\2\2Y\21\3\2\2\2Z[\b\n\1\2[\\\7\b"
          + "\2\2\\l\5\22\n\2]^\7\27\2\2^l\5\22\n\2_`\7\30\2\2`b\7\n\2\2ac\5\24\13"
          + "\2ba\3\2\2\2bc\3\2\2\2cd\3\2\2\2dl\7\4\2\2el\7\30\2\2fl\7\31\2\2gh\7\n"
          + "\2\2hi\5\22\n\2ij\7\4\2\2jl\3\2\2\2kZ\3\2\2\2k]\3\2\2\2k_\3\2\2\2ke\3"
          + "\2\2\2kf\3\2\2\2kg\3\2\2\2l}\3\2\2\2mn\6\n\2\3no\7\t\2\2o|\5\22\n\2pq"
          + "\6\n\3\3qr\t\3\2\2r|\5\22\n\2st\6\n\4\3tu\7\24\2\2u|\5\22\n\2vw\6\n\5"
          + "\3wx\7\7\2\2xy\5\22\n\2yz\7\3\2\2z|\3\2\2\2{m\3\2\2\2{p\3\2\2\2{s\3\2"
          + "\2\2{v\3\2\2\2|\177\3\2\2\2}{\3\2\2\2}~\3\2\2\2~\23\3\2\2\2\177}\3\2\2"
          + "\2\u0080\u0085\5\22\n\2\u0081\u0082\7\5\2\2\u0082\u0084\5\22\n\2\u0083"
          + "\u0081\3\2\2\2\u0084\u0087\3\2\2\2\u0085\u0083\3\2\2\2\u0085\u0086\3\2"
          + "\2\2\u0086\25\3\2\2\2\u0087\u0085\3\2\2\2\17\30\32 \62<IMXbk{}\u0085";
  public static final ATN _ATN = ATNSimulator.deserialize(_serializedATN.toCharArray());

  static {
    _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
  }
}