VarStack

From Esolang
Jump to navigation Jump to search

VarStack is an esolang by User:ChuckEsoteric08 where all variables are 1-character stacks.

Specification

Commands look like this:

X;Y;Z

Declare label X, execute command Y and jump to label Z. If you are trying to access non-existing label, stack element, or stack itself then program will halt.

@X:Y Create new stack called X with initial element(s) Y
$X:Y Push X to stack Y.
!X Pop element from stack X and discard it
"X Output X
'X Output stack X
?X Ask for input and push it to stack X
#X=Y:Z If top of the stack X is equal to Y jump to label Z
!X=Y:Z If top of the stack X is not equal to Y jump to label Z
%X=Y:Z If top of the stack X is equal top of the stack Y jump to label Z
~X Swap top two elements in stack X
&X Reverse stack X
^X Move top of the stack X to the bottom

Examples

Hello, World!

hello;"Hello, World!;halt

Truth-machine

start;@X:0;input
input;?X;if
if;#X=0:print0;print1
print1;"1;print1
print0;"0;halt

Bitwise Cyclic Tag interpreter

You should input program by character. Then input @ and input data. After you inputed data input @ again.

initprogram;@code:0;initprogramfinish
initprogramfinish;!code;initdata
initdata;@data:0;initdatafinish
initdatafinish;!data;inputcode
inputcode1;?code;inputcode2
inputcode2;#code=@:inputcode3;inputcode1
inputcode3;!code;inputcode4
inputcode4;&code;inputdata1
inputdata1;?data;inputdata2
inputdata2;#data=@:inputdata3;inputdata1
inputdata3;!data;inputdata4
inputdata4;&data;interpet
interpret;#code=0:remove;if1
remove;!data;move
if1;#data=1;nextinstruction;move
nextinstruction;^code;reverse
reverse;&data;enq
enq;#code=0:enq0;enq1
enq0;$0:data;endenq
enq1;$1:data;endenq
endenq;&data;interpret
move;^code;interpret