Advanced Brainfuck

From Esolang
Jump to: navigation, search

The Advanced Brainfuck is an extension of the brainfuck programming language. It adds the abality to switch to "file mode".

to open a file (/dev/stdin for instance), you can use the switch operator '~'. It will open the file with the address corresponding to the string starting at the current memory pointer position (which should be ended by \0). Once open, you are in "file mode" the '.' operation copy from the file to the memory, and the ',' operation copy from the memory to the file. To switch back to "memory mode", reuse the '~' operator. In this case the operators are reversed, '.' copy from the memory to the file and ',' copy from the file to the memory.

Each time you read/write a file in memory mode, the file pointer is automatically shifted by +1.

Each you read/write the memory in file mode, the memory pointer is automatically shifted by +1.

If you are in file mode, the reading overwrite the memory where was the pointer, so the file address. If you switch back to memory, you can shift the memory pointer and still get data from the file with the operator ','. But to shift the file pointer by a custom value, you need to reopen it.

TapTempo.abf is a commented example that opens stdout, stdin and /proc/uptime to get an implementation of TapTempo: