Exemple #1
0
  private ExprContext expr(int _p) throws RecognitionException {
    ParserRuleContext _parentctx = _ctx;
    int _parentState = getState();
    ExprContext _localctx = new ExprContext(_ctx, _parentState);
    ExprContext _prevctx = _localctx;
    int _startState = 16;
    enterRecursionRule(_localctx, 16, RULE_expr, _p);
    int _la;
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
        setState(107);
        switch (getInterpreter().adaptivePredict(_input, 10, _ctx)) {
          case 1:
            {
              _localctx = new NegateContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;

              setState(91);
              match(T__13);
              setState(92);
              expr(8);
            }
            break;
          case 2:
            {
              _localctx = new NotContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(93);
              match(T__14);
              setState(94);
              expr(7);
            }
            break;
          case 3:
            {
              _localctx = new CallContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(95);
              match(ID);
              setState(96);
              match(T__2);
              setState(98);
              _la = _input.LA(1);
              if ((((_la) & ~0x3f) == 0
                  && ((1L << _la)
                          & ((1L << T__2)
                              | (1L << T__13)
                              | (1L << T__14)
                              | (1L << ID)
                              | (1L << INT)))
                      != 0)) {
                {
                  setState(97);
                  exprList();
                }
              }

              setState(100);
              match(T__3);
            }
            break;
          case 4:
            {
              _localctx = new VarContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(101);
              match(ID);
            }
            break;
          case 5:
            {
              _localctx = new IntContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(102);
              match(INT);
            }
            break;
          case 6:
            {
              _localctx = new ParensContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(103);
              match(T__2);
              setState(104);
              expr(0);
              setState(105);
              match(T__3);
            }
            break;
        }
        _ctx.stop = _input.LT(-1);
        setState(125);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input, 12, _ctx);
        while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) {
          if (_alt == 1) {
            if (_parseListeners != null) triggerExitRuleEvent();
            _prevctx = _localctx;
            {
              setState(123);
              switch (getInterpreter().adaptivePredict(_input, 11, _ctx)) {
                case 1:
                  {
                    _localctx = new MultContext(new ExprContext(_parentctx, _parentState));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(109);
                    if (!(precpred(_ctx, 6)))
                      throw new FailedPredicateException(this, "precpred(_ctx, 6)");
                    setState(110);
                    match(T__15);
                    setState(111);
                    expr(7);
                  }
                  break;
                case 2:
                  {
                    _localctx = new AddSubContext(new ExprContext(_parentctx, _parentState));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(112);
                    if (!(precpred(_ctx, 5)))
                      throw new FailedPredicateException(this, "precpred(_ctx, 5)");
                    setState(113);
                    _la = _input.LA(1);
                    if (!(_la == T__13 || _la == T__16)) {
                      _errHandler.recoverInline(this);
                    } else {
                      consume();
                    }
                    setState(114);
                    expr(6);
                  }
                  break;
                case 3:
                  {
                    _localctx = new EqualContext(new ExprContext(_parentctx, _parentState));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(115);
                    if (!(precpred(_ctx, 4)))
                      throw new FailedPredicateException(this, "precpred(_ctx, 4)");
                    setState(116);
                    match(T__17);
                    setState(117);
                    expr(5);
                  }
                  break;
                case 4:
                  {
                    _localctx = new IndexContext(new ExprContext(_parentctx, _parentState));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(118);
                    if (!(precpred(_ctx, 9)))
                      throw new FailedPredicateException(this, "precpred(_ctx, 9)");
                    setState(119);
                    match(T__11);
                    setState(120);
                    expr(0);
                    setState(121);
                    match(T__12);
                  }
                  break;
              }
            }
          }
          setState(127);
          _errHandler.sync(this);
          _alt = getInterpreter().adaptivePredict(_input, 12, _ctx);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      unrollRecursionContexts(_parentctx);
    }
    return _localctx;
  }
Exemple #2
0
  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;
  }
Exemple #3
0
  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;
  }
  private ExprContext expr(int _p) throws RecognitionException {
    ParserRuleContext _parentctx = _ctx;
    int _parentState = getState();
    ExprContext _localctx = new ExprContext(_ctx, _parentState);
    ExprContext _prevctx = _localctx;
    int _startState = 6;
    enterRecursionRule(_localctx, 6, RULE_expr, _p);
    int _la;
    try {
      int _alt;
      enterOuterAlt(_localctx, 1);
      {
        setState(58);
        switch (_input.LA(1)) {
          case NUMBER:
            {
              _localctx = new NumContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;

              setState(53);
              match(NUMBER);
            }
            break;
          case ID:
            {
              _localctx = new IdContext(_localctx);
              _ctx = _localctx;
              _prevctx = _localctx;
              setState(54);
              match(ID);
              setState(56);
              switch (getInterpreter().adaptivePredict(_input, 4, _ctx)) {
                case 1:
                  {
                    setState(55);
                    formal();
                  }
                  break;
              }
            }
            break;
          default:
            throw new NoViableAltException(this);
        }
        _ctx.stop = _input.LT(-1);
        setState(68);
        _errHandler.sync(this);
        _alt = getInterpreter().adaptivePredict(_input, 7, _ctx);
        while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) {
          if (_alt == 1) {
            if (_parseListeners != null) triggerExitRuleEvent();
            _prevctx = _localctx;
            {
              setState(66);
              switch (getInterpreter().adaptivePredict(_input, 6, _ctx)) {
                case 1:
                  {
                    _localctx = new MulDivContext(new ExprContext(_parentctx, _parentState));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(60);
                    if (!(precpred(_ctx, 4)))
                      throw new FailedPredicateException(this, "precpred(_ctx, 4)");
                    setState(61);
                    ((MulDivContext) _localctx).op = _input.LT(1);
                    _la = _input.LA(1);
                    if (!(_la == MUL || _la == DIV)) {
                      ((MulDivContext) _localctx).op = (Token) _errHandler.recoverInline(this);
                    } else {
                      consume();
                    }
                    setState(62);
                    expr(5);
                  }
                  break;
                case 2:
                  {
                    _localctx = new AddSubContext(new ExprContext(_parentctx, _parentState));
                    pushNewRecursionContext(_localctx, _startState, RULE_expr);
                    setState(63);
                    if (!(precpred(_ctx, 3)))
                      throw new FailedPredicateException(this, "precpred(_ctx, 3)");
                    setState(64);
                    ((AddSubContext) _localctx).op = _input.LT(1);
                    _la = _input.LA(1);
                    if (!(_la == ADD || _la == SUB)) {
                      ((AddSubContext) _localctx).op = (Token) _errHandler.recoverInline(this);
                    } else {
                      consume();
                    }
                    setState(65);
                    expr(4);
                  }
                  break;
              }
            }
          }
          setState(70);
          _errHandler.sync(this);
          _alt = getInterpreter().adaptivePredict(_input, 7, _ctx);
        }
      }
    } catch (RecognitionException re) {
      _localctx.exception = re;
      _errHandler.reportError(this, re);
      _errHandler.recover(this, re);
    } finally {
      unrollRecursionContexts(_parentctx);
    }
    return _localctx;
  }