esolang

Full Stack

The program is a queue of its own bytes, and a small stack language rewrites what is left of it.

Challenger5, 2019 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, World!

The idea

Challenger5 made Full Stack in 2019, inspired by ///. The source is a queue of bytes, and most bytes print themselves. So Hello, World! prints Hello, World!, and it is a quine as well.

Read the story

The work is done by a second language, Front End. When the queue reaches <, the code up to > runs as Front End, with the rest of the program as its stack. What is left on the stack becomes the rest of the program. Front End on its own is deliberately weak, a push-down automaton at most. The specification thinks Full Stack could simulate cyclic tag, which would make it Turing complete, but that is not proven.

The machine

The queue.

ByteDoes
]Print the next byte
[Put a byte of input at the back
< ... >Run Front End on the rest of the queue
any otherPrint itself

Front End, on a stack of bytes with 26 variables that start at 0.

CommandDoes
+N -NAdd to or take from the top, mod 256
:N !NCopy or delete the top N values
/Swap the top two
a APush variable a; pop into it
{...}Push the bytes inside, the last on top
[...] [...)Repeat, or run once, while a popped value is not 0
(...] (...)Repeat, or run once, while the stack is not empty

N left out is 1. The variables keep their values from one < to the next.

Example

In the quine, ::8 copies the top byte and then the top 8.
Expected: <::8>]<::8>]

In the quine, ::8 copies the top byte and then the top 8. The rest ]<::8>] becomes ]<::8>]]]<::8>]], and that prints the source.

The truth machine reads a byte to the back of the queue. Front End copies it and takes 48 off. On 0 nothing more happens and the 0 is printed. On 1 it pushes <:5>1<:5>, a loop that prints 1 for ever.

Expected: 0

The Front End example clears the stack and pushes how many values it had, mod 2. In this implementation it counts the three bytes xyz, with +48 added to print the digit.

Expected: 1

Patterns it teaches

Further

Queue-based

Self-modifying

Write your own in Run Convert a program from Full Stack

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: full-stack.

Command line

shib run full-stack -e '<::8>]<::8>]'
shib manual full-stack

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/full-stack.js

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

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