brain_fuck 0.1.1

BrainFuck compiler in Rust procedural macro metaprogramming
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 4.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 243.73 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • netcan

BrainFuck Compiler

BrainFuck compiler in Rust procedural macro metaprogramming.

Usage

The BrainFuck code from https://fatiherikli.github.io/brainfuck-visualizer/, see it how to work.

The BrainFuck compiler generates the below code to "Hello World!" at compiler time(metaprogramming), and printing it at run time.

Implementing in Rust procedural macro way.

extern crate brain_fuck;
use brain_fuck::brain_fuck;
fn main() {
    println!("{}", brain_fuck!(
        ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.
        >---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
    ));
}

emit asm code:

brain_fuck::main::h3aaadb2fa73e0763:
...
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$64, %rsp
	leaq	l___unnamed_2(%rip), %rax
	movq	%rax, -16(%rbp)
	leaq	_$LT$$RF$T$u20$as$u20$core..fmt..Display$GT$::fmt::h45c22d68a23dc67a(%rip), %rax
...
l___unnamed_6:
	.ascii	"Hello World!\__int128"

	.section	__DATA,__const
	.p2align	3
l___unnamed_2:
	.quad	l___unnamed_6
	.asciz	"\r\000\000\000\000\000\000"