StupidStackLanguage
StupidStackLanguage (or SSL) is an esoteric programming language created by Lebster in which all operations take place on a Stack
SSL Uses the characters A-Z to perform actions. SSL is also case-insensitive.
Operations
Note: Items on the stack can only be numbers.
Character | Operation |
---|---|
a | Pushes 0 to the top of the stack |
b | Pops the 1st item from the stack |
c | Subtracts the 2nd item on the stack from the 1st item and pushes the result to the stack |
d | Decrements the 1st item of the stack by 1 |
e | Pushes the 1st item mod the 2nd item onto the stack |
f | Prints the 1st item on the stack as an ASCII character |
g | Adds the first 2 stack items together and pushes the result to the stack |
h | Gets input from the user as a number and pushes to the stack |
i | Increments the 1st item of the stack by 1 |
j | Gets input from the user as a character and pushes that character's ASCII code onto the stack |
k | Skips the next command if the 1st item on the stack is 0 |
l | Swaps the 1st and 2nd items on the stack |
m | Multiplies the first two stack items together and pushes the result onto the stack |
n | If the 1st item on the stack is equal to the 2nd item, push a 1 to the stack, else push a 0 |
o | Pops the (first item on the stack)th item on the stack |
p | Divides the 1st item on the stack by the 2nd item and pushes the result onto the stack |
q | Duplicates the 1st item on the stack |
r | Pushes the total length of the stack onto the stack |
s | Swaps the 1st and (first item on the stack)th items on the stack |
t | If the 1st item on the stack is 0, jumps to the corresponding 'u' in the program, otherwise does nothing |
u | If the 1st item on the stack is not 0, jumps back to the corresponding 't' in the program, otherwise does nothing |
v | Increments the top item on the stack by 5 |
w | Decrements the top item on the stack by 5 |
x | Prints the 1st item on the stack |
y | Deletes the entire stack |
z | Exits the script |
Examples
Hello World
avqmimcfdddfviiffvddfavdegmfavdmcwfwdddfvddfwdfwdddf
The online interpriter also features macros so:
You can make a hello world program using the print
macro
.print("hello world")
but thats lame
Cat
jf
A+B Problem
hhgx
Truth-machine
htxux
Find the Factorial of a Number
hqdtmldubx
h # Set X q # Duplicate x (z) d # Decrement z (y) t # Begin loop m # Multiply y by x l # Swap result and y d # Decrement y u # End loop b # Pop remaining 0 x # Print (x!)
Calculator
hhhtdtdtblpxzubmxzublcxzubgxz
Usage
Takes 3 inputs, X, Y and Z
Z | Program output |
---|---|
0 | X + Y |
1 | X - Y |
2 | X * Y |
3 | X / Y |
Print the Fibonacci Sequence
# Note: Works best on tio.run as when run via command line it runs so fast that you can't really see any of the numbers. axiqvvdflxlwwltgavvfbxu
Print a box of any character
jfffavvflflqvvvviifblflflfff
Ackermann function
hhaitbltlanlbailtbbbdaiaaubtbdlqdlavdqslobaublubirdubx
hh # read m and n ait # loop while len(stack) > 1 b # drop stack length l # n m t # loop while m != 0 l # m n anlb # push case2=(n == 0) ail # push case3=1 to below top of stack tb # if case2 b # drop case3 b # drop n d # m -= 1 ai # push n=1 a # push case3=0 aub # endif tb # if case3 d # n -= 1 l # n-1 m qdl # n-1 m-1 m avdqslob # lift 3rd (stack: m-1 m n-1) aub # endif l # n m u b # drop m (== 0) i # n += 1 rd # push len(stack)-1 u b # drop stack length x # print result
Print any string
I have created a script which can convert any string into an SSL program that will print that string. You can find it on tio.run HERE
Example program created with this script:
# Prints "StupidStackLanguage" avvvvvvvvvvvvvvvviiifvvvvvviiififwfwddfwfwwwddfvvvvvviiifwwwwifiifviiifwwwwwwdfvvvvifvviiifwddfvvvdfwwwwfvifddf
Implementations
Website
You can use the website to run SSL code online, however due to being programmed in javascript, it's considerably slower than tio.run, which itself is much slower than saving the python interpreter, which is slower than using the C++ interpreter.
Python
import sys, re f = open(sys.argv[1], "r"); prg = f.read(); f.close(); stack = [] prg = (re.compile('#(?=.*).*',re.IGNORECASE).sub("",prg)) prg = (re.compile('[^abcdefghijklmnopqrstuvwxyz]*', re.IGNORECASE).sub("", prg)) prgPos = 0 shouldSkip = False while prgPos<len(prg): if shouldSkip: shouldSkip = False else: char = prg[prgPos].lower() if char == "a": stack.insert(0,0) elif char == "b": stack.pop(0) elif char == "c": stack.insert(0,stack[0] - stack[1]) elif char == "d": stack[0]-=1 elif char == "e": stack.insert(0,stack[0] % stack[1]) elif char == "f": print(chr(stack[0]),end="") elif char == "g": stack.insert(0,stack[0] + stack[1]) elif char == "h": stack.insert(0,int(input("\nNumber: "))) elif char == "i": stack[0]+=1 elif char == "j": stack.insert(0,ord(input("\nInput: ")[0])) elif char == "k": if stack[0]==0: shouldSkip = True elif char == "l": temp = stack[1] stack[1] = stack[0] stack[0] = temp elif char == "m": stack.insert(0,(stack[0] * stack[1])) elif char == "n": stack.insert(0,int(stack[0]==stack[1])) elif char == "o": stack.pop(stack[0]) elif char == "p": stack.insert(0,stack[0] / stack[1]) elif char == "q": stack.insert(0,stack[0]) elif char == "r": stack.insert(0,len(stack)) elif char == "s": temp = stack[stack[0]] stack[stack[0]] = stack[0] stack[0] = temp elif char == "t": if stack[0] == 0: opened = 0 prgPos += 1 while prgPos < len(prg): if prg[prgPos] == "u" and opened == 0: break elif prg[prgPos] == "t": opened += 1 elif prg[prgPos] == "u": opened -= 1 prgPos += 1 elif char == "u": if stack[0] != 0: closed = 0 prgPos -= 1 while prgPos >= 0: if prg[prgPos] == "t" and closed == 0: break elif prg[prgPos] == "u": closed += 1 elif prg[prgPos] == "t": closed -= 1 prgPos -= 1 elif char == "v": stack[0]+=5 elif char == "w": stack[0]-=5 elif char == "x": print(stack[0],end="") elif char == "y": stack = [] elif char == "z": sys.exit(0) else: print("Invalid character:",char,"at",prgPos); sys.exit(0) prgPos+=1
Usage
> python SSL.py [SSL SCRIPT]
Online
You can use the interpreter online HERE
Get string from program
THIS JS script can take an SSL program that prints something and can tell you what it would print, however it only works with scripts generated by or following the same rules as HERE
Notes
Comments can be written as such:
# Comment