Syntax Null Language

From Esolang
Jump to navigation Jump to search

Syntax Null Language (or SNL for short) is a language similar to brainfuck. SNL operates on an infinite tape with 8-bit unsigned cells.

Commands

SNL Commands
Command Description
> Move the tape head right.
< Move the tape head left.
+ Take the current cell and the next cell, add them, and put the result in the current cell.
- Take the current cell and the next cell, subtract them, and put the result in the current cell.
* Take the current cell and the next cell, multiply them, and put the result in the current cell.
/ Take the current cell and the next cell, divide them, and put the result in the current cell.
o Output the value of the current cell as an ASCII character.
n Output the value of the current cell as a number.
p Output the value of the current cell, and following cells as a null-terminated ASCII string.
i Take an input as a character and put it into the current cell.
c Take an input as a number and put it into the current cell.
s Take an input as a string and put it into the current cell, and the following cells as a null-terminated UTF-8 string.
@ Push current cell onto stack.
# Pop a value off the stack into current cell.
[ Start a block.
] End a block.
e Requires a block directly after. Runs block if current cell isn't zero.
f Requires a block directly after. Runs block if current cell is zero.
z Requires a block directly after. Loops block while current cell isn't zero.
w Requires a block directly after. Loops block while current cell is zero.
0-9 Writes the given number to the current cell.

Examples

Hello World

This programs prints hello world in an extremely un-optimized way.

7>1>9<+<*>2<+o1>1>9<+<**>0>1>9<+<*<+>1<+o1>1>9<+<**>0>1>9<+<*<+>8<+o1>
1>9<+<**>0>1>9<+<*<+>8<+o1>1>9<+<**>1>1>9<+<*<+>1<+o4>1>9<+<*>4<+o3>1>
9<+<*>2<+o8>1>9<+<*>7<+o1>1>9<+<**>1>1>9<+<*<+>1<+o1>1>9<+<**>1>1>9<+<
*<+>4<+o1>1>9<+<**>0>1>9<+<*<+>8<+o1>1>9<+<**>0>1>9<+<*<+>0<+o3>1>9<+<
*>3<+o

Countdown

This program creates a counter, and then uses a loop to decrement the counter and print the value.

>>1>9<+<1<9+z[n->>o<<]n>>>3<*+o-/o

Implementations

There is an implementation written in Rust availible at https://crates.io/crates/snli.