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