JLannoo / brainfuck-interpreter-rs

A Brainfuck interpreter written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

brainfuck-interpreter-rs

An interpreter for the Brainfuck language written in Rust.

Usage

You can instantiate the interpreter with the new method, and then run it with the run method.

let mut interpreter = BFInterpreter::new();

interpreter.run(...);

Example

// Interpreter with default config
let mut interpreter = BFInterpreter::new(None);

// Interpreter with custom config
let mut custom_instructions = HashMap::new();
// Use WASD instead of +-<> for instructions
custom_instructions.insert('D', Instruction::PointerInc);
custom_instructions.insert('A', Instruction::PointerDec);
custom_instructions.insert('W', Instruction::ByteInc);
custom_instructions.insert('S', Instruction::ByteDec);
...

let mut interpreter = BFInterpreter::new(Some(BFInterpreterConfig {
   tape_size: Some(1024),
   custom_instructions: Some(custom_instructions),
}));

interpreter.run(...);

About

A Brainfuck interpreter written in Rust


Languages

Language:Rust 97.7%Language:Brainfuck 2.3%