예제 #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);
            }
예제 #2
0
        public Instruction GetInstruction()
        {
            var instructionData   = new ParserInstructionData();
            var returnInstruction = instructionData.GetOpcode(InstructionString);

            returnInstruction.InstructionString = InstructionString;

            SplitInstruction(returnInstruction);

            var analyzer = new OperandAnalyzer(returnInstruction);

            returnInstruction = analyzer.GetOperands();

            return(returnInstruction);
        }