Пример #1
0
 public override void ExitFalse([NotNull] FalseContext context)
 {
     base.ExitFalse(context);
     Log("ExitFalse");
     if (phase == Phase.Building)
     {
         symbolTableCreator.ExitFalse(context);
     }
     else
     {
         symbolTableTraverser.ExitFalse(context);
         semanticErrorChecker.ExitFalse(context);
     }
 }
Пример #2
0
    private TermContext term(int _p)
    {
        ParserRuleContext _parentctx = Context;
        int         _parentState     = State;
        TermContext _localctx        = new TermContext(Context, _parentState);
        TermContext _prevctx         = _localctx;
        int         _startState      = 6;

        EnterRecursionRule(_localctx, 6, RULE_term, _p);
        try {
            int _alt;
            EnterOuterAlt(_localctx, 1);
            {
                State = 53;
                ErrorHandler.Sync(this);
                switch (TokenStream.LA(1))
                {
                case T__1:
                {
                    _localctx = new ParContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;

                    State = 25; Match(T__1);
                    State = 26; term(0);
                    State = 27; Match(T__2);
                }
                break;

                case VAR:
                {
                    _localctx = new VarContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 29; Match(VAR);
                }
                break;

                case T__3:
                {
                    _localctx = new IftContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 30; Match(T__3);
                    State     = 31; term(0);
                    State     = 32; Match(T__4);
                    State     = 33; term(0);
                    State     = 34; Match(T__5);
                    State     = 35; term(5);
                }
                break;

                case T__6:
                {
                    _localctx = new TrueContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 37; Match(T__6);
                }
                break;

                case T__7:
                {
                    _localctx = new FalseContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 38; Match(T__7);
                }
                break;

                case T__8:
                {
                    _localctx = new LetContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 39; Match(T__8);
                    State     = 40; Match(VAR);
                    State     = 41; Match(T__9);
                    State     = 42; term(0);
                    State     = 43; Match(T__10);
                    State     = 44; term(2);
                }
                break;

                case LAMBDA:
                {
                    _localctx = new AbsContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 46; Match(LAMBDA);
                    State     = 47; Match(VAR);
                    State     = 48; Match(T__11);
                    State     = 49; type(0);
                    State     = 50; Match(DOT);
                    State     = 51; term(1);
                }
                break;

                default:
                    throw new NoViableAltException(this);
                }
                Context.Stop = TokenStream.LT(-1);
                State        = 59;
                ErrorHandler.Sync(this);
                _alt = Interpreter.AdaptivePredict(TokenStream, 3, Context);
                while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER)
                {
                    if (_alt == 1)
                    {
                        if (ParseListeners != null)
                        {
                            TriggerExitRuleEvent();
                        }
                        _prevctx = _localctx;
                        {
                            {
                                _localctx = new AppContext(new TermContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_term);
                                State = 55;
                                if (!(Precpred(Context, 6)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 6)");
                                }
                                State = 56; term(7);
                            }
                        }
                    }
                    State = 61;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 3, Context);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            UnrollRecursionContexts(_parentctx);
        }
        return(_localctx);
    }
Пример #3
0
    public TermContext term()
    {
        TermContext _localctx = new TermContext(Context, State);

        EnterRule(_localctx, 0, RULE_term);
        try {
            State = 26;
            ErrorHandler.Sync(this);
            switch (TokenStream.LA(1))
            {
            case T__0:
                _localctx = new ParContext(_localctx);
                EnterOuterAlt(_localctx, 1);
                {
                    State = 6; Match(T__0);
                    State = 7; term();
                    State = 8; Match(T__1);
                }
                break;

            case IF:
                _localctx = new IfThenElseContext(_localctx);
                EnterOuterAlt(_localctx, 2);
                {
                    State = 10; Match(IF);
                    State = 11; term();
                    State = 12; Match(THEN);
                    State = 13; term();
                    State = 14; Match(ELSE);
                    State = 15; term();
                }
                break;

            case SUCC:
                _localctx = new SuccContext(_localctx);
                EnterOuterAlt(_localctx, 3);
                {
                    State = 17; Match(SUCC);
                    State = 18; term();
                }
                break;

            case PRED:
                _localctx = new PredContext(_localctx);
                EnterOuterAlt(_localctx, 4);
                {
                    State = 19; Match(PRED);
                    State = 20; term();
                }
                break;

            case ISZERO:
                _localctx = new IsZeroContext(_localctx);
                EnterOuterAlt(_localctx, 5);
                {
                    State = 21; Match(ISZERO);
                    State = 22; term();
                }
                break;

            case TRUE:
                _localctx = new TrueContext(_localctx);
                EnterOuterAlt(_localctx, 6);
                {
                    State = 23; Match(TRUE);
                }
                break;

            case FALSE:
                _localctx = new FalseContext(_localctx);
                EnterOuterAlt(_localctx, 7);
                {
                    State = 24; Match(FALSE);
                }
                break;

            case ZERO:
                _localctx = new ZeroContext(_localctx);
                EnterOuterAlt(_localctx, 8);
                {
                    State = 25; Match(ZERO);
                }
                break;

            default:
                throw new NoViableAltException(this);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }