Crates.io | brainfuck_macros |
lib.rs | brainfuck_macros |
version | 0.1.5 |
source | src |
created_at | 2014-11-14 08:59:47.910261 |
updated_at | 2015-12-11 23:57:49.028558 |
description | A compiler plugin that converts brainfuck code into Rust at compile time, letting your BF programs be optimised by LLVM to super-fast native code. |
homepage | https://github.com/huonw/brainfuck_macros |
repository | https://github.com/huonw/brainfuck_macros |
max_upload_size | |
id | 98 |
size | 22,591 |
A simple procedural macro that turns a Brainfuck program into native code.
Example:
#![feature(phase)]
#[phase(plugin)] extern crate brainfuck_macros;
use std::io;
fn main() {
let hello_world = brainfuck!{
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>
---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
};
hello_world(&mut io::stdin(), &mut io::stdout()).unwrap();
}
See tests/
and examples/
for some basic examples and the
bf_bf_interpreter
subpackage for
brainfuck interpreter written in brainfuck.
This is Cargo enabled, and so can be used
by adding a [dependencies.brainfuck_macros]
section pointing to this
git repository to your Cargo.toml. If you wish to also use
bf_bf_interpreter
, simply add [dependencies.bf_bf_interpreter]
section also pointing to this repository.
Normal brainfuck, with:
<
when pointing at the
first cell is just ignored, and similarly for >
at the last).