private static ProgramInstruction ParseInstruction(ReadBuffer buffer) { buffer.SkipSpace(); String instructionField = ReadField(buffer); return(ProgramInstruction.Parse(instructionField)); }
private ProgramLine(String text, Label label, ProgramInstruction instruction, String errorMessage) { m_text = text; m_label = label; m_instruction = instruction; m_errorMessage = errorMessage; }
private static void ReadOperand(ProgramInstruction instruction, ReadBuffer buffer) { buffer.SkipSpace(); // ';' ならば、そのあとはコメントなので、オペランドとして解釈しない。 if (buffer.Current == Casl2Defs.Semicolon) { buffer.SkipToEnd(); } instruction.ReadOperand(buffer); }
// 命令行 // オペランドあり: [ラベル] {空白} {命令コード} {空白} {オペランド} [ {空白} [コメント]] // オペランドなし: [ラベル] {空白} {命令コード} [ {空白} [ {;} [コメント]]] 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)); }
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); }
private static ProgramLine MakeInstructionLine(String text, Label label, ProgramInstruction instruction) { return(new ProgramLine(text, label, instruction, null)); }