コード例 #1
0
        private static Instruction ToInstruction(Token token, TokenQueue tokens)
        {
            Func <Instruction> func = token.TokenType switch
            {
                TokenType.Number => () => new NumberInstruction(ushort.Parse(token.Value)),
                TokenType.WireName => () => new GetWireInstruction(token.Value),
                TokenType.Not => () =>
                {
                    var rightToken = tokens.GetNext();
                    return(new NotInstruction(new GetWireInstruction(rightToken.Value)));
                },
                _ => () => new NullInstruction()
            };

            return(func());
        }
    }
コード例 #2
0
        private static Instruction AssignInstruction(TokenQueue tokens, Instruction instruction)
        {
            var rightToken = tokens.GetNext();

            return(new AssignInstruction(instruction, new GetWireInstruction(rightToken.Value)));
        }
コード例 #3
0
        private static Instruction AndInstruction(TokenQueue tokens, Instruction instruction)
        {
            var rightToken = tokens.GetNext();

            return(new AndInstruction(instruction, ToInstruction(rightToken, tokens)));
        }
コード例 #4
0
        private static Instruction NotInstruction(TokenQueue tokens)
        {
            var rightToken = tokens.GetNext();

            return(new NotInstruction(ToInstruction(rightToken, tokens)));
        }
コード例 #5
0
        private static Instruction LShiftInstruction(TokenQueue tokens, Instruction instruction)
        {
            var rightToken = tokens.GetNext();

            return(new LeftShiftInstruction(instruction, ToInstruction(rightToken, tokens)));;
        }