A brainfuck interpretor/compiler.
- Interpreter, Bytecode interpretor, JIT-compiled code interpretor
- Transpiler to C
- Compiler to executable binary
- x86 for Windows
- x64 for Windows
- x86 for Linux
- x64 for Linux
- Armeabi (WIP)
You can execute brainfuck as following.
$ ./kbf hello.b
The command is equivalent to following command, with option -O1
which means that compile branfuck code to IR-code and execute it.
$ ./kbf hello.b -O1
If you want to execute brainfuck code directory, try following command (very slow).
$ ./kbf hello.b -O1
You can also execute branfuck code with JIT compile (very fast). But currently, this option is available in x86 or x64 environment.
$ ./kbf hello.b -O2
You can transpile brainfuck code to C code as following.
$ ./kbf hello.b --target=c -o hello.c
Ofcourse, generated C source file can be compile with C-compiler.
$ gcc hello.b -Wall -Wextra -O2 -o hello
$ ./hello
Following example shows that compile brainfuck code to a x64 ELF binary and execute it in x64-Linux environment.
$ ./kbf hello.b --target=elfx64 -o hello
$ ./hello
Generated ELF binary is glibc less binary, use system call only.
Following example shows that compile brainfuck code to a x64 Windows binary and execute it in x64-Windows environment.
$ kbf hello.b --target=winx64 -o hello.exe
$ hello.exe
- Execute with JIT-compile by LLVM
- Generate LLVM-IR
- Fix ARM binary generation
- Use buffer for output characters in Linux ELF binary
This software is released under the MIT License, see LICENSE.