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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
## Input and Output operations
- INP
_Input_
**put 1 str**
Get a string from the active in-stream (cin is default), terminated by the set in-stream termination character (newline is default)
- OUT
_Output_
**pop 1 str**
Put a string in the active out-stream (cout is default), terminated by the set out-stream termination character (newline is default)
- IFI
_Input File_
**pop 1 str**
**put 1 int**
Get a filename, open that file for reading and set the active in-stream to that file. Returns a boolean value with true for succes and false for any error that has occured while trying to open the file.
- OFI
_Output File_
**pop 1 str**
**put 1 int**
Get a filename, open that file for writing and set the active out-stream to that file. Returns a boolean value with true for succes and false for any error that has occured while trying to open the file.
- IUS
_Input User_
Set the active in-stream to cin and if required close the file previously set as the active in-stream.
- OUS
_Output User_
Set the active out-stream to cout and if required close the file previously set as the active out-stream.
- ICH
_Input Character_
**pop 1 str**
Change the in-stream termination character (newline is default).
- OCH
_Output Character_
** pop 1 str **
Change the out-stream termination character (newline is default).
## Tree operations
- PSH
_Push_
**pop 1 int**
Take the root node and its secondary children and put it between the n-th and (n+1)-th primary child of the root node. Negative numbers invoke a PLL with that number's absolute value.
- PLL
_Pull_
**pop 1 int**
Take the n-th node and its secondary children and make it the root node, with the previous root node as its primary child. Negative numbers invoke a PSH with that number's absolute value.
- SWP
_Swap_
Swap the root node's primary and secondary child.
- POP
_Pop_
Remove the root node and its secondary children from the tree, making the previous root node's primary child the root node.
- DUP
_Duplicate_
Copy the root node and its secondary children and make it the root node, making the previous root node the new root node's primary child.
- GRB
_Grab_
**pop 1 int**
Take n generations of primary children of the root node with all of their secondary children and insert them between the root node and the root node's secondary child.
- REL
_Release_
**pop 1 int**
Take n-1 generations of primary children of the root node's secondary child and the root node's secondary child itself with all of their secondary children and insert them between the root node and and the root node's primary child.
## Datatypes
- INT
_Integer_
**pop 1 datatype**
**put 1 int**
Convert datatype to integer. When impossible, the NaN type is put instead of an integer.
- FLT
_Floating point_
**pop 1 datatype**
**put 1 flt**
Convert datatype to floating point. When impossible, the NaN type is put instead of a floating point.
- STR
_String_
**pop 1 datatype**
**put 1 str**
Convert datatype to string. This always succeeds.
- NAN
_Not a Number_
**put 1 nan**
Put a Not a Number type.
- LEN
_Length_
**pop 1 str**
**put 1 int**
Put the number of characters in the string. If the datatype is not a string, NaN is put instead of an integer.
- SPL
_Split_
**pop 1 int**
**put 1 str**
Split the string at the root node (when the int is popped) in two between the the (n-1)-th and the n-th character from the beginning of the string for positive numbers and between the (length-n-1)-th and the (length-n)-th character for negative values of n. For all values for n that are out of string bounds or if no string was found at all, throw an error.
## Math, Arithmetic and Bitwise operators
All operations are applied on the root node and optionaly its primary child as first and second parameter. One of these parameters is allowed to have secondary children, on which the operation is also executed. This allows for a large number of operations in a small number of commands.
All math and arithmetic functions work for the integer and floating point type. The operation will return a floating point, when one of the parameters is a floating point. Otherwise it will return an integer.
Bitwise operators require integers, although the SUM and PRO operations work on strings as well.
Operations on illegal types will throw an error, and math errors will result in the NaN type. (ex. 1/0 -> NaN)
- SUM
_Sum_
1. The sum of two numbers.
2. Concatenation of two strings.
- DIF
_Difference_
The difference between two numbers
- PRO
_Product_
1. The product of two numbers
2. A number of times a string concatenated to itself.
- QUO
_Quotient_
The quotient of two numbers
- POW
_Power_
The first parameter raised to the second parameter's power.
- ROO
_Root_
The first parameter's root of the first parameter's degree.
- LOG
_Logarithm_
The second parameter's log of the first parameter.
- MOD
_Modulo_
The remainder of a division of the first and second parameter.
- SIG
_Sigma/Summation_
The sum of the root node and all its secondary children.
- PI\_
_Pi/Product_
The product of the root node and all its secondary children.
- OR\_
_Bitwise Or_
The bitwise or of two integers.
- AND
_Bitwise And_
The bitwise and of two integers.
- XOR
_Bitwise Xor_
The bitwise xor of two integers.
- INV
_Bitwise Invert_
The bitwise inversion of an integer.
- NOT
_Not_
A boolean not of an integer. (equal to n<1)
- EQU
_Equal_
Compare to datatypes and put true when they are equal and otherwise put false.
- NEQ
_Not Equal_
Compare to datatypes and put true when they are not equal and otherwise put false.
- SML
_Smaller than_
Compare to datatypes and put true when the first is smaller than the second and otherwise put false.
- GRT
_Greater than_
Compare to datatypes and put true when the first is greater than the second and otherwise put false.
## Constants and Generated Variables
- TAU
_Tau_
**put 1 flt**
Put the ratio of a circle's circumference to its radius, equal to 2π.
- E__
_e_
**put 1 flt**
Put Euler's number.
- RND
_Random_
**put 1 int**
Put a random integer between zero and an implementation-defined number, at least 32767, inclusively.
## Loops and Conditions
- JMP
_Jump_
**pop 1 int**
Let the n-th command be the next one.
- EXJ
_Extended Jump_
**pop 1 int**
**put 1 int**
Let the n-th command be the next and put back an integer with the position of the command after this EXJ.
Useful for functions.
- IFJ
_If Jump_
**pop 1 int**
If the second parameter is true, jump to the first parameters position.
- STP
_Stop_
Terminate the program
## Debug functions
- STK
_Stack_
Output the stack without popping anything.
## Literals
Integers and floating points are written down as one normally would, accepting an 'e' for an exponent, a minus sign in front for negative and a dot ('.') as the decimal separator. Strings are enclosed in "double quotes" and comments in 'single quotes' or, more preferably, in {braces}.
Special characters in strings can be written down as they are, with the sole exception of the double quote ("), which cannot be put in a string literal.
Bare literals in the code get pushed into the tree such that the old root node becomes the first child of the newly pushed thing, and thus the newly pushed thing becomes the new root node.
|