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()); } }
private static Instruction AssignInstruction(TokenQueue tokens, Instruction instruction) { var rightToken = tokens.GetNext(); return(new AssignInstruction(instruction, new GetWireInstruction(rightToken.Value))); }
private static Instruction AndInstruction(TokenQueue tokens, Instruction instruction) { var rightToken = tokens.GetNext(); return(new AndInstruction(instruction, ToInstruction(rightToken, tokens))); }
private static Instruction NotInstruction(TokenQueue tokens) { var rightToken = tokens.GetNext(); return(new NotInstruction(ToInstruction(rightToken, tokens))); }
private static Instruction LShiftInstruction(TokenQueue tokens, Instruction instruction) { var rightToken = tokens.GetNext(); return(new LeftShiftInstruction(instruction, ToInstruction(rightToken, tokens)));; }