esolang

Klon

Thirteen commands on a row of text cells, run by a Windows batch file.

KlonMac7, 2012 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 8 known programs · Test method

Run it

Expected: Hello_world

The idea

KlonMac7 made Klon in 2012. A program is a list of lines, each a command and one word. The cells hold text, not numbers, so in adds a word to the end of a cell and out prints the whole cell. Arithmetic reads the cell as a number only when it needs one. There are no loops or jumps, so every program stops after one pass.

Read the story

The specification gives the interpreter as a batch file of 21 lines, and this implementation follows it.

The machine

CommandDoes
left rightMove the pointer, from cell 0 up to cell 32767
in wordAdd the word to the end of the cell
outPrint the cell and a line break
conAdd a line of input to the end of the cell
clsEmpty the cell
copy pasteKeep the cell's text; add the kept text to a cell
+ n - n * n / nWhole number arithmetic on the cell
exitStop

A word cannot hold a space, which is why the examples write Hello_world. Arithmetic works in 32 bits, as the batch file's set /a does. It reads a cell from its first digits, so 12abc counts as 12 and a word as 0, and like set /a it reads 010 as octal 8 and 0x10 as hexadecimal 16.

con reads with set /p, which keeps its old value when the line is empty or the input has ended. So a second con with nothing left to read adds the last line again.

Example

The specification says the second program prints 321.
Expected: 3 2 1
Expected: Whats_your_name_? Hello_Klon
Expected: 5

The specification says the second program prints 321. Each out is an echo in the batch file, so the three digits come out on three lines.

Further

Cell-based

Write your own in Run Convert a program from Klon

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run klon -e 'in 5
+ 5
out'
shib manual klon

Source

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

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

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