A brainfuck compiler & interpreter with a shell to boot!
You must have the following installed that is not included in this binary:
- qbe (https://c9x.me/compile/, latest commit)
- cc (probably already a symlink on your system)
Then run:
cargo build --release
sudo cp target/release/bfc-rs /usr/bin/shell will launch an interactive REPL where you can put full brainfuck commands in.
interpret <file> will run the interpreter on the file.
compile <file> will compile the program to a static binary.
bfc-rs offers a couple useful optimizations out of the box:
Contractions will turn:
Add(1)
Add(1)
Add(1)
into
Add(3)
thereby reducing the amount of instructions taken.
Clear loops will turn:
Loop: [
Inc(1)
]
into
Clear
thereby turning an at max 254 operation into a single constant operation.
bfc-rs will detect dead code that will not affect the programs running and remove it during compile time/interpreting.
- Debug flag that will produce debug symbols (
-gon compile)