A brainfuck compiler written in PHP.
Naegleria fowleri /nəˈɡlɪəriə/ (also known as the "brain-eating amoeba") infects people by entering the body through the nose.
You can use Naegleria to compile a brainfuck file into AT&T assembly. This can then be assembled using gcc
, and executed directly.
$ bin/compile $(uname -m) examples/hello.b > hello.s
$ gcc -o hello hello.s
$ ./hello
Hello World!
For more cross-platform support, you can use the LLVM backend:
$ bin/compile llvm examples/hello.b > hello.ll
$ clang -o hello hello.ll
$ ./hello
Hello World!
- linux amd64
- linux aarch64
- llvm
- php (source)
- wasm (with WASI)
The compiler uses a fixed-size array of 4000 elements for the cells. Good luck!
It's assembly, so probably faster than C.
Run your own.
This is not (yet) an optimizing compiler.
- Thanks to @nikita_ppv for planting the idea a long time ago.
- Thanks to @codeoracle for the inspiration to pick up
gcc -S
. - Thanks to @dazzlog for helping understand assembly.
- Thanks to @old_sound for coming up with the name and logo.
- Thanks to the Esolang wiki for being a great resource.