esolang

Tier

Befunge in a stack of files. Each file is a floor, and @ takes the lift.

BN, 2020 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 9 known programs · Test method

Run it

Expected: hello, world!

The idea

BN made Tier in 2019 and 2020, after Befunge. A program is a folder of files named 0.tier, 1.tier and so on, all stacked on top of each other in one 3D space. The pointer runs over one tier at a time and wraps at its edges. @ and a number move it straight up or down to the same spot in another tier, which gives a function its entry and exit points.

Read the story

Every tier keeps its own stack. It runs from minus infinity to plus infinity, holds 0 everywhere, and has a pointer sp that the program moves itself. A value that gets overwritten is not lost at once. It falls into ts, one store shared by all tiers, and ~ can push it back.

The machine

CharDoes
> < ^ _Go right, left, up, down
@3Move to the same place in tier 3
#End
[ ]Move sp up or down
'12' "text"Put a number or a string at stack[sp]; the old value goes to ts
~Push ts on top of the stack
( ) ,Copy stack[sp] to ts, ts to stack[sp], sp to ts
!Boolean not of stack[sp]
: $Pop at sp, or pop the top
+ - * / \ % & \|Push stack[sp] op stack[sp-1] on top
= ?Skip the next cell if stack[sp] is 0, or greater than stack[sp-1]
{ }Print stack[sp]; read a line into it

The reference interpreter is one Python file, and the values are Python's. A number is a whole number of any size or a float, ! makes booleans that print as True and False, and / always gives a float. Input is a string unless it is wrapped in '. A program with more than one tier writes each file after a line such as 1.tier, as the specification does.

Example

The truth machine reads '0' as the number 0.
Expected: 0

The truth machine reads '0' as the number 0. = sees it and skips the _, so it prints and ends. On '1' the pointer goes down, right and up again into { for ever.

The prime test runs over five tiers. It tries n mod d for d from n − 1 down, and goes through tiers 3 and 4 to loop back into tier 0.

Expected: Enter a number to check if prime: Prime

Strings read in the direction of travel, so "n\emirP" met going left is Prime and a line feed.

Patterns it teaches

Further

Multi-dimensional languages

Stack-based

Write your own in Run Convert a program from Tier

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run tier -e '}{#' --input 'abc'
shib manual tier

Source

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

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

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