Elsie19/bfc-rs

Optimized Brainfuck interpreter in Rust

★ 2Forks 0BrainfuckGitHub ↗Compare

README

bfc-rs

A brainfuck compiler & interpreter with a shell to boot!

Installing

You must have the following installed that is not included in this binary:

Then run:

cargo build --release
sudo cp target/release/bfc-rs /usr/bin/

Subcommands

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.

Optimizations

bfc-rs offers a couple useful optimizations out of the box:

Contractions

Contractions will turn:

Add(1)
Add(1)
Add(1)

into

Add(3)

thereby reducing the amount of instructions taken.

Clear loops

Clear loops will turn:

Loop: [
    Inc(1)
]

into

Clear

thereby turning an at max 254 operation into a single constant operation.

Dead code

bfc-rs will detect dead code that will not affect the programs running and remove it during compile time/interpreting.

Features

  • Debug flag that will produce debug symbols (-g on compile)

Contributors

Elsie19

Issues