1 stable release
1.0.0 | Jan 20, 2024 |
---|
#8 in #zero-dependency
Used in rainfuck-cli
16KB
218 lines
Rainfuck
A configurable, minimal, powerful Brainfuck interpreter library! Rainfuck uses no dependencies unless you specify a feature that requires one!
Examples:
use rainfuck::BrainfuckVM;
// A simple cat program. (Just repeats what you type.)
fn main() {
let mut vm = BrainfuckVM::new();
vm.prompt_display = String::from("[TYPE]: ");
vm.process(",[.,]");
}
use rainfuck::BrainfuckVM;
// Run some stuff, then reset the virtual machine.
fn main() {
let mut vm = BrainfuckVM::new();
assert!(vm == BrainfuckVM::new());
vm.process("++++++++[>+>+<<-]>>[<<+>>-]");
assert!(vm.cells[0..4] == [8, 8, 0, 0]);
vm.reset();
assert!(vm == BrainfuckVM::new());
}
lib.rs
:
Rainfuck
A configurable, minimal, powerful Brainfuck interpreter library! Rainfuck uses no dependencies unless you specify a feature that requires one!
Examples:
use rainfuck::BrainfuckVM;
// A simple cat program. (Just repeats what you type.)
fn main() {
let mut vm = BrainfuckVM::new();
vm.prompt_display = String::from("[TYPE]: ");
vm.process(",[.,]");
}
use rainfuck::BrainfuckVM;
// Run some stuff, then reset the virtual machine.
fn main() {
let mut vm = BrainfuckVM::new();
assert!(vm == BrainfuckVM::new());
vm.process("++++++++[>+>+<<-]>>[<<+>>-]");
assert!(vm.cells[0..4] == [8, 8, 0, 0]);
vm.reset();
assert!(vm == BrainfuckVM::new());
}
Dependencies
~205KB