public override void RunInstruction(InterpreterState state) { if (state.GetCurrentValue() != 0) { state.CurrentInstruction = MatchingInstruction; Debug.WriteLine(Number + ": !0 Jumping to " + MatchingInstruction.Number); } }
static void Main() { string text = File.ReadAllText("fib.ook"); Microsoft.FSharp.Collections.List<string> instructions = Parser.parse(text); StringBuilder sb = new StringBuilder(); foreach (var inst in instructions) sb.AppendLine(inst); Console.WriteLine(sb.ToString()); File.WriteAllText("log.txt", sb.ToString()); LinkedList<Instruction> instructionList = CreateInstructionList(instructions); InterpreterState state = new InterpreterState(); state.AddInstructionList(instructionList); while(state.Done == false) { state.ExecuteNextInstruction(); } Console.ReadKey(); }
public abstract void RunInstruction(InterpreterState state);
public override void RunInstruction(InterpreterState state) { state.IncrementValue(direction == Direction.Forward ? 1 : -1); }
public override void RunInstruction(InterpreterState state) { char ch = Console.ReadKey().KeyChar; state.SetCurrentValueTo(Encoding.ASCII.GetBytes(new []{ch})[0]); }
public override void RunInstruction(InterpreterState state) { var ch = (byte)state.GetCurrentValue(); char c = Encoding.ASCII.GetChars(new[] { ch })[0]; Console.Write(c); }