esolang

Complack

Simplack with more of everything. As many stacks as you name, labels, four conditional jumps and subroutines.

Olivato, 2020 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: 25

The idea

Olivato built Complack on Simplack, a small stack language by Saka, and the name is short for Complex Stack. A program is one instruction a line, and every instruction works on the selected stack. use potato selects a stack called potato, and makes it the first time. Items are found by index, counted from the bottom, and an argument written $2 means the item at index 2.

The machine

InstructionDoes
use nSelect stack n
push n pop iPush a number; remove the item at index i
inc i n dec i n set i nAdd to, subtract from or set the item at index i
label l goto lMark a line; jump to it
if i n goto lJump if the item at index i is n; nif bif sif jump if it is not, if it is bigger, if it is smaller
sub n ... end gosub nA subroutine and its call
output i c prints cPrint one item or the whole stack as characters, or with i as numbers
input c input iPush the characters of a line, or its number
exitStop

A line that starts with # is a comment. A jump may also name a line number, counted from 0 without the comments, which the specification discourages.

Example

The square of the input adds the input to index 2 while index 1 counts up to it.

The square of the input adds the input to index 2 while index 1 counts up to it.

The subroutines push 0, 10 and 20 three times. Then the second one twice removes the bottom item and prints the new bottom.

Expected: 1020

The Fibonacci program keeps five numbers on a stack called fib, the last one 10 for the line break, and counts down on a second stack.

Expected: 1 2 3 5 8

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Complack

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run complack -e '# Echo what user input
input c
prints c' --input 'hello'
shib manual complack

Source

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

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

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