A compiler from a C-like language to Brainfuck
Always heard that Brainfuck is Turing complete but still had doubts about its computational power? Those days are over
BF-it is a Compiler of a C-like language to Brainfuck, written in Python
You give it C-like code, and it gives you Brainfuck code with the same functionality :)
There are several reasons why I chose to create this
Create a Brainfuck code of your choice, send it to your friends, and tell them to run it (on some online interpreter, for example)
When they receive a bunch of nonsense which does something meaningful, they will (maybe) be amazed
BF-it.py <path_to_code_file>
-o
for output file, and -r
for running the compiled file)Interpreter.py <path_to_bf_file>
, this will execute
the Brainfuck codeExample:
$ cat helloworld.code
int main()
{
print("Hello World!\n");
}
$ ./BF-it.py helloworld.code
Compiling file 'helloworld.code'...
Compiled successfully to 'helloworld.bf'
$ cat helloworld.bf
>[-]>[-]<>++++++++[-<+++++++++>]<.>++++[-<+++++++>]
<+.+++++++..+++.>++++++[-<------------->]<-.>+++++[
-<+++++++++++>]<.>++++[-<++++++>]<.+++.------.-----
---.>++++++[-<----------->]<-.>+++[-<------->]<--.<
$ ./Interpreter.py helloworld.bf
Hello World!
For a more interesting example, check out Tic-Tac-Toe!
./BF-it.py examples/games/tic_tac_toe.code -r
Please refer to the 'examples' directory. It contains examples and explanations for syntax, operations, flow, and more
If you would like to add a feature yourself, perform a pull request and add your changes. I will review them
If you found a bug, or have an idea for a feature, open an issue