esolang

Grapheme

Twenty-six commands, and every one of them is a capital letter.

PythonshellDebugwindow, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: HLLOWORLD

The idea

PythonshellDebugwindow made Grapheme in 2020. A program may only use the letters A to Z, so strings, numbers and functions have to be written in letters too. Three letters open and close them. E starts and ends a string, F a number and H a function. Since E ends a string, no string can hold an E, and the Hello World in the specification prints HLLOWORLD.

Read the story

Numbers are letters as well. Inside F...F each letter is one decimal place, A to I for 1 to 9 and Z for 0, so FABF is 12. The formula adds each letter before it multiplies by 10, which would make FABF 120, but its truth machine prints 1 with FAF, so Grapheme reads plain decimal digits.

The machine

One stack holds integers, strings and functions, and variables map any value to any value.

LetterDoes
A B S RAdd, subtract, multiply, floor divide the top two
C DSet a variable; push a variable
G I Q ZRun code; run a function; run it if true; run it while the stack is not empty
J NTurn the top into a number or a string
K L M PDuplicate, swap, drop, reverse the stack
O TLength of a string; not
U V XSkip the next command, the next n commands, or one of the next two
W YRead a line; print

False is 0, the empty string and the empty function.

Example

The second adds 12 and 3.
Expected: 15
Expected: 1

The second adds 12 and 3. The third pushes the string FAFY and runs it as code with G.

The truth machine from the specification. HFAFYH is a function that prints 1, WJ reads a line and turns it into a number, and U skips the loop Z when that number is 0. Input is letters too, so 0 is typed as Z.

Expected: 0

Read as written, Z pops the function before it looks at the stack. On 1 the stack is then empty, so the loop never runs and this truth machine prints 0 as well.

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Grapheme

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run grapheme -e 'EHLLOWORLDEY'
shib manual grapheme

Source

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

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

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