bflib

Crates.iobflib
lib.rsbflib
version0.1.9
sourcesrc
created_at2023-10-30 15:01:43.769128
updated_at2023-10-31 10:37:07.00472
descriptiona BrainFuck-to-Rust transpiler using Rust proc macro.
homepage
repositoryhttps://github.com/HellOwhatAs/brainfuck
max_upload_size
id1018570
size12,396
(HellOwhatAs)

documentation

README

BrainFuck compiler using Rust proc macro

More precisely, the BrainFuck-to-Rust transpiler using Rust proc macro

Crates.io License: MIT docs.rs

Examples:

  1. Hello World (run on dropping)
    brain_fuck!(
        ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.
        >---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
    );
    
  2. using into method to obtain (pc: usize, mem: Vec<u8>) after running (run on into calling)
    let (pc, mem) = brain_fuck!(
        ++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[
            -<<<[
                ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<<
            ]>.>+[>>]>+
        ]
    ).into();
    println!("{:?}", (pc, mem));
    
  3. use env method to set Program Counter pc and Memory mem for brainfuck codeblock (run on dropping)
    brain_fuck!(
        [.>]
    ).env(0, vec![79, 75, 10]);
    
  4. Altogether (run on into calling)
    let (pc, mem) = brain_fuck!(
        [.>]
    ).env(0, vec![72, 101, 108, 108, 79, 119, 104, 97, 116, 65, 115, 10]).into();
    println!("{:?}", (pc, mem));
    
Commit count: 21

cargo fmt