Assembler.Assembler.ParseInstruction C# (CSharp) Method

ParseInstruction() private method

private ParseInstruction ( ) : Instruction
return Instruction
        private Instruction ParseInstruction()
        {
            var t = tokens[pos++];

            Instructions type;
            if (!Enum.TryParse(t.Value, true, out type))
                throw new AssemblerException(string.Format("Expected opcode on line {0}.", t.Line));

            var operandCount = operandCounts[type];

            if (operandCount == 0)
                return new Instruction(type, null, null);

            Operand left = ParseOperand();

            if (operandCount == 1)
                return new Instruction(type, left, null);

            Require(TokenType.Comma);
            Operand right = ParseOperand();
            return new Instruction(type, left, right);
        }