#brainfuck #brainfuck-interpreter #esoteric #interpreter #bf

brainpreter

A simple and easy to use brainfuck interpreter

1 unstable release

Uses old Rust 2015

0.1.0 Nov 10, 2017

#289 in Emulators

MIT license

20KB
425 lines

rust-brainpreter (brainpreter) - v0.1.0

A simple and easy to use Brainfuck interpreter.

How to use (Hello world! Example)

Create a new brainpreter.

let mut bf = brainpreter::Inter::new();

Load brainfuck code from text string or file.

// For file use: .load_from_file()
match bf.load("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.") {

    Ok(_) => {}
	
    Err(e) => println!("{}", e),
	
}

Compile the bf code.

match bf.parse() {
        
    Ok(_) => {}
	
    Err(e) => println!("{}", e),

}

Finally run it.

match bf.run() {
        
    Ok(_) => {}
	
    Err(e) => println!("{}", e),

}

Result on the console.

Hello world!

Installation

Add this line to your Cargo.toml:

[dependencies]
brainpreter = "0.1.0"

and then add this line to your main.rs:

extern crate brainpreter;

No runtime deps