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§
- OutOf
Bounds Access - 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 theBrainfuckVMtrait. - VMBuilder
- A builder struct for the default implementation of
BrainfuckVMCreate the default configuration withVMBuilder::new()orVMBuilder::default(), customize with the member functions, and build the final VM withVMBuilder::build()
Enums§
- Brainfuck
Execution Error - A fatal error encountered by the Brainfuck VM during program execution.
- Instruction
- Represents a single Brainfuck instruction
- Missing
Kind - The kind of missing jump instruction
- VMMemory
Error - A general memory error encountered during runtime by the VM
Traits§
- Brainfuck
Allocator - A trait representing an object that is capable of allocating memory for a Brainfuck VM
- Brainfuck
Cell - 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