Quests

Quests is the first Questa-based made language by User:ChuckEsoteric08.

Syntax

The following Extended Backus-Naur Form (EBNF) describes the language's syntax:

```program       := [ command , { whitespaces , command } ] ;
command       := push | pop | increment | output | decrement | swap ;
expression    := integer | string | command ;
push          := "p"   , "(" , expression , ")" ;
pop           := "<"   , "(" , expression , ")" ;
output        := ">"   , "(" , expression , ")" ;
increment     := "inc" , "(" , expression , ")" ;
decrement     := "dec" , "(" , expression , "," , expression , ")" ;
swap          := "sw"  , "(" , ")" ;

string        := textCharacter , { textCharacter } ;
integer       := [ "+" | "-" ] , digit , { digit } ;
whitespaces   := whitespace , { whitespace } ;
whitespace    := " " | "\t" | "\n" ;
textCharacter := letter | digit | "_" | "-" ;
letter        := "a" | ... | "z" | "A" | ... | "Z" ;
digit         := "0" | "1" | "2" | "3" | "4"
|  "5" | "6" | "7" | "8" | "9" ;
```

Commands

Command Function
`p(x)` Pushes `x` to top of the Questa
`<(x)` If `x` is 0, pops the element from the top. If 1, pops the element from the bottom
`>(x)` If `x` is 0, pops the element from the top and outputs it. If 1, pops the element from the bottom and outputs it
`inc(x)` If `x` is 0, increments the element on the top. If 1, increments the element on the bottom
`dec(x,y)` If `x` is 0, jumps to the `y`-th command if top of the quest is zero and if it isn't decrement top of the questa, with the commands being indexed starting with zero (0). If `x` is 1 jumps to the `y`-th command if bottom of the questa is zero and if it isn't decrement bottom of the questa
`sw()` Swaps the elements on the top with the element on the bottom

`x` can't contain spaces, because these are utilized to separate commands.

Examples

Hello World

```p(HelloWorld) >(0)
```

Goto

The following example utilizes the `dec` command with the purpose of obviating the insertion of an element. After pushing the values “Hello” and 0 unto the Questa, the goto facility bypasses the pushing of the “World” string to its top by using the top 0 element for its navigation, thus popping and returning in the last step the top value 0 instead.

```p(Hello)
p(0)
dec(0,4)
p(World)
>(0)
```

Turing-completness

It is Turing-complete, beacuse it can simulate Szewczyk notation for Minsky machine with 2 registers like that:

MM Quests
Start `p(0) p(0)`
A -1 `inc(0)`
B -1 `inc(1)`
A Y `dec(0,Y+2)`
B Y `dec(1,Y+2)`

Interpreter

• Common Lisp implementation of the Quests programming language.