= = = NORF**K COMPILER = = =

Language and Javascript by Jack Eisenmann

Enter pseudo Norf**k code here:


Enter raw Norf**k code here:


Program input:


Program output:

For a more basic and visual implementation of Norf**k, please go here:
Norf**k Interpreter

= COMPILER NOTES =

Unlike the Norf**k interpreter I made earlier, the tape in this implementation is hidden. Instead, there are 2 additional I/O commands:

,: Input the next character given, if the input has been set and has not yet been accepted. The input is written at the head, and the command moves the head back to the first cell. Note: if an "X" is given as an input character instead of "0" or "1", the data at the head will not be changed when that character is accepted.

.: Output the character at the tape head. If there are multiple output commands in a single cycle, multiple boolean values will be given at a time in a single string. This command also moves the head to the first cell.

Important: Do NOT include an I/O command between a < command and its respective ! command. The compiler will not execute such a sequence correctly. Instead, keep all I/O and NOR commands untangled.

= TRANSLATOR NOTES =

The translator function is useful if you want to make long programs in Norf**k. It accepts an input which is significantly more human readable, and will translate it into raw Norf**k automatically.

This is an example of a very basic pseudo Norf**k program. It accepts two inputs, then calculates the first input NOR the second, and outputs the result:

IN input1 input2
input1 input2 output
OUT output

There are three kinds of commands you can give in the pseudo code: IN to accept input (the comma command, ,), OUT to give output (period, .), or the NOR operation (< and !). The second line in the code above is a NOR command; commands which do not begin with IN or OUT are assumed to be NOR.

The tape positions named input1, input2, and output are used in this example program. The translator will automatically assign each of these variables a position on the tape. Variables used more frequently are assigned lower positions on the tape, so the number of < commands are reduced.

The IN and OUT commands may accept any number of variables to accept input or give output. In a NOR command, the variable written by the ! command is the last variable (output in the case of the example program), and the variables before it are read by < (input1 and input2).

If you paste the example program into the pseudo Norf**k code box and press the convert button, the following code will be written into the raw Norf**k code box:

,>,<><>>!>>.

From there, simply press the compile button to run the code.

Note: in pseudo Norf**k code, you can use a semicolon to separate commands on the same line. Each command by itself on a line may end with a semicolon as well, but it is not required. The following code will yield the same output:

IN input1 input2;
input1 input2 output; OUT output;

Also note: If a command contains a pound sign (#), the command will be ignored by the translator. The code below has the same output as the original example:

# Accepts two values.
IN input1 input2
# Performs a NOR operation, and outputs the result.
input1 input2 output; OUT output

Return to the Ostracod Pond