Crate cpr_bf

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§

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

Structs§

OutOfBoundsAccess
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
Program
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.
VMBuilder
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§

BrainfuckExecutionError
A fatal error encountered by the Brainfuck VM during program execution.
Instruction
Represents a single Brainfuck instruction
MissingKind
The kind of missing jump instruction
VMMemoryError
A general memory error encountered during runtime by the VM

Traits§

BrainfuckAllocator
A trait representing an object that is capable of allocating memory for a Brainfuck VM
BrainfuckCell
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.)
BrainfuckVM
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§

BfResult
The result of the execution of a Brainfuck program