BICIB aims to provide a easy-to-use tool set for brainfuck, and it is also written in brainfuck.
BICIB provides dockerized brainfuck interpreter and compiler. Currently only docker-capable x86_64-linux is supported. For details please check docker.
Brainfuck is a esoteric programming language with only eight instructions which can be viewed as the ability of a Turing machine. These instructions are(assume head is of type char* in C):
symbol | action | C |
"<"(ASCII 0x3c) | move the head to the left square | head-- |
">"(ASCII 0x3e) | move the head to the right square | head++ |
"+"(ASCII 0x2b) | increase the current square by 1 | (*head)++ |
"-"(ASCII 0x2d) | decrease the current square by 1 | (*head)-- |
","(ASCII 0x2c) | write to the current square | *head = getchar() |
"."(ASCII 0x2e) | read from the current square | putchar(*head) |
"["(ASCII 0x5b) | loop until the current square is 0 | while(*head){ |
"]"(ASCII 0x5d) | the end of the loop | } |
It may be a little bit confusing that the "," instruction performs a write by getchar() and the "." instruction performs a read by putchar(). But notice that read/write is the action of an operator of Turing machine, and the put/getchar() functions are the actions from the terminal's point of view, which is mere a simulation to Turing machine.
More detailed history and references can easily be found at Wikipedia and esolangs.
Obviously, we have no way to interact with the modern computer systems in such programming model. Brainfuck supports neither file operations, nor object linking. These constraints make it hard to produce a self-hosted brainfuck interpreter or compiler.
We write the two programs in brainfuck. In other words, these programs themselves should be viewed as Turing machines. There is no random-accessed memory but only a tape.
As a result, we implement a small piece of assembly code as a general entry point, which is responsible for loading the files specified in the command line arguments into a contiguous region on the tape of the simulated machine. The code will then be processed by the main part of interpreter/compiler, writen in brainfuck.
Currently(version 0.3) we have self-hosted compiler and interpreter, and planning to start developing debugger.
The only thing you have to make sure is that you have docker working properly. For those who don't know how to install docker, reference this document. Most of the GNU/Linux distributions and MAC are already supported, so it shouldn't be a problem.
After you have a docker environment, you may first clone this project,
git clone [email protected]:NonerKao/BICIB.git
cd BICIB
And then build the container,
docker build -t bicib .
After the container is built, you may run it following the guide, or briefly type the following instruction,
docker run --rm bicib bfi /root/BICIB/brainfuck/examples/hw.b
You may also use interactive shell,
docker run --rm bicib bash
in which the you can use bfc or bfi directly.
Have fun!
BICIB is licenced under GPLv3.