bfbackend 0.1.0

Compiler backend for brainfuck
Documentation
  • Coverage
  • 9.09%
    7 out of 77 items documented0 out of 71 items with examples
  • Size
  • Source code size: 54.08 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.04 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • jacks0n9/bfbackend
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jacks0n9

BFBackend: A Compiler Backend for Brainfuck

BFBackend is a Rust crate which allows you to use Rust functions to generate Brainfuck code.

Features

  • Comparisons (equals, not equals, greater than, and less than)
  • Text display
  • Read strings of a specified length
  • Setting single cells and arrays efficiently
  • Efficiently matching on the value of a byte
  • Multiplication, division, addition, subtraction, exponentiation
  • General variable/memory manipulation utilities

Concepts

  • Variable: a container for a slice of memory and variable data
  • ByteRef: a reference to a specific cell in memory as well as a reference to the variable which the cell is a part of
  • MemoryRange: a pointer to a start cell along with the size of the data

How to Use

  • Create a BfContext:
    use bfbackend::BfContext;
    let ctx = BfContext::default();
    
  • Run functions on it to generate Brainfuck code:
    let mut my_num = ctx.declare_and_set_byte(42);
    ctx.add_to_var(&mut my_num.get_byte_ref());
    
  • Get your code:
    let code = ctx.build_code();
    println!("{code}");