Simplack

From Esolang
Jump to navigation Jump to search

Simplack is a simple, stack-based language created by User:Saka. Simplack is designed to be easy to learn.

Basics

In Simplack, only integers can be stored in the stack, although they can be outputted as ASCII characters.
Each instruction is on a separate line.
Comments are any line that start with #

Instructions

Certain arguments can use values from other items in the stack by using $n where n is the index that the value will be taken from. These arguments are marked by an asterisk (*) after them.

Instruction Description
push n Push the integer n to the top of the stack.
pop n Pop/remove item at index n.
increase i n* Increase integer at index i by n
set i n* Set the integer at index i to n
if i n* goto l If the integer at index i is n, go to line l, otherwise, carry on.
goto n Go to line n.
output i t Output item at index i as either ASCII (t = a) or an integer (t = i).
input t Get either ASCII (t = a) or integer (t = i) input and push it to top. If a string is inputted, each character will get pushed one by one, not as the whole string.
exit End the program.

Examples

Here are some examples:

Truth Machine

input i
if 0 1 goto 4
output 0 i
exit
output 0 i
push 1
goto 4

CAT

input a
push 0
output 0 a
pop 0
if 0 0 goto 6
goto 2
exit

Hello, World!

push 72
push 101
push 108
push 108
push 111
push 44
push 32
push 87
push 111
push 114
push 108
push 100
push 33
push 0
output 0 a
pop 0
if 0 0 goto 18
goto 14
exit

Square of Input

#Calculates the square of whatever
input i
push 0
push 0
increase 2 $0
increase 1 1
if 1 $0 goto 8
goto 4
output 2 i

Fibonacci

push 0
push 1
push 0
push 0
push 10
set 3 $0
increase 3 $1
set 2 $3
set 0 $1
set 1 $2
output 3 i
output 4 a
goto 5

Interpreters

Python

Available on GitHub

Extension

There is an simplack extension, with more functionalities called Complack