Brainfuck 2

April 20, 2013 ยท View on GitHub

This is an interpreter for a brainfuck dialect. Notable design choices are the unbounded size of the data array (both to the left and to the right) and the addition of the '2' command, which doubles the number executions of the previous command as follows:

+22+2	adds 10: (((1 * 2) * 2) + 1) * 2

Whitespace is ignored and characters not among <>+-,.2[] have the effect that from that character on, the rest of the line is ignored (treated as comments). Syntactical errors are fatal.

By the addition of the '2' command, programs can potentially get a lot shorter.

[>+2+2+>+22+2>+2+>+<22-]>+2.>+.+2+2+.2+2+.>+2.<2+2222-.>.+2+.-2-2.-222.>+.>.

Incidentally, the original brainfuck was conceived 20 years before brainfuck2. Hooray!

(c) 2013 Jouke Witteveen