bfc is a Brainfuck compiler. Currently, it doesn't directly compile to an executable format, but rather to NASM. Directly compiling to a binary format is planned for the near future.
bfc is super easy to build and has no external dependencies, other than the standard C library.
git clone https://github.com/SarahIsWeird/bfc
cd bfc
make
Right now, there isn't anything you can configure. You run the program with bfc <input> <output>
. After bfc ran through, you need to compile the resulting NASM file and link it. Congratulations! You've just compiled brainfuck code!
./bfc myProgram.bf myProgram.asm
nasm -f elf64 myProgram.asm
ld -o myProgram myProgram.o
Make sure you have the command line developer tools installed!
./bfc myProgram.bf myProgram.asm
nasm -f macho64 myProgram.asm
ld -macosx_version_min 11.3.1 -o myProgram myProgram.o -L$(xcode-select -p)/SDKs/MacOSX.sdk/usr/lib -lSystem
Why all the extra stuff when linking? Well... macOS requires creating a binary for a minimum macOS version, as well as linking to libSystem. $(xcode-select -p)
just fetches the appropriate path where libSystem lies.
There's an example program included at example.bf, if you want to try out the compiler, but don't have any brainfuck code ready. It prints out a well-known text!