コード例 #1
0
    public InstructionContext instruction()
    {
        InstructionContext _localctx = new InstructionContext(Context, State);

        EnterRule(_localctx, 14, RULE_instruction);
        try {
            State = 70;
            ErrorHandler.Sync(this);
            switch (TokenStream.LA(1))
            {
            case ID:
                _localctx = new ExpressionInstructionContext(_localctx);
                EnterOuterAlt(_localctx, 1);
                {
                    State = 60; Match(ID);
                    State = 61; Match(T__5);
                    State = 62; expression();
                }
                break;

            case T__6:
                _localctx = new ConditionalInstructionContext(_localctx);
                EnterOuterAlt(_localctx, 2);
                {
                    State = 63; Match(T__6);
                    State = 64; ((ConditionalInstructionContext)_localctx).var = Match(ID);
                    State = 65; Match(T__7);
                    State = 66; Match(T__8);
                    State = 67; Match(T__2);
                    State = 68; ((ConditionalInstructionContext)_localctx).label = Match(ID);
                }
                break;

            case T__2:
            case WORD:
                _localctx = new MacroInstructionContext(_localctx);
                EnterOuterAlt(_localctx, 3);
                {
                    State = 69; macro();
                }
                break;

            default:
                throw new NoViableAltException(this);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
コード例 #2
0
        public override void ExitConditionalInstruction([NotNull] ConditionalInstructionContext context)
        {
            base.ExitConditionalInstruction(context);

            var ids = context.ID();

            CheckValidVar(ids[0].Symbol);
            var targetLabel = ids[1].Symbol;

            CheckValidLabel(targetLabel);

            if (context.Parent is LabeledLineContext labeledLine)
            {
                CheckInfiniteLoop(labeledLine.label, targetLabel);
            }
        }