Brainfuck is an esoteric programming language created in 1993 by Swiss student Urban Müller. Designed to be extremely minimalistic, the language consists of only eight simple commands, a data pointer, and an instruction pointer. [Wikipedia]. BrainFuck is probably the simplest programming lanugage you have ever seen, and ironically the hardest you have ever programmed in. This Link Provides more information about the rules and syntax of this language.
This is yet another Compiler written in C that translates brainf*ck code to ELF Executables. Its not an interpreter, it compiles the source to ELF Executables which is executable in most linux platforms. First the source is compiled down to Assembly following the NASM x86-64 bit syntax and using NASM's Assembler assembled and finally linked to the final executable. So you need NASM and a linker (ld) for this compiler to function properly. But, for some purpose, if you want you can only generate assembly code.
I haven't made support for windows but I might someday. Make sure you have NASM and LD, for most linux distro, they are available by default.
- Clone this Repository - https://github.com/bitwise-rude/brainf-ck
- Inside the folder run -
make - This creates
bfin the same folder, which is the required compiler executable.
After building, you can use start compiling brainf*ck, there are some test code provided in tests/ which are downloaded from here.
- In terminal,
./bf tests/tic-tac-toe.bf -ca - It builds a tic-tac-toe game written in brainf*ck, and outputs
outputin the same root folder. - Run
./outputto execute and play the game. - Remove Argument
-cato generate the assembly file as well.
The file template.asm contains the blueprint that every program have.
I am open to contribution, send a PR, or you can contact me directly.
- Refactor Code
- Arguments Refactors making user experiencing better
- Use pipelining instead of using Temporary File for NASM and LD