esolang

smol

Every character means two things. A semicolon says which.

Conor O'Brien · Turing complete: no · ●●○ moderate

Tested with 6 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

Conor O'Brien's smol reads its program in two modes. It starts in collect mode, where each character is a literal pushed on the stack: digits and letters are the numbers 0 to 61, . is an empty list and `c is the code of c. A ; switches to evaluate mode, where the same characters are commands. So a is 10 in one mode and a range in the other.

Read the story

The stack holds 64-bit integers and lists. A string in quotes is a list of character codes, and @ runs a list as commands. That is the only way to repeat anything.

The machine

In evaluate modeDoes
0…9Push the digit
X Y Z / x y zPop into a register, push it back
R rStore into register n, load register n
+ ,Add two integers, join two values into a list
a ARange from lower to upper, without and with a step
: dDuplicate the same list, copy it
oDrop the last element of the list on top
. p ?Print as characters, print as a value, print the whole stack
@Run each element of a list as a command

'text' pushes the codes of the text in either mode, and ; switches modes. A character collect mode does not know, a space included, pushes -1337, smol's error value. The reference is smol.c in github.com/ConorOBrien-Foxx/smol.

Example

The second collects 3, 3 and 10, then prints 10 and the sum of the two 3s.
Expected: 10 6
Expected: abab
Expected: ababc

The second collects 3, 3 and 10, then prints 10 and the sum of the two 3s. The last two show the difference between : and d. After : both stack entries are the same list, so o shortens both; after d only the copy loses its c.

Patterns it teaches

Without input or a real loop it is not Turing complete.

Without input or a real loop it is not Turing complete.

Further

Also in Golfing

Write your own in Run Convert a program from smol

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run smol -e '05;ap'
shib manual smol

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/smol.js

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