示例#1
0
 public override void RunInstruction(InterpreterState state)
 {
     if (state.GetCurrentValue() != 0)
     {
         state.CurrentInstruction = MatchingInstruction;
         Debug.WriteLine(Number + ": !0 Jumping to " + MatchingInstruction.Number);
     }
 }
示例#2
0
        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();
        }
示例#3
0
 public abstract void RunInstruction(InterpreterState state);
示例#4
0
 public override void RunInstruction(InterpreterState state)
 {
     state.IncrementValue(direction == Direction.Forward ? 1 : -1);
 }
示例#5
0
 public override void RunInstruction(InterpreterState state)
 {
     char ch = Console.ReadKey().KeyChar;
     state.SetCurrentValueTo(Encoding.ASCII.GetBytes(new []{ch})[0]);
 }
示例#6
0
 public override void RunInstruction(InterpreterState state)
 {
     var ch = (byte)state.GetCurrentValue();
     char c = Encoding.ASCII.GetChars(new[] { ch })[0];
     Console.Write(c);
 }