esolang

EXDotSF

DotSF without the tips, and with comparisons, an if-else, whole lines of input and up to ten stacks.

Rudolph4268, 2021 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 11 known programs · Test method

Run it

Expected: Hello world!

The idea

Rudolph4268 began EXDotSF in 2021 as an interpreter in C for DotSF, a stack language of one-character commands by ArthroStar11, and kept adding to it. Every DotSF program still runs. DotSF wants its interpreter tipped with $ in a tenth to a fifth of the source; EXDotSF keeps $ but lets it do nothing.

Read the story

DotSF can push only single digits, so 72 has to be worked out as 98*. EXDotSF pushes the code of a character with #cH and any number with #n72\. It adds comparisons, an if-else, a command that reads a whole line, comments, and commands of the form #...\ that make up to ten stacks and pass numbers between them.

The machine

CommandDoes
0 to 9Push the digit
#cH #n72\Push the code of H, or the number
+ - * / %Pop A, then B, and push A op B
= < > { } &Pop B, then A, and push 1 or 0 for A = B, A < B, A > B, A <= B, A >= B, and both not 0
_ @Copy the top item; copy the top two
~Move the bottom item to the top
. , "Read a number, a character, or a line with a 0 after it
: ;Print a number or a character
` | Print the whole stack, bottom first
[ ... ]Pop, and skip to the matching ] if it is 0
A to Z, a to zMark a label; jump to it
!A comment to the end of the line

? starts an if-else that ends at ', with | between its two halves. It pops a number and runs the first half unless the number is 0, and the second half if it is. Numbers are 32 bits, and the first stack holds 30,000 of them, as in DotSF. #sns\ makes another stack, #sds\ deletes one, #stfa\ to #stfh\ move or copy an item between another stack and the current one, at its top or its bottom, and #gcs\ and #scs\ get and set the current stack.

Example

The Hello world pushes a line feed and then the letters from last to first, and prints all 13.

The Hello world pushes a line feed and then the letters from last to first, and prints all 13.

The smallest of two numbers. @ copies both and < tests the first against the second. If it is smaller, [] drops the second and : prints the first; otherwise : prints the second.

Expected: 3

The calculator reads an operator and two numbers, moves the operator from the bottom of the stack to the top with ~, and tests it against +, -, * and / in turn. On any other operator it prints ERROR.

Expected: 42

A second stack. #n-1\9#sns\ asks for the first free stack with room for 9 numbers and pushes its index,

  1. #stfc\ moves 42 onto stack 1, and #stfa\ takes it back.
Expected: 42

Patterns it teaches

  • Stack machines: up to ten stacks, and an item can be taken from the bottom of one as well as from the top.

Further

Works-in-Progress

Stack-based

Write your own in Run Convert a program from EXDotSF

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run exdotsf -e '..@<?[]:|:'\''' --input '3 7'
shib manual exdotsf

Source

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

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

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