Lately I have been learning Rust. As my first project, I decided to write a Brainfuck interpreter. Feel free to submit issues or pull requests on how may I improve the code!
- Ensure that you have a Rust installed, including cargo (Rust's build and package manager).
- Clone the repository:
$ git clone https://github.com/s3rvac/yabir
- Build the interpreter:
$ cargo build --release
- Run it on a Brainfuck program:
$ target/release/yabir PROG
The programs
directory contains a few sample programs you can try.
As stated here, there are some portability issues that developers of Brainfuck interpreters and programs need to be aware of. My implementation behaves as follows:
- Cells are 8-bit unsigned integers. They wrap around (e.g. when incrementing 255, you get 0).
- The data array has potentially unlimited size and is automatically resized. However, the array can be extended only to the right.
- Emitted ends of lines are platform-specific (e.g. LF on Linux).
- The behavior of the
,
command (read a byte from the input stream) when an end-of-file condition has been encountered is to leave the current cell unchanged.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.