A brainfuck interpreter and brainfuck-to-C transpiler written in odin.
Brainfuck is an esoteric programming language created in 1993 by Urban Müller. It looks like this:
+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.
This program prints Hello, World!.
- To practice programming in odin.
- To build an interpreter/compiler without getting distracted by all the parsing theory and predefined structures that are easy to self-impose when thinking about a "regular" programming language.
- Make sure you have Visual Studio installed on your device.
- Install the Odin compiler and add its location to the
pathenvironment variable. - Either start a 64-bit developer command prompt or start a regular command prompt and run
vcvars64.bat. - Run
build.bat.
- Run
bf.exe(or simplybf) and pass to it a brainfuck source file to interpret. It will only run the first argument and ignore every other file. The tests folder contains a bunch of brainfuck source files you can try to run. - Run with the
-buildoption to compile the argument (both to C and to an executable). You can optionally pass in another file name which will be used as the output name. - Run
bf.exe -helpto see what you can do with it.
Both the interpreter and the compiler use a "wrap-around" strategy when moving the data pointer out of bounds. The allocated space is of 30.000 bytes, and going off one end wraps you back to the other side.
