NullScript 2
Jump to navigation
Jump to search
NullScript 2 is a esolang written by a stone arachnid. It is a superset of NullScript 1 and inspired by Deadfish~ and bf. It stores data in a 256-cell tape, and has an 8-item FIFO parameter queue used primarily for copying data between cells and mathematical operations. There is a cell pointer that can look at one cell at a time. All the cells default to zero.
Commands
These are NullScript 2's 19 commands:
tcell group | |
---|---|
[ |
Decrement the current cell |
] |
Increment the current cell |
; |
Square the current cell |
. |
Print the current cell as a number |
, |
Print the current cell as a character |
~ |
Reset the current cell to 0 |
stdin group | |
& |
Take an integer as input and put in the current cell. |
meta group | |
< |
Move the cell pointer left. |
> |
Move the cell pointer right. |
* |
Push the current cell to the parameter queue |
' |
Take the value from the parameter queue and put it into the current cell |
math group | |
+ |
Add two numbers from the parameter queue and put it into the current cell |
- |
Subtract two numbers from the parameter queue and put it into the current cell |
x |
Multiply two numbers from the parameter queue and put it into the current cell |
/ |
Divide two numbers from the parameter queue and put it into the current cell |
" |
Divide two numbers from the parameter queue and put the remainder into the current cell |
jump group | |
{ |
If the current cell is 0, jump to the next } . If there is none, jump to the end of the program.
|
} |
Jump to the previous { . If there is none, jump to the start of the program.
|
q |
Jump to the end of the program. |
Implementation notes
- When a
,
is executed on a cell outside of the range of 0 to 127, it is undefined behavior. - When
<
would push the cell pointer below zero, the cell pointer wraps around to cell 255. Likewise, if>
would push the cell pointer above 255, the cell pointer wraps around to zero. - When the parameter queue is empty and a command requires a value from the queue, the value is received from input.
- If there is division by zero, the behavior is undefined.
Examples
Hello, world!
This program prints the message “Hello, World!” to the standard output:
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],~ ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]],
Cat program
The following program implements a repeating cat program for numeric input and output, which terminates upon a user input equal to zero:
]{&.}
Truth-machine
A truth-machine is implemented in the following program:
&.{.}
Interpreter
- Common Lisp implementation of the NullScript 2 programming language.