Beispiel #1
0
            public override bool VisitMnemonic_body(Mnemonic_bodyContext context)
            {
                //命令語は命令語で解析
                if (!InstructionAnalyzer.TryAnalyze(context.instruction(), out var instInfo))
                {
                    return(false);
                }

                //オペランドはオペランドで解析
                var opeInfoList =
                    context.operand()
                    .Select(ope => (success: OperandAnalyzer.TryAnalyze(_env, ope, out var info), info))
                    .Where(x => x.success)
                    .Select(x => x.info)
                    .ToArray();

                if (opeInfoList.Length != context.operand().Length)
                {
                    return(false);
                }

                //両方解析できたら命令語実行
                instInfo.Execute(_env, opeInfoList);

                return(true);
            }
    public Mnemonic_bodyContext mnemonic_body()
    {
        Mnemonic_bodyContext _localctx = new Mnemonic_bodyContext(Context, State);

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

        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 22; instruction();
                State = 27;
                ErrorHandler.Sync(this);
                _la = TokenStream.LA(1);
                while (_la == WS)
                {
                    {
                        {
                            State = 23; Match(WS);
                            State = 24; operand(0);
                        }
                    }
                    State = 29;
                    ErrorHandler.Sync(this);
                    _la = TokenStream.LA(1);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }