6 releases

0.1.5 Mar 20, 2024
0.1.4 Mar 18, 2024

#446 in Programming languages


Used in cpr_bfvm

MPL-2.0 license

27KB
519 lines

cpr_bf

crate documentation

A simple Brainfuck interpreter library, featuring a configurable Brainfuck Virtual Machine.


lib.rs:

A simple Brainfuck interpretation library

The library exposes the BrainfuckVM trait, representing an object that is able to run Brainfuck programs either from source code represented as a string, or from a Brainfuck source file.

In addition to this general trait, it also provides the VMBuilder struct, that can be used to create a Brainfuck VM that is customizable through various means.

Examples

To simply create a basic spec-compliant Brainfuck runner, and run some Brainfuck code:

let code = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";

let vm = cpr_bf::VMBuilder::new().build();
vm.run_string(code);

Dependencies

~555KB
~11K SLoC