More precisely, the BrainFuck-to-Rust transpiler using Rust proc macro
Cargo.toml
[dependencies]
bflib = "0.1.9"
use bflib::brain_fuck;
- Hello World
(run on dropping)
brain_fuck!( [> [> > > > <<<<-]> > >->> [<]<-]>>. >---. .. .>>.<-.<. .------.--------.>> .> . );
- using
into
method to obtain(pc: usize, mem: Vec<u8>)
after running (run oninto
calling)let (pc, mem) = brain_fuck!( [> > <<-]> >> <[-[>> <<-] >>]> [ -<<<[ ->[ [-] > >>>-<<]<[<]>> [<< >>-] << .[-]<< ]>.> [>>]> ] ).into(); println!("{:?}", (pc, mem));
- use
env
method to set Program Counterpc
and Memorymem
for brainfuck codeblock (run on dropping)brain_fuck!( [.>] ).env(0, vec![79, 75, 10]);
- 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));