Expand description
Brainfuck interpreter
§Examples
This will output “Hello World!\n” in the output vector:
use std::io::Cursor;
use std::str;
use vtashkov_bf::Interpreter;
let source_code = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
let mut input = Cursor::new(vec![]);
let mut output = vec![];
let mut interpreter = Interpreter::new(&mut input, &mut output, 30000);
interpreter.execute(&source_code);
assert_eq!("Hello World!\n", str::from_utf8(output.as_slice()).unwrap());
Structs§
- Args
- Command-line arguments for the interpreter input_file - the path to the file to be interpreted memory_size - the number of the cells in the memory, defaults to 30 000
- Interpreter
- Brainfuck interpreter
Functions§
- run_cmd
- Runs the interpreter using the arguments passed - file to read the source from and memory size