Crates.io | brainhug |
lib.rs | brainhug |
version | 0.7.0 |
source | src |
created_at | 2019-01-04 18:27:14.747726 |
updated_at | 2022-09-12 19:22:54.945458 |
description | A simple brainf*ck translator |
homepage | https://sn99.github.io/brainhug/ |
repository | https://github.com/sn99/brainhug |
max_upload_size | |
id | 105474 |
size | 55,957 |
brainhug
is a crate that is used to interpret brainf*ck code to any other language
Inspired from link
Add this to your Cargo.toml
:
[dependencies]
brainhug = "*"
and this to your crate root:
extern crate brainhug;
use brainhug::Lang;
Read contributing for Details
extern crate brainhug;
use brainhug::Lang;
fn main() {
// will print `Hello World!`
let input = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
// `brainhug::generate` will generate a `String`
println!("{}", brainhug::generate(Lang::C, input));
}
#include "stdio.h"
int main() {
char tape[20000] = {0};
char *ptr = tape;
*ptr += 8;
while (*ptr) {
ptr += 1;
*ptr += 4;
while (*ptr) {
ptr += 1;
*ptr += 2;
ptr += 1;
*ptr += 3;
ptr += 1;
*ptr += 3;
ptr += 1;
*ptr += 1;
ptr -= 4;
*ptr -= 1;
}
ptr += 1;
*ptr += 1;
ptr += 1;
*ptr += 1;
ptr += 1;
*ptr -= 1;
ptr += 2;
*ptr += 1;
while (*ptr) {
ptr -= 1;
}
ptr -= 1;
*ptr -= 1;
}
ptr += 2;
putchar(*ptr);
ptr += 1;
*ptr -= 3;
putchar(*ptr);
*ptr += 7;
putchar(*ptr);
putchar(*ptr);
*ptr += 3;
putchar(*ptr);
ptr += 2;
putchar(*ptr);
ptr -= 1;
*ptr -= 1;
putchar(*ptr);
ptr -= 1;
putchar(*ptr);
*ptr += 3;
putchar(*ptr);
*ptr -= 6;
putchar(*ptr);
*ptr -= 8;
putchar(*ptr);
ptr += 2;
*ptr += 1;
putchar(*ptr);
ptr += 1;
*ptr += 2;
putchar(*ptr);
}
Licensed under