esolang

JollyScript

Every program is a Christmas tree, and the cursor falls through it from the star to the trunk.

Turing complete: no · ●●○ moderate · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: Hello World!

The idea

Execution starts at the * on the first line. Every step moves the cursor one row down and one column left or right, so it can only fall. / and \ steer it, and ^ splits it in two. The left branch runs to its end first, then the right one. A row of ~ at the bottom ends every branch that reaches it. The only way back up is }, which jumps to the last {.

Read the story

The stack holds 4-bit numbers that wrap around at 16. A byte is two of them, so , prints the top two as one character and & reads one character as two digits.

The machine

CommandDoes
*Start here, going left
/ \Go left or right
^Run the left branch, then the right one
~End this branch
{ }Keep this place; jump back to it
0-9 A-FPush a digit
+ -Add; subtract the top from the one below
: % $Duplicate, swap, drop
?Go left on 0, else take 1 off the top and go right
. , nPrint the top as a hex digit, the top two as a character, a line feed
# &Read a hex digit, read a character as two digits
"Print every cell the cursor passes, until the next "

Every other character is decoration. The specification leaves open what a command does with too few values on the stack; it does nothing, as in the Haskell interpreter.

Example

Hello World splits three times.

Hello World splits three times. Each of the four branches turns printing on, prints the three cells it falls through and turns printing off again before it reaches the row of ~ at the bottom.

The truth machine reads a digit in the left branch and tests it in the right one. On 1 it pushes another 1 and jumps back to the { forever, printing the 1 each time.

Expected: 0

The cat reads a character as two digits and stops when both are 0.

Expected: Merry Christmas!

The specification also has FizzBuzz, 99 glasses of milk and the Twelve Days of Christmas, each drawn as a tree, and all three are implemented.

Patterns it teaches

Further

Two-dimensional languages

Stack-based

Write your own in Run Convert a program from JollyScript

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: jollyscript.

Command line

shib run jollyscript -e '     *
    ^
   { ?
  # . 1
 / / } }
~~~/-\~~~' --input '0'
shib manual jollyscript

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/jollyscript.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org