Brainfuck interpreter written in C.
I wanted to write a little program in C just to get to know C a bit better and I thought, this would be a really nice project to do so.
Warning
I honestly believe no one will ever use this interpreter for any production software, but if you do so, use this software with caution! The ways to shoot yourself in the foot with C are endless, and so to speak I have never used a gun before.
git clone https://github.com/zekrotja/bfc .
make$ ./dist/bfc --help
usage: bfc [options] [INPUT_FILE]
Arguments:
INPUT_FILE Source file (reads from stdin if not specified)
Options:
-b, --buffer-size <BUFFER_SIZE> Define the size of the program buffer [default: 30000]
-D, --debug Enable debug mode
-d, --dynamic-reallocation Enable dynamic reallocation of the program buffer
-h, --help Print help message
-j, --json Output as JSON format
Run from a file:
./dist/bfc inputs/hello_world.bfRun from stdin:
cat inputs/hello_world.bf | ./dist/bfcSome rules of the languages seem not to be as clearly defined, so some assumptions were made based on some documentation I found and other implementations of brainfuck.
The buffer for the cells is pre-allocated and has by default a size of 30000, but you can define a custom size via the --buffer-size option. When the pointer moves out of the bounds of the buffer, the program will error. The cell size is 8 bit ([0..255]). The values will wrap around when over or underflowing. Currently, the implementation has a limitation that loops can only be nested up to a depth of 1000. Also the whole program code is load into memory, so the size of your program is limited by the amount of available system memory. Also the input of data (, syntax) is currently not implemented.
- Implement input (
,syntax) - Optimizations (like
[-]) [see ref] - Dynamic resizing of the cell buffer