The BrainFuck-like Languages Compiler (bflc) is a compiler framework that targets Brainfuck and closely related languages.
Before building, get the source code by cloning the repository.
git clone https://github.com/bynect/bflc.git
Build the project using CMake.
cmake -B _build
make -C _build
Guaranteed to work for Linux, requires the Unix Makefile generator for CMake.
The compiler is a terminal interface for the blfc library.
--debug
Set debug output--verbose
or-v
Set verbose output--help
or-h
Print help message--version
Print version message--frontend=STRING
Set one of the available frontends. The default isbrainfuck
--backend=STRING
Set one of the available backends. The default isamd64_asm
--front=STRING
Alternative name for--frontend
option--back=STRING
Alternative name for--backend
option-o
Set output file path. The default isoutput
-fread
Use read syscall (not available in all backends)-fwrite
Use write syscall (not available in all backends)-fsyscall
Equivalent to-fread
and-fwrite
-fcell=INT
Set the number of cells (default is30000
)
# Compile echo.bf to x86_64 nasm assembly
bflc echo.bf -o echo.asm
The amd64
backend is not supported at the moment.
To create x86_64 executables assemble the output of amd64_asm
.
The framework is by default built as a standalone static library libbflc.a
,
that can be easily linked with your projects.
The frontends and backends are not included in the static library,
so you must compile them separately.
- X86_64 assembly backend, uses NASM syntax (
amd64_asm
) - X86_64 machine code backend, only for JIT-ing (
amd64
)
Backends may generate machine code (for example amd64
).
Since you can use the framework as a library you can create a JIT quite easily.
A practical integration example is also available.
Contributions are welcome. Please open an issue first for major changes.
Before pushing contributions, please check for errors, memory leaks and other problems with either Asan or Valgrind.
The bflc framework is licensed under the terms and conditions of the Apache-2.0 License.