Compile, transpile and interpret Brainfuck with bfpile!
This project was created by Tanya Nevskaya with the guidance and help of Yana Timoshenko <3
bfpile also implements peephole optimizations that turn consecutive Brainfuck commands into one CPU instruction!
This project can be built with Nimble that comes with Nim. Just run nimble build
.
To compile Brainfuck to a desired target, enter:
bfpile -t<TARGET> filename.bf
Supported compiler targets:
Target | Description |
---|---|
aarch64-linux |
Linux AArch64 (Arm 64-bit) |
riscv64-linux |
Linux RISC-V 64-bit |
wasm32-wasi |
WebAssembly System Interface (WASI) |
x86_64-linux |
Linux x86-64 (AMD64) |
x86_64-freebsd |
FreeBSD x86-64 (AMD64) |
x86_64-netbsd |
NetBSD x86-64 (AMD64) |
x86_64-openbsd |
OpenBSD x86-64 (AMD64) |
x86_64-illumos |
Illumos x86-64 (AMD64) |
To transpile Brainfuck to a desired language, enter:
bfpile -l<LANGUAGE> filename.bf
Supported transpiler languages:
Language | Description |
---|---|
c |
C |
rust |
Rust |
zig |
Zig |
To interpret Brainfuck, enter:
bfpile -i filename.bf
If no option is provided, bfpile defaults to compiling to Linux x86-64.
Enter bfpile
without any arguments to get help :)
You can test bfpile with any of the programs in vendor
folder. mandelbrot.bf
is mostly useful for benchmarking.
All contributions are very welcome! Found a confusing comment? Know a better way to write some part of the program? Want to submit an additional emitter? Feel free to create issues and pull requests to bfpile repository!