bfbackend

Crates.iobfbackend
lib.rsbfbackend
version0.1.0
sourcesrc
created_at2024-08-12 23:07:59.110916
updated_at2024-08-12 23:07:59.110916
descriptionCompiler backend for brainfuck
homepage
repositoryhttps://github.com/jacks0n9/bfbackend
max_upload_size
id1335254
size52,758
Jackson (jacks0n9)

documentation

https://docs.rs/bfbackend

README

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}");
    
Commit count: 0

cargo fmt