Gray Snail
Four commands, strings for everything, and a name in square brackets to read a variable.
Jack Eisenmann, 2009 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Jack Eisenmann made Gray Snail around 2009. It has four commands: INPUT, OUTPUT, POP and GOTO. There are no numbers. Everything is a string, and any string can be a variable name. first is the text first; [first] is the value of the variable called first.
Read the story
POP is the only way to take a string apart. It splits off the first character. Gluing strings back together needs no command, since a[x][y] is already one word. Jumps compare two strings. With that, the specification shows interpreters for Smallfuck, Bitwise Cyclic Tag and brainfuck written in Gray Snail.
The machine
| Command | Does |
|---|---|
POP v1 v2 s | First character of s into v1, the rest into v2 |
GOTO label s1 s2 | Jump to the line starting with label if s1 equals s2 |
INPUT v | Read a line into v |
OUTPUT s | Show s |
Quotes keep spaces inside a word: aHell"o w"orld! is one word. The original runs in a web page with one output box, which every OUTPUT blanks and fills again. This implementation prints the box when the program waits for input and when it ends.
Example
Every letter of the second word is quoted on its own, and they still make one word.
Every letter of the second word is quoted on its own, and they still make one word. POP throws the a away and keeps the rest.
The reverse cat from the specification. It keeps a word starting with a so that POP can split it, and the GOTO back to the top compares a with a, which always holds.
Further
- esolangs.org/wiki/Gray_Snail
- The original page, with a compiler in JavaScript
Ideas it shows
See also
Also in Turing tarpits
Write your own in Run Convert a program from Gray Snail
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: gray-snail.
Command line
shib run gray-snail -e 'OUTPUT "Hello World!"'shib manual gray-snailSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/gray-snail.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org