esolang

Quests

A stack that can also be reached from the bottom. Six commands on it are enough for a Minsky machine.

ChuckEsoteric08 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: HelloWorld

The idea

ChuckEsoteric08 made Quests as the first language built on a Questa, a stack whose bottom can be popped, raised and lowered as well as its top. Every command but p and sw takes a 0 to work on the top or a 1 to work on the bottom. The only jump sits inside dec. It jumps when the element is 0 and takes 1 from it otherwise.

Read the story

Two numbers on the Questa, one on top and one at the bottom, are the two registers of a Minsky machine. The specification gives a table that turns each Minsky instruction into five Quests commands, so Quests is Turing complete.

The machine

CommandDoes
p(x)Push x, a whole number or a word, on top
<(0) <(1)Pop the top or the bottom
>(0) >(1)Pop the top or the bottom and print it
inc(0) inc(1)Add 1 to the top or the bottom
dec(0,y) dec(1,y)Jump to command y if the top or the bottom is 0, else take 1 from it
sw()Swap the top and the bottom

Commands are separated by whitespace and numbered from 0. A word holds letters, digits, _ and -. The grammar also lets a command stand as an argument, but it does not say what a command gives there, so this implementation leaves that out.

Example

The second is the goto.
Expected: 0

The second is the goto. The 0 on top makes dec jump to command 4, past p(World), and >(0) pops and prints that 0.

An addition in the Minsky style. B is 3 at the bottom and A is 2 on top. Each round takes 1 from B and adds 1 to A. To jump back it pushes a 0 for dec(0,3) to jump on, and <(0) at command 3 pops it again. When B is 0, dec(1,8) jumps to the end, which prints A.

Expected: 5

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Quests

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run quests -e 'p(HelloWorld) >(0)'
shib manual quests

Source

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

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

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