bfrunner

Crates.iobfrunner
lib.rsbfrunner
version0.1.2
created_at2026-01-21 00:47:11.660694+00
updated_at2026-01-21 01:39:43.965063+00
descriptionA Brainfuck interpreter in Rust, for shits and giggles. Not for production.
homepage
repositoryhttps://github.com/NekoTheCatgirl/bfrunner
max_upload_size
id2057917
size14,041
Neko The Catgirl (NekoTheCatgirl)

documentation

README

bfrunner

A Brainfuck interpreter for shits and giggles. Seriously. Don’t use this in production.

bfrunner is a tiny, pure-Rust Brainfuck interpreter. It's fast enough to play with small programs, safe enough that it won't melt your computer (probably), and it comes with optional FFI support if you want to torture another language with this as well!

Features

  • ✅ Run Brainfuck code from strings or files
  • ✅ Echo input/output with simple examples
  • ✅ Detailed errors for unmatched brackets or pointer overflows
  • ✅ Optional FFI interface for integration in other languages like C

Installation

Add this to your Cargo.toml

[dependencies]
bfrunner = "0.1.0"

Examples

Hello world

use std::io::Cursor;
use bfrunner::{ BrainfuckError, run_to_string };

const SOURCE: &str = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";

fn main() -> Result<(), BrainfuckError> {
    let mut input = Cursor::new(Vec::<u8>::new());
    let output = run_to_string(SOURCE, &mut input)?;
    println!("{output}");
    Ok(())
}

Echo Input

use std::io::Cursor;
use bfrunner::{ BrainfuckError, run_to_string };

const SOURCE: &str = ",[.,]";

fn main() -> Result<(), BrainfuckError> {
    let mut input = Cursor::new(b"Hello, world!".to_vec());
    let output = run_to_string(SOURCE, &mut input)?;
    println!("{output}");
    Ok(())
}

Error Handling

bfrunner distinguishes between:

  • Parse errors - unmatched brackets, invalid syntax
  • Runtime errors - pointer out of bounds, I/O errors

FFI Support (Optional)

If you build the library from source with the ffi feature enabled, you can run Brainfuck code from C using:

int Brainfuck_run(const char*, const char*, char*, size_t);

Check the function in ffi.rs for error codes.

Warning ⚠️

This crate exists purely for fun, learning, and mild frustration. Brainfuck is notoriously impractical, and so is this interpreter. Do not expect it to replace any serious programming language or runtime.

Use at your own risk. May cause laughter, confusion, or existential dread.

Contributing

PRs, bug reports, and memes are welcome. Keep it silly, keep it safe.

Commit count: 10

cargo fmt