summaryrefslogtreecommitdiff
path: root/reference.md
blob: 1938d5f767706268446cb9e61ed697e53acffa09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
POSTRUN STDLIB REFERENCE
========================

word | meaning
-----|---------
a b `+` | Add two numbers, concat two arrays, push an item on an array on either side or concat strings
a b `-` | Subtract two numbers
a b `*` | Multiply two numbers
a b `/` | Divide two numbers (integer division)
a b `%` | Modulo operator
a b `&` | Bitwise and
a b `\|` | Bitwise or
a `~` | Bitwise inverse
a b `^` | Number to the power of number
a `!` | Boolean 'not'
a b `=` | Test for equality (true: 1, false: 0)
a b `<` | Test for being less than
a b `>` | Test for being greater than
v `print` | Print the given value
`lf` | Print a newline
`getline` | Get a line from stdin
`getc` | Get a character from stdin
h s `fprint` | Print string `s` to handle `h`
h `flf` | Prints a newline to handle `h`
h `fgetc` | Gets a character from handle `h`
f `fopen` | Opens file with name `f`, returns the handle
`argc` | The number of command-line arguments the script got
i `argvget` | Gets the command-line argument at index `i`
v `dup` | Duplicate top of stack
`pop` | Pop top of stack
a b `swap` | Swap top two stack elements
v n `store` | Store value `v` in variable with name `n`
v n `gstore` | Store value `v` in variable, in previous scope, with name `n`
n `get` | Get value of variable with name `n`
n `swapoutvar` | Get value of variable with name `n`, *moving* onto the stack instead of copying
`enterscope` | Enter a function variable scope
`leavescope` | Leave a function variable scope
n `roll` | Roll the stack by `n`; positive n: roll OFF top to bottom; negative n: roll off bottom ONTO top
s i `stridx` | Gets the character in string `s` index `i`, leaving `s` on the stack
s `strlen` | Gets the length of string `s`, leaving `s` on the stack
s a b `substr` | Gets the substring in `s` from index `a` to `b`, `b` exclusive; leaving `s` on the stack
a `chr` | Converts the ascii value on the stack to the equivalent character (as a string)
s `ord` | Gets the ascii value of the first character in string `s` (replacing `s`)
`mkarray` | Creates an empty array on the stack
[v...] n `mkarrayp` | Takes `n` elements off the stack and creates a new array with these `n` elements
a i `arridx` | Gets index `i` from array `a`, leaving `a` on the stack
a `arrlen` | Gets the length of array `a`, leaving `a` on the stack
a v `arrpush` | Pushes the value `v` on the end of array `a` (leaving `a` on the stack, obviously)
a v `arrpushf` | Pushes the value `v` at the front of array `a` (leaving `a` on the stack, obviously)
a `arrpop` | Pops from the end of array `a` (leaving `a` on the stack, obviously)
a `arrpopf` | Pops from the front of array `a` (leaving `a` on the stack, obviously)
`rand` | Gets a random value in range [0,2^31)
a b `randr` | Gets a random value in range [a,b)
u `sleep` | Sleeps for `u` microseconds
`stackdump` | Dumps the stack to stdout
`error` | Exists the program with code 1
`exit` | Exists the program with code 0 (successfully)