Stackish
Jump to navigation
Jump to search
Paradigm(s) | imperative |
---|---|
Designed by | ender_scythe |
Appeared in | 2016 |
Memory system | stack-based |
Computational class | Turing complete |
Major implementations | Original |
Influenced by | Befunge (loosely) |
File extension(s) | .stk |
Stackish was a venture into stack-based programming by ender_scythe in November, 2016.
Language overview
In Stackish nearly every command alters the stack somehow.
Stackish has 28 commands.
Note: character numbers start at 0.
Command | Description |
---|---|
0-9
|
Pushes this number to stack. |
"number/string"
|
Pushes this number/these characters's values to stack. |
+
|
Pop last two numbers, add and push result to stack. |
-
|
Pop last two numbers, subtract second to last from last and push result to stack.
|
i=/!/>/<...'
|
Pop last two numbers, if second to last (equal/not equal/greater/less) last do... |
j
|
Pop last number and jump to that character number. |
l<character number>'
|
Jump to the character number <character number>. If the command is l' jump to 0th character.
|
k
|
Pop last number, if the stack is empty after pop, jump to the character number that was popped. |
r
|
Generate random number and push that to the stack. |
q
|
Pop last number from the "popped" stack and push to "main" stack (referred to as the stack). |
p
|
Pop last number from the stack. |
.
|
Pop last number and output (as integer). |
,
|
Pop last number and output (as ASCII). |
:
|
Get input and push to stack (if ASCII, push first character's value). |
;
|
Get input and push to stack (as if it were "number/string" ).
|
z
|
Pause until keypress. |
c
|
Clear the screen. |
\
|
Swap last number of the stack with the first. |
/
|
Swap last two numbers of the stack. |
d
|
Duplicate the last number of the stack and push to stack. |
Canonical stuff
If you are making a Stackish interpreter/compiler, keep these things in mind.
- When popping, push the pop into the opposite stack. So if I'm popping from the "main" stack I would push to the "popped" stack, but if I was popping from the "popped" stack, I would push to the "main" stack. This ensures that the
q
command works properly. - If possible; have
r
generate a number from 0 to 2,147,483,647.
Examples
This prints Hello, World! to the screen.
"!dlroW ,olleH",l15'
This prints a random number after every pause.
r.zcl'
This prints the next Fibonacci number after ever pause (1,2,3,5,8,13...)
01d\+.qzcl2'
External resources
- Original Interpreter (Dead link)