SimpleScript
Brainfuck's loop, with a stack of bytes and one register in place of the tape.
A, 2018 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
SimpleScript is by the user A, from 2018. It keeps brainfuck's bracket loop but drops the tape. There is a stack for bytes and a single register for a whole number of any size. Strings go onto the stack in one piece, and nine letters move values between the stack, the register, the input and the output.
The machine
| Command | Does |
|---|---|
"chars" | Push the codes of the characters, in order |
a | Pop the whole stack, printing each value as a character |
b c | Read a character into the register; read a line onto the stack |
d g | Pop into the register; push the register |
e f | Print the register as a number; as a character |
h i | Pop a value and add it to the register; subtract it |
[ ... ] | Repeat while the register is not 0 |
The specification's table says the loop repeats while the register equals 0. Its cat and its truth machine only work the other way round, as in brainfuck, so this implementation follows the examples. At the end of the input b reads 0, which is what ends the cat.
Example
Strings push from left to right and a pops from the top, so Hello, World! is written backwards.
Strings push from left to right and a pops from the top, so Hello, World! is written backwards.
The truth machine takes the code of 0 from the code it reads. On 0 the loop is skipped and e prints 0 once; on 1 the loop prints 1 for ever.
There is no command to add 1. A countdown adds the code of 0 and takes away the code of 1.
Further
Ideas it shows
See also
SimpleScript builds on Brainfuck.
Brainfuck derivatives
Stack-based
Write your own in Run Convert a program from SimpleScript
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: simplescript.
Command line
shib run simplescript -e '"0" b i [e] e' --input '0'shib manual simplescriptSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/simplescript.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org