コード例 #1
0
        private static ProgramInstruction ParseInstruction(ReadBuffer buffer)
        {
            buffer.SkipSpace();
            String instructionField = ReadField(buffer);

            return(ProgramInstruction.Parse(instructionField));
        }
コード例 #2
0
 private ProgramLine(String text, Label label, ProgramInstruction instruction, String errorMessage)
 {
     m_text         = text;
     m_label        = label;
     m_instruction  = instruction;
     m_errorMessage = errorMessage;
 }
コード例 #3
0
        private static void ReadOperand(ProgramInstruction instruction, ReadBuffer buffer)
        {
            buffer.SkipSpace();
            // ';' ならば、そのあとはコメントなので、オペランドとして解釈しない。
            if (buffer.Current == Casl2Defs.Semicolon)
            {
                buffer.SkipToEnd();
            }

            instruction.ReadOperand(buffer);
        }
コード例 #4
0
        // 命令行
        //   オペランドあり: [ラベル] {空白} {命令コード} {空白} {オペランド} [ {空白} [コメント]]
        //   オペランドなし: [ラベル] {空白} {命令コード} [ {空白} [ {;} [コメント]]]
        private static ProgramLine ParseInstructionLine(String text)
        {
            ReadBuffer buffer = new ReadBuffer(text);

            Label label = ParseLabel(buffer);
            ProgramInstruction instruction = ParseInstruction(buffer);

            ReadOperand(instruction, buffer);

            return(MakeInstructionLine(text, label, instruction));
        }
コード例 #5
0
        internal static ProgramInstruction Make(String instructionField)
        {
            if (instructionField.Length == 0)
            {
                String message = Resources.MSG_NoInstructionInInstructionLine;
                throw new Casl2SimulatorException(message);
            }

            if (!m_factoryMethodDictionary.ContainsKey(instructionField))
            {
                String message = String.Format(Resources.MSG_InstructionNotDefined, instructionField);
                throw new Casl2SimulatorException(message);
            }

            Func <ProgramInstruction> factoryMethod = m_factoryMethodDictionary[instructionField];
            ProgramInstruction        instruction   = factoryMethod();

            return(instruction);
        }
コード例 #6
0
 private static ProgramLine MakeInstructionLine(String text, Label label, ProgramInstruction instruction)
 {
     return(new ProgramLine(text, label, instruction, null));
 }