Skip to content

Instantly share code, notes, and snippets.

@nekodjin
Last active October 24, 2021 17:21
Show Gist options
  • Save nekodjin/7dd816a606e49de6a0f575ee6fc2ebcd to your computer and use it in GitHub Desktop.
Save nekodjin/7dd816a606e49de6a0f575ee6fc2ebcd to your computer and use it in GitHub Desktop.

YeetSkeet is a stack-based language which uses a primary stack and a secondary stack. for both stacks, the each element shall be exactly one byte.

a program consists of an ordered list of instructions.

YeetSkeet instructions:

0  : push byte 0 to the stack
1  : push byte 1 to the stack
"x : push ascii value of x (which is an ascii char) to the stack
.  : pop from stack, print as ascii
,  : get byte of input, push to stack
j  : pop from stack, push to second stack
k  : pop from second stack, push to stack
c  : duplicate top value
d  : drop top value
s  : swap top 2 values
e  : exit (success) (exit code 0)
f  : exit (failure) (exit code 1)
+  : pop top 2 values,      add, push result
-  : pop top 2 values, subtract, push result
*  : pop top 2 values, multiply, push result
/  : pop top 2 values,   divide, push result (integral division)
%  : pop top 2 values,  modulus, push result
&  : pop top 2 values,   bw and, push result (bw = bitwise)
|  : pop top 2 values,   bw  or, push result
^  : pop top 2 values,   bw xor, push result
~  : bw not top value
!  : logical not top value (C semantics)
$x : label, where x is an ascii char
@x : unconditional jump to $x
#x : pop top value from stack, jump if zero to $x

"stack", not preceded by the word "second", shall always refer to the primary stack. "second stack" shall always refer to the secondary stack.

a program begins execution at the first instruction in its source.

if a pop is attempted from either stack while it is empty, program shall exit w/ exit code 2. this means that $gd@g can be used to augment f, but it is not recommended.

if the end of the program is reached, execution will continue at the beginning of the program.

when not preceded by one of $, @, #, ", whitespace is to be ignored by compliant implementations.

any program source containing any characters not listed above as instructions, not preceded by one of $, @, #, ", shall be considered malformed.

any program source in which any of $, @, #, " are directly followed by EOF shall be considered malformed.

compliant implementations should emit an error upon receiving a malformed program, and abort further compilation/interpretation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment