Crate cpr_bf

source ·
Expand description

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);

Modules§

  • Contains various default memory allocators for the Brainfuck Virtual Machine trait

Structs§

  • An out-of-bounds access error returned by the Brainfuck VM if an access is attempted outside the allocated memory region, without dynamic allocation being enabled
  • Struct representing a complete Brainfuck program. The program does not need to be constructed directly, and is instead constructed automatically through the various run_* methods defined on the BrainfuckVM trait.
  • A builder struct for the default implementation of BrainfuckVM Create the default configuration with VMBuilder::new() or VMBuilder::default(), customize with the member functions, and build the final VM with VMBuilder::build()

Enums§

Traits§

  • A trait representing an object that is capable of allocating memory for a Brainfuck VM
  • This trait defines types that can be used as the datatype for a single cell of a Brainfuck VM. Can be implemented manually (although not recommended), but is already implemented for the default unsigned int types (u8, u16, etc.)
  • This trait represents an object that is able to run Brainfuck programs, either from a string of Brainfuck source code or by reading a Brainfuck source file

Type Aliases§

  • The result of the execution of a Brainfuck program