/// <summary> /// Creates an instance of an Interpreter. Each of the parameters except program is optional.. /// </summary> /// <param name="program">The program to execute. If this is null, the empty program is executed.</param> /// <param name="tape">The tape to use as a memory story. If this is null, a default tape is used.</param> /// <param name="input">The input source to use. If this is null then Console.In is used.</param> /// <param name="output">The output source to use. If this is null then Console.Out is used.</param> public Interpreter(IProgram program, Tape tape = null, TextReader input = null, TextWriter output = null) { _program = program; _tape = tape ?? Tape.Default; _input = input ?? Console.In; _output = output ?? Console.Out; }
/// <summary> /// Executes this instruction within the given context. /// </summary> public void Execute(IProgram program, Tape tape, TextReader input, TextWriter output) { _action(program, tape, input, output); }