syntax | meaning | |
x | identifier. maximum 8 characters, including namespace | |
@x | label | |
@@x | goto label | |
:x | begin namespace. all subsequent identifiers starting with . will be prefixed with x , until the beginning of next namespace | |
.y | expands to x.y , given current namespace x . works for both labels and variables. (e.g. @.y expands to @x.y ) | |
@. | unnamed label | |
@@. | goto next unnamed label (scanning downward from current position, wrapping to the top upon reaching bottom) | |
^ x | push x onto stack | |
-> x | pop one from stack, assign it to new variable x | |
=> x | pop one from stack, assign it to existing variable x | |
~ | value: the last item on stack, which is popped upon reading | |
# | value: the length of stack | |
"hi" | push values 0x68 ('h'), 0x69 ('i'), 2 (length) onto stack. this is the representation for strings used by std lib functions | |
>@@ | pop a string from stack, goto the label whose name matches the string | |
@:x | shorthand for namespace + label, expands to @x :x | |
% | save the position of the last executed goto ("return address") | |
%% | goto right after the position saved by the previous % , rewinding the frame (paired with % to simulate function calls). If already at the top level, exit the program | |
%%. | goto right after the position of the last executed goto ("un-goto") | |
? | pop one from stack, if it is not zero, evaluate the next token, otherwise, skip one token and evaluate the next. push the result (if any) onto the stack. (e.g. ^ 1 ? 2 3 pushes 2 , while ^ 1 ? @@. * does not by itself) | |
* | noop | |
;ok; | comments are enclosed by pairs of ; | |
operator | meaning | |
>> | pop the last string on stack and print it | |
>>| | pop the last string on stack and print it with a newline | |
peek i | copy the i th item on the stack and push it to the top, negative indices count from the top, positive indices count from the bottom. all "indices" mentioned below follow this convention | |
droq i | drop all higher items on the stack starting from index i | |
edit i x | change the i th item on the stack to x | |
roll i j | roll all higher items on the stack starting from index i , by j steps. positive j rolls toward the top, negative j rolls toward the bottom. (e.g. ^1^2^3^4 roll -3 1 gives 1 4 2 3 ) | |
rev i | reverse the order of all higher items on the stack starting from index i | |
ntos x | convert number x to a string and push it onto the stack | |
ston | read the last string from the stack, convert it to a number, and push it onto the stack | |
sub x y | subtraction (x-y). pushes result onto stack. other math functions of arity 2: add , mul , div , fmod , lt , gt , leq , geq , eq , neq , atn2 , pow | |
imod x y | push both integer division (x//y ) and integer modulo (x%y ) onto stack | |
abs x | absolute value. pushes result onto stack. other math functions of arity 1: flor , ceil , rond , eqz (==0), sin , cos , exp , ln , asin , acos | |
vand x y | logical AND, eager evaluation (no short-circuit). OR counterpart: vor . pushes result onto stack. | |
uand x y | unsigned bitwise AND. converts to uint16_t and back. also: uor , unot , uxor , ushl , ushr . pushes result onto stack. | |
rand | pushes a uniformly random float from 0 to 1 onto stack | |
srnd x | set random seed to x | |
^^ x n | push x to stack n times (shorthand for ^ x ^ x ^ x ^ x ... ) | |