MultiStacker

From Esolang
Jump to navigation Jump to search

MultiStacker is an Esoteric programming language created by Aylias

MultiStacker has what are called functions. Each function is a file, ending in the .stkr extension. When run, the interpreter automatically runs the function titled main. Each function has 4 stacks: integer, float, string, and boolean. There are a lot of commands that can be used.

There are only 4 commands that take in arguments. These commands all explicitly push an object to a stack.

Command Description Example
pushi Pushes the passed argument to the int stack pushi 10
pushf Pushes the passed argument to the float stack pushf 1.5
pushs Pushes the passed argument to the string stack pushs Hello, World!
pushb Pushes the passed argument to the bool stack pushb true

The next table of commands, are commands that can be used on any stack. You specify the stack to use by trailing the command with the initial of the stack, ie printi to execute print on the int stack, or pops to execute pop on the string stack.

Command Description
print Pops and prints out a value from the stack (no newline)
rev Reverses the stack
input Get an input and put it on the stack (It has built in handling for improper inputs, ie putting f in for an int)
clone Clones the top value of a stack
and Pops the top 2 values off the stack, and if they are equal puts a true on the bool stack, otherwise puts false
pop Pops a value off the stack, and does nothing with it
flip flips the position of the top 2 values on the stack
str Pops the top value and puts it on the str stack

The next commands are called numberic commands. They function the same as a above, but only on the int and float stacks, ie opi will execute op on the int stack, and opf will execute op on the float stack.

Command Description
op Performs an operation (popped off the str stack). Operations are explained below
random Pushes a random number between 0 and the number popped off the stack

The next commands are call commands. Call commands call run another function, with the name popped off of the str stack. Call commands can be run to give args or to not. To run a call command without args, just precede it with an a, like this arun. If run with args, it will pop 4 values off the int stack. For each of the 4 stacks in the new function, it will pop and push the previously popped number of values to the stack. The stacks get assigned in this order: int, float, str, bool, so the int stack gets the first of the 4 popped values from earlier, float the second, etc.

Command Description
for Runs the function x amount of times, where x is a number popped off the int stack. The top number on the int stack of the new function is the iteration number.
while As long as the value popped off the bool stack is true, it will run the function repeatedly.
if If the value popped off the top of the bool stack is true, it will run the function
run Runs the function once

Note: You can also precede a command with if_ or for_ to run if or for on that command, ie if_printi or for_pops, and they can be strung together as much as needed, so if_for, for_if, for_for_for_if, etc. Other things you can precede a command with is s_ and m_. s_ will run the command on the function that called the current command. m_ will run the command on the main function. These are useful, due to the fact that each function has its own stack.

Other Commands

Command Description
merge Pops a number off the int stack, and pops that many off of the str stack, and joins them together with a space in between (in the order they were popped), and then puts the result on the str stack
printn Prints a newline
not Inverts the top value of the bool stack
itof Moves the top value of the int stack to the float stack
ftoi Rounds and moves the top value of the float stack to the int stack

Operations are all formatted a op b (ie a + b), and a is always the first of the 2 values popped off of the stack. Some of the operations push a number, others push a bool, but at the end of the operation it pushes true to the bool stack if it was a number, and a false otherwise.

Number Operations

Operation Description
+ Adds the numbers together
- Subtracts the numbers
* or x Multiplies the numbers
/ Divides the numbers
% Does mod on the numbers
^ To the power of

Boolean operations

Operation Description
> Does greater than on the numbers
< Does less than on the numbers
>= Does greater than or equal to on the numbers
<= Does less than or equal to on the numbers

Example Code

Hello, World!

pushs Hello, World!
prints

Truth Machine

main.stkr

pushi 0
pushs Input 0 or 1:
inputi
greateri
pushs ones
awhile
pushi 0
printi

ones.stkr

pushi 1
printi
s_pushb true

Calculator

pushs Input Number A:
pushs Input Number B:
pushs Input Operation:
revs
inputf
inputf
revf
inputs
opf
revb
cloneb
if_strf
not
if_strb
pushs The result was
pushi 2
merge
prints

Please report any issues on the github

Download the interpreter here

Note: Passing any arguments into the interpreter will run in that subdirectory, so if you are in a dir named Projects and you do java -jar stacker.jar Project Name it will run in the Project Name dir.