Beispiel #1
0
        public ExpresionContext expresion()
        {
            ExpresionContext _localctx = new ExpresionContext(Context, State);

            EnterRule(_localctx, 12, RULE_expresion);
            int _la;

            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 77;
                    _la   = TokenStream.LA(1);
                    if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << BOOLEAN) | (1L << VARIABLE) | (1L << NUMERO))) != 0)))
                    {
                        ErrorHandler.RecoverInline(this);
                    }
                    else
                    {
                        ErrorHandler.ReportMatch(this);
                        Consume();
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
        public ExpresionContext expresion()
        {
            ExpresionContext _localctx = new ExpresionContext(_ctx, State);

            EnterRule(_localctx, 4, RULE_expresion);
            int _la;

            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State           = 20; _localctx.a = multiplicacion();
                    _localctx.value = _localctx.a.value;
                    State           = 32;
                    _errHandler.Sync(this);
                    _la = _input.La(1);
                    while (_la == MAS || _la == MENOS)
                    {
                        {
                            State = 30;
                            _errHandler.Sync(this);
                            switch (_input.La(1))
                            {
                            case MAS:
                            {
                                State           = 22; Match(MAS);
                                State           = 23; _localctx.b = multiplicacion();
                                _localctx.value = _localctx.value + _localctx.b.value;
                            }
                            break;

                            case MENOS:
                            {
                                State           = 26; Match(MENOS);
                                State           = 27; _localctx.b = multiplicacion();
                                _localctx.value = _localctx.value - _localctx.b.value;
                            }
                            break;

                            default:
                                throw new NoViableAltException(this);
                            }
                        }
                        State = 34;
                        _errHandler.Sync(this);
                        _la = _input.La(1);
                    }
                    System.Console.WriteLine(_localctx.value);
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }