SimpleScript

From Esolang
Jump to navigation Jump to search

SimpleScript is an esoteric programming language invented by User:A, similar in many aspects to brainfuck, but regarding its architecture operating on a stack and a single register, while the command set is extended to accommodate for these variations.

Architecture

A program in this language is offered access to two memory storages: a stack of infinite size intended to store byte values, and a register maintaining an unbounded integer. Both data conditories partake of input and output capacities, and their interrelations may be availed for computations.

Commands

SimpleScript's commands embrace strings, instructions composed of a single character, and an iteration facility.

Command Description
"chars" Pushes the ASCII character codes of the chars in the string unto the stack, in the order of their appearance.
a Empties the stack while outputting its elements as ASCII characters, in the order of their popping.
b Prompts the user for a character and stores its ASCII code in the register.
c Prompts the user for a string and pushes its characters' ASCII codes unto the stack, from left to right.
d Pops a value from the stack and writes it to the register.
e Prints the content of the register as a number.
f Prints the content of the register as the associated ASCII character.
g Pushes the content of the register to the stack.
h Pops a value from the stack and increments the register by this value.
i Pops a value from the stack and decrements the register by this value.
[ While the register equals 0, the code betwixt [ and either the matching ] or, if not present, the end of the program, is executed. If the register does not equal 0, the enclosed code section is skipped.
] Terminates a code section to repeat started by a [.

Examples

Hello, world!

The following program prints “Hello, World!” to the standard output:

"!dlroW ,olleH"a

Cat program

An infinitely repeating cat program may be implemented as such:

bf[bf]

Truth-machine

A truth-machine is implemented in the following:

"0" b i [e] e

Interpreter

  • Common Lisp implementation of the SimpleScript programming language.