rust-bfi
Simple and fast Brainfuck interpreter perfectly suited for machine learning needs.
Example
extern crate bfi;
use ;
let code = b; // `b` converts an `&str` to a byte vector: `pub fn b(s: &str) -> Vec<u8>`
let input = b;
let mut output = Vec new;
let mut machine = new;
let res = machine.exec;
assert_eq!;
assert_eq!;
Implementation details
- The memory tape is infinitely long to the right.
- Going to the left of the starting cell causes an
Err(BfError::Memory)
. - Cells can hold values from 0 to 255.
- Addition and subtraction over- and underflow silently.
- End of input results in an early return.
Why another Brainfuck interpreter?
I like idea of Brainfuck as an environment for reinforcement learning. After searching crates, I have't found anything decent for interpreting BF in runtime, so I've written this little thing.