User:Elronnd/brainfcuk

This is brainfcuk (speling intentional). It is a brainfuck derivative/extension. Below follows the official specification.

As with other extensions, brainfuck code should be forwards-compatible with brainfcuk, except for the fact that certain characters may be ignored/considered comments by standard brainfuck, but be considered commands in brainfcuk.

It inherits the following eight basic commands from brainfuck but aside from that goes in a different direction from most brainfuck extensions, as far as I know:

In addition to those commands, the following commands are also available:

File handling
There is now a new thing in addition to the tape, the string, and each cell on the tape now holds two values (or there are two tapes, whichever way you want to look at it). The string is separate from the the tape and is used for file operations and environment variable handling. Here is an example of its usage:

Let us assume that some section of the tape looks like this:

"lsdkf" [000] [009] [014] [008] [102] [105] [108] [101] [46] [116] [120] [116] [032] [014]                    ^

Where  represents the current cell and the value enclosed by quotes represents the current string cell. 102, 105, 108, 101, 46, 116, 120, 116, collectively are the ASCII values that together represent

Now, given this configuration, let us put  into the parser. It will take 8 values from the right and put them into the string value. The program state is now this:

"file.txt" [000] [009] [014] [008] [102] [105] [108] [101] [46] [116] [120] [116] [032] [014]                    ^

Now let's open the file by giving  to the interpreter. This will open file.txt for writing. Since file.txt does not yet exist (assume), the  will be replaced by. We can now use the hello world program and then close the file. file.txt will have been created and "Hello, world!\n" will have been placed in it.

Each cell on the tape also optionally holds a "function", although it is more akin to a procedure in that it takes no arguments and returns nothing. The function in the current cell can be written to by enclosing any other set of brainfcuk instructing within `(` `)`. This code will not be executed immediately, but only when called via the `:` instruction. This allows for a crude form of self-modifying code whereby which function is placed in the current cell is conditional. Note that the content of a function need not be a valid brainfcuk program in and of itself -- only a segment of one. For example, `(])[-:` is valid code, and equivelant to `[-]`.