Kavod
As many stacks as there are integers, and a jump that counts tokens.
Conor O'Brien · Turing complete: unknown · ●●○ moderate
Tested with 4 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Kavod is a small tarpit by Conor O'Brien. Memory is a set of stacks, each named by an integer. Stack 0 is where a program starts, and stack -1 is a register for keeping a value aside. There are 12 commands and numbers. There is no loop and no if; a program jumps to a position it computed itself.
The machine
| Command | Does |
|---|---|
123 | Push the number |
+ - | Pop two, push second plus top or second minus top |
# * | Print a byte; read a byte, -1 at the end |
> < | Copy the top to the register; move the register's top back |
} { ~ | Send a value to stack n; take the top of stack n; make stack n current |
. ? | Jump to position n; jump only if the top is not 0, which stays |
A position counts tokens, not characters. A run of digits is one token, a run of whitespace is one token, and every other character is one. Popping an empty stack gives 0. A jump past the end, or to a negative position, ends the program. Values are 32-bit integers.
Example
The cat reads a byte, keeps a copy in the register and adds 1.
The cat reads a byte, keeps a copy in the register and adds 1. Only at the end of the input is that 0, so ? jumps to token 8 for every real byte. There the sum is parked on stack 5, the byte comes back from the register and is printed, and 0. starts again.
Further
- The reference interpreter, in C++
Ideas it shows
See also
Also in Turing tarpits
Write your own in Run Convert a program from Kavod
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: kavod.
Command line
shib run kavod -e '5 3-48+#'shib manual kavodSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/kavod.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language