CalScript
A stack, a tape and 26 commands, all spelled with three words. HAA, HEE, HOO.
Vriskanon, 2015 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Vriskanon made CalScript in 2015. Its whole alphabet is three tokens. Each command is a path through a tree, three or four tokens deep, and each token picks a branch. The first says what the command works on (HAA the stack, HEE the tape, HOO both), the next one narrows it down, and so on to a leaf.
Read the story
The machine has a stack and a tape of integers. There is no jump and no loop, so a program runs once from top to bottom. The Hello World is 13,924 characters long. For each letter it adds 1 to a cell as many times as the letter's code, pushes the cell onto the stack, which sets the cell back to 0, and prints the top.
The machine
| Command | Does |
|---|---|
HAA HAA HAA HAA HAA HEE | Move the top of the stack to the bottom, or the bottom to the top |
HAA HAA HOO | Drop the top |
HAA HEE HAA HAA HAA HEE HEE HAA | Pop two, push the sum or the product |
HAA HEE HAA HEE HAA HEE HEE HEE | Pop a, then b, push a - b or a / b |
HAA HOO HAA HAA HAA HOO HAA HEE | Push 1 or 0 if the top is 0, else 0 or 1 |
HAA HOO HEE HAA HAA HOO HEE HEE | Pop and print a character; read one and push it |
HEE HAA HAA HEE HAA HEE | Move the tape pointer right or left |
HEE HEE HAA HEE HEE HEE | Add 1 to the cell or take 1 away |
HEE HOO HAA HAA HEE HOO HAA HEE | Make the cell 1 or 0 if it is 0, else 0 or 1 |
HEE HOO HEE HAA HEE HOO HEE HEE | Print the cell; read a character into it |
HOO HAA HAA HOO HAA HEE | Pop the top into the cell, or copy it there |
HOO HEE HAA HOO HEE HEE | Push the cell and set it to 0, or just push it |
HOO HOO HAA HOO HOO HEE HOO HOO HOO | Pop v, make the cell cell + v, cell - v or v - cell, and push it |
Tokens are separated by spaces or line breaks. Any other word stops the program before it starts. Division rounds down, and the end of the input reads as 0.
Example
The one-time cat reads one character into the cell and prints it.
The one-time cat reads one character into the cell and prints it.
Read a character, add 1 to it, print it.
Subtraction takes the second number popped from the first. This pushes 2, then 8 and 8, multiplies them and adds 3. The top is 67 and the one below it 2, and 67 - 2 is 65, an A.
Patterns it teaches
- Stack machines: arithmetic and printing go through the stack.
- Encoding tricks: 26 commands written as a prefix code over three words.
Further
See also
Cell-based
Stack-based
Write your own in Run Convert a program from CalScript
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: calscript.
Command line
shib run calscript -e 'HEE HOO HEE HEE
HEE HOO HEE HAA' --input 'cat'shib manual calscriptSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/calscript.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org