public MultExprContext multExpr()
        {
            MultExprContext _localctx = new MultExprContext(_ctx, State);

            EnterRule(_localctx, 14, RULE_multExpr);
            int _la;

            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 84; powerExpr();
                    State = 89;
                    _errHandler.Sync(this);
                    _la = _input.La(1);
                    while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << STAR) | (1L << SLASH) | (1L << PERCENT))) != 0))
                    {
                        {
                            {
                                State = 85;
                                _la   = _input.La(1);
                                if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << STAR) | (1L << SLASH) | (1L << PERCENT))) != 0)))
                                {
                                    _errHandler.RecoverInline(this);
                                }
                                else
                                {
                                    if (_input.La(1) == TokenConstants.Eof)
                                    {
                                        matchedEOF = true;
                                    }

                                    _errHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 86; powerExpr();
                            }
                        }
                        State = 91;
                        _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);
        }
Example #2
0
	private bool multExpr_sempred(MultExprContext _localctx, int predIndex) {
		switch (predIndex) {
		case 16: return Precpred(_ctx, 3);

		case 17: return Precpred(_ctx, 2);

		case 15: return Precpred(_ctx, 4);
		}
		return true;
	}
Example #3
0
	private MultExprContext multExpr(int _p) {
		ParserRuleContext _parentctx = _ctx;
		int _parentState = State;
		MultExprContext _localctx = new MultExprContext(_ctx, _parentState);
		MultExprContext _prevctx = _localctx;
		int _startState = 22;
		EnterRecursionRule(_localctx, 22, RULE_multExpr, _p);
		try {
			int _alt;
			EnterOuterAlt(_localctx, 1);
			{
			{
			State = 205; _localctx._unaryExpr = unaryExpr();
			 _localctx.retValue =  _localctx._unaryExpr.retValue;
			}
			_ctx.stop = _input.Lt(-1);
			State = 225;
			_errHandler.Sync(this);
			_alt = Interpreter.AdaptivePredict(_input,15,_ctx);
			while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) {
				if ( _alt==1 ) {
					if ( _parseListeners!=null ) TriggerExitRuleEvent();
					_prevctx = _localctx;
					{
					State = 223;
					switch ( Interpreter.AdaptivePredict(_input,14,_ctx) ) {
					case 1:
						{
						_localctx = new MultExprContext(_parentctx, _parentState);
						_localctx.first = _prevctx;
						PushNewRecursionContext(_localctx, _startState, RULE_multExpr);
						State = 208;
						if (!(Precpred(_ctx, 4))) throw new FailedPredicateException(this, "Precpred(_ctx, 4)");
						State = 209; Match(T__17);
						State = 210; _localctx._unaryExpr = unaryExpr();
						 _localctx.retValue =  new BinaryExpression(BinaryExpressionType.Times, _localctx.first.retValue, _localctx._unaryExpr.retValue);
						}
						break;

					case 2:
						{
						_localctx = new MultExprContext(_parentctx, _parentState);
						_localctx.first = _prevctx;
						PushNewRecursionContext(_localctx, _startState, RULE_multExpr);
						State = 213;
						if (!(Precpred(_ctx, 3))) throw new FailedPredicateException(this, "Precpred(_ctx, 3)");
						State = 214; Match(T__29);
						State = 215; _localctx._unaryExpr = unaryExpr();
						 _localctx.retValue =  new BinaryExpression(BinaryExpressionType.Div, _localctx.first.retValue, _localctx._unaryExpr.retValue);
						}
						break;

					case 3:
						{
						_localctx = new MultExprContext(_parentctx, _parentState);
						_localctx.first = _prevctx;
						PushNewRecursionContext(_localctx, _startState, RULE_multExpr);
						State = 218;
						if (!(Precpred(_ctx, 2))) throw new FailedPredicateException(this, "Precpred(_ctx, 2)");
						State = 219; Match(T__5);
						State = 220; _localctx._unaryExpr = unaryExpr();
						 _localctx.retValue =  new BinaryExpression(BinaryExpressionType.Modulo, _localctx.first.retValue, _localctx._unaryExpr.retValue);
						}
						break;
					}
					} 
				}
				State = 227;
				_errHandler.Sync(this);
				_alt = Interpreter.AdaptivePredict(_input,15,_ctx);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.ReportError(this, re);
			_errHandler.Recover(this, re);
		}
		finally {
			UnrollRecursionContexts(_parentctx);
		}
		return _localctx;
	}
Example #4
0
        private ExprContext expr(int _p)
        {
            ParserRuleContext _parentctx = _ctx;
            int         _parentState     = State;
            ExprContext _localctx        = new ExprContext(_ctx, _parentState);
            ExprContext _prevctx         = _localctx;
            int         _startState      = 4;

            EnterRecursionRule(_localctx, 4, RULE_expr, _p);
            int _la;

            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 29;
                    _errHandler.Sync(this);
                    switch (_input.La(1))
                    {
                    case INT:
                    {
                        _localctx = new IntContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;

                        State = 23; Match(INT);
                    }
                    break;

                    case ID:
                    {
                        _localctx = new IdentContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 24; Match(ID);
                    }
                    break;

                    case T__2:
                    {
                        _localctx = new ParensContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 25; Match(T__2);
                        State     = 26; expr(0);
                        State     = 27; Match(T__3);
                    }
                    break;

                    default:
                        throw new NoViableAltException(this);
                    }
                    _ctx.stop = _input.Lt(-1);
                    State     = 39;
                    _errHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(_input, 4, _ctx);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                    {
                        if (_alt == 1)
                        {
                            if (_parseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                State = 37;
                                _errHandler.Sync(this);
                                switch (Interpreter.AdaptivePredict(_input, 3, _ctx))
                                {
                                case 1:
                                {
                                    _localctx = new MultExprContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 31;
                                    if (!(Precpred(_ctx, 5)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 5)");
                                    }
                                    State = 32;
                                    ((MultExprContext)_localctx).op = _input.Lt(1);
                                    _la = _input.La(1);
                                    if (!(_la == MUL || _la == DIV))
                                    {
                                        ((MultExprContext)_localctx).op = _errHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        if (_input.La(1) == TokenConstants.Eof)
                                        {
                                            matchedEOF = true;
                                        }

                                        _errHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 33; expr(6);
                                }
                                break;

                                case 2:
                                {
                                    _localctx = new AddExprContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 34;
                                    if (!(Precpred(_ctx, 4)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 4)");
                                    }
                                    State = 35;
                                    ((AddExprContext)_localctx).op = _input.Lt(1);
                                    _la = _input.La(1);
                                    if (!(_la == ADD || _la == SUB))
                                    {
                                        ((AddExprContext)_localctx).op = _errHandler.RecoverInline(this);
                                    }
                                    else
                                    {
                                        if (_input.La(1) == TokenConstants.Eof)
                                        {
                                            matchedEOF = true;
                                        }

                                        _errHandler.ReportMatch(this);
                                        Consume();
                                    }
                                    State = 36; expr(5);
                                }
                                break;
                                }
                            }
                        }
                        State = 41;
                        _errHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(_input, 4, _ctx);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }