9 releases
| 0.1.9 | Oct 31, 2023 |
|---|---|
| 0.1.8 |
|
#413 in Procedural macros
13KB
BrainFuck compiler using Rust proc macro
More precisely, the BrainFuck-to-Rust transpiler using Rust proc macro
Examples:
- Hello World
(run on dropping)
brain_fuck!( ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>. >---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. ); - using
intomethod to obtain(pc: usize, mem: Vec<u8>)after running (run onintocalling)let (pc, mem) = brain_fuck!( ++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[ -<<<[ ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<< ]>.>+[>>]>+ ] ).into(); println!("{:?}", (pc, mem)); - use
envmethod to set Program Counterpcand Memorymemfor brainfuck codeblock (run on dropping)brain_fuck!( [.>] ).env(0, vec![79, 75, 10]); - Altogether
(run on
intocalling)let (pc, mem) = brain_fuck!( [.>] ).env(0, vec![72, 101, 108, 108, 79, 119, 104, 97, 116, 65, 115, 10]).into(); println!("{:?}", (pc, mem));
Dependencies
~1.5MB
~36K SLoC