esolang

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

Expected: Hello world!

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

CommandDoes
POP v1 v2 sFirst character of s into v1, the rest into v2
GOTO label s1 s2Jump to the line starting with label if s1 equals s2
INPUT vRead a line into v
OUTPUT sShow 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.

Expected: seen

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.

Expected: Enter a string to reverse. lians

Further

Ideas it shows

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-snail

Source

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