Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / command / rpn.qc
1 #include "command.qh"
2 #include "rpn.qh"
3
4
5 // ========================================
6 //  RPN command code, written by divVerent
7 //  Last updated: December 28th, 2011
8 // ========================================
9
10 string rpn_pop()
11 {
12         if(rpn_sp > 0) {
13                 --rpn_sp;
14                 return rpn_stack[rpn_sp];
15         } else {
16                 LOG_INFO("rpn: stack underflow\n");
17                 rpn_error = true;
18                 return "";
19         }
20 }
21 void rpn_push(string s)
22 {
23         if(rpn_sp < MAX_RPN_STACK) {
24                 rpn_stack[rpn_sp] = s;
25                 ++rpn_sp;
26         } else {
27                 LOG_INFO("rpn: stack overflow\n");
28                 rpn_error = true;
29         }
30 }
31 string rpn_get()
32 {
33         if(rpn_sp > 0) {
34                 return rpn_stack[rpn_sp - 1];
35         } else {
36                 LOG_INFO("rpn: empty stack\n");
37                 rpn_error = true;
38                 return "";
39         }
40 }
41 void rpn_set(string s)
42 {
43         if(rpn_sp > 0) {
44                 rpn_stack[rpn_sp - 1] = s;
45         } else {
46                 LOG_INFO("rpn: empty stack\n");
47                 rpn_error = true;
48         }
49 }
50
51 float rpn_getf() { return stof(rpn_get()); }
52 float rpn_popf() { return stof(rpn_pop()); }
53 void rpn_pushf(float f) { return rpn_push(sprintf("%.9g", f)); }
54 void rpn_setf(float f) { return rpn_set(sprintf("%.9g", f)); }
55
56 void GenericCommand_rpn(float request, float argc, string command)
57 {
58         switch(request)
59         {
60                 case CMD_REQUEST_COMMAND:
61                 {
62                         float i, j, f, f2, f3, rpnpos;
63                         //vector rgb;
64                         string s, s2, rpncmd;
65
66                         if(!rpn_db)
67                         {
68                                 rpn_db = db_create();
69                                 db_put(rpn_db, "stack.pointer", "0");
70                                 db_put(rpn_db, "stack.pos", "-1");
71                         }
72
73                         if(argc >= 2)
74                         {
75                                 rpn_sp = 0;
76                                 rpn_error = false;
77                                 for(rpnpos = 1; rpnpos < argc; ++rpnpos)
78                                 {
79                                         rpncmd = argv(rpnpos);
80                                         f = strlen(rpncmd);
81                                         if(rpncmd == "") {
82                                         } else if(stof(substring(rpncmd, 0, 1)) > 0) {
83                                                 rpn_push(rpncmd);
84                                         } else if(substring(rpncmd, 0, 1) == "0") {
85                                                 rpn_push(rpncmd);
86                                         } else if(f >= 2 && substring(rpncmd, 0, 1) == "+") {
87                                                 rpn_push(rpncmd);
88                                         } else if(f >= 2 && substring(rpncmd, 0, 1) == "-") {
89                                                 rpn_push(rpncmd);
90                                         } else if(f >= 2 && substring(rpncmd, 0, 1) == "/") {
91                                                 rpn_push(substring(rpncmd, 1, strlen(rpncmd) - 1));
92                                         } else if(rpncmd == "clear") {
93                                                 rpn_sp = 0;
94                                         } else if(rpncmd == "def" || rpncmd == "=") {
95                                                 s = rpn_pop();
96                                                 s2 = rpn_pop();
97
98                                                 if(s2 != "")
99                                                 {
100                                                         #ifdef MENUQC
101                                                         registercvar(s2, "", 0);
102                                                         #else
103                                                         registercvar(s2, "");
104                                                         #endif
105                                                         if(!rpn_error) // don't change cvars if a stack error had happened!
106                                                                 cvar_set(s2, s);
107                                                 }
108                                                 else
109                                                 {
110                                                         LOG_INFO("rpn: empty cvar name for 'def'\n");
111                                                         rpn_error = true;
112                                                 }
113                                         } else if(rpncmd == "defs" || rpncmd == "@") {
114                                                 s = "";
115                                                 i = rpn_popf();
116                                                 j = (i == 0);
117                                                 while(rpn_sp > 1 && (j || i > 0))
118                                                 {
119                                                         s = strcat("/", rpn_pop(), " ", s);
120                                                         --i;
121                                                 }
122                                                 s2 = rpn_pop();
123                                                 if(s2 != "")
124                                                 {
125                                                         #ifdef MENUQC
126                                                         registercvar(s2, "", 0);
127                                                         #else
128                                                         registercvar(s2, "");
129                                                         #endif
130                                                         if(!rpn_error) // don't change cvars if a stack error had happened!
131                                                                 cvar_set(s2, s);
132                                                 }
133                                                 else
134                                                 {
135                                                         LOG_INFO("rpn: empty cvar name for 'defs'\n");
136                                                         rpn_error = true;
137                                                 }
138                                         } else if(rpncmd == "load") {
139                                                 rpn_set(cvar_string(rpn_get()));
140                                         } else if(rpncmd == "exch") {
141                                                 s = rpn_pop();
142                                                 s2 = rpn_get();
143                                                 rpn_set(s);
144                                                 rpn_push(s2);
145                                         } else if(rpncmd == "dup") {
146                                                 rpn_push(rpn_get());
147                                         } else if(rpncmd == "pop") {
148                                                 rpn_pop();
149                                         } else if(rpncmd == "add" || rpncmd == "+") {
150                                                 f = rpn_popf();
151                                                 rpn_setf(rpn_getf() + f);
152                                         } else if(rpncmd == "sub" || rpncmd == "-") {
153                                                 f = rpn_popf();
154                                                 rpn_setf(rpn_getf() - f);
155                                         } else if(rpncmd == "mul" || rpncmd == "*") {
156                                                 f = rpn_popf();
157                                                 rpn_setf(rpn_getf() * f);
158                                         } else if(rpncmd == "div" || rpncmd == "/") {
159                                                 f = rpn_popf();
160                                                 rpn_setf(rpn_getf() / f);
161                                         } else if(rpncmd == "mod" || rpncmd == "%") {
162                                                 f = rpn_popf();
163                                                 f2 = rpn_getf();
164                                                 rpn_setf(f2 - f * floor(f2 / f));
165                                         } else if(rpncmd == "pow" || rpncmd == "**") {
166                                                 f = rpn_popf();
167                                                 rpn_setf(pow(rpn_getf(), f));
168                                         } else if(rpncmd == "bitand" || rpncmd == "&") {
169                                                 f = rpn_popf();
170                                                 rpn_setf(rpn_getf() & f);
171                                         } else if(rpncmd == "bitor" || rpncmd == "|") {
172                                                 f = rpn_popf();
173                                                 rpn_setf(rpn_getf() | f);
174                                         } else if(rpncmd == "bitxor" || rpncmd == "^") {
175                                                 f = rpn_popf();
176                                                 rpn_setf(rpn_getf() ^ f);
177                                         } else if(rpncmd == "and" || rpncmd == "&&") {
178                                                 f = rpn_popf();
179                                                 rpn_setf(rpn_getf() && f);
180                                         } else if(rpncmd == "or" || rpncmd == "||") {
181                                                 f = rpn_popf();
182                                                 rpn_setf(rpn_getf() || f);
183                                         } else if(rpncmd == "xor" || rpncmd == "^^") {
184                                                 f = rpn_popf();
185                                                 rpn_setf(!rpn_getf() != !f);
186                                         } else if(rpncmd == "bitnot") {
187                                                 rpn_setf(~rpn_popf());
188                                         } else if(rpncmd == "not") {
189                                                 rpn_setf(!rpn_popf());
190                                         } else if(rpncmd == "abs") {
191                                                 rpn_setf(fabs(rpn_getf()));
192                                         } else if(rpncmd == "sgn") {
193                                                 f = rpn_getf();
194                                                 if(f < 0)
195                                                         rpn_set("-1");
196                                                 else if(f > 0)
197                                                         rpn_set("1");
198                                                 else
199                                                         rpn_set("0");
200                                         } else if(rpncmd == "neg" || rpncmd == "~") {
201                                                 rpn_setf(-rpn_getf());
202                                         } else if(rpncmd == "floor" || rpncmd == "f") {
203                                                 rpn_setf(floor(rpn_getf()));
204                                         } else if(rpncmd == "ceil" || rpncmd == "c") {
205                                                 rpn_setf(ceil(rpn_getf()));
206                                         } else if(rpncmd == "exp") {
207                                                 rpn_setf(exp(rpn_getf()));
208                                         } else if(rpncmd == "log") {
209                                                 rpn_setf(exp(rpn_getf()));
210                                         } else if(rpncmd == "sin") {
211                                                 rpn_setf(sin(rpn_getf()));
212                                         } else if(rpncmd == "cos") {
213                                                 rpn_setf(cos(rpn_getf()));
214                                         } else if(rpncmd == "max") {
215                                                 f = rpn_popf();
216                                                 f2 = rpn_getf();
217                                                 rpn_setf(max(f2, f));
218                                         } else if(rpncmd == "min") {
219                                                 f = rpn_popf();
220                                                 f2 = rpn_getf();
221                                                 rpn_setf(min(f2, f));
222                                         } else if(rpncmd == "bound") {
223                                                 f = rpn_popf();
224                                                 f2 = rpn_popf();
225                                                 f3 = rpn_getf();
226                                                 rpn_setf(bound(f3, f2, f));
227                                         } else if(rpncmd == "when") {
228                                                 f = rpn_popf();
229                                                 s = rpn_pop();
230                                                 s2 = rpn_get();
231                                                 if(f)
232                                                         rpn_set(s2);
233                                                 else
234                                                         rpn_set(s);
235                                         } else if(rpncmd == ">" || rpncmd == "gt") {
236                                                 f = rpn_popf();
237                                                 rpn_setf(rpn_getf() > f);
238                                         } else if(rpncmd == "<" || rpncmd == "lt") {
239                                                 f = rpn_popf();
240                                                 rpn_setf(rpn_getf() < f);
241                                         } else if(rpncmd == "==" || rpncmd == "eq") {
242                                                 f = rpn_popf();
243                                                 rpn_setf(rpn_getf() == f);
244                                         } else if(rpncmd == ">=" || rpncmd == "ge") {
245                                                 f = rpn_popf();
246                                                 rpn_setf(rpn_getf() >= f);
247                                         } else if(rpncmd == "<=" || rpncmd == "le") {
248                                                 f = rpn_popf();
249                                                 rpn_setf(rpn_getf() <= f);
250                                         } else if(rpncmd == "!=" || rpncmd == "ne") {
251                                                 f = rpn_popf();
252                                                 rpn_setf(rpn_getf() != f);
253                                         } else if(rpncmd == "rand") {
254                                                 rpn_setf(ceil(random() * rpn_getf()) - 1);
255                                         } else if(rpncmd == "crc16") {
256                                                 rpn_setf(crc16(false, rpn_get()));
257                                         } else if(rpncmd == "put") {
258                                                 s2 = rpn_pop();
259                                                 if (!rpn_error)
260                                                 {
261                                                         s = rpn_pop();
262                                                         if (!rpn_error)
263                                                                 db_put(rpn_db, s, s2);
264                                                 }
265                                         } else if(rpncmd == "get") {
266                                                 s = rpn_pop();
267                                                 if (!rpn_error)
268                                                         rpn_push(db_get(rpn_db, s));
269                                         } else if(rpncmd == "dbpush") {
270                                                 s = rpn_pop();
271                                                 if(!rpn_error)
272                                                 {
273                                                         i = stof(db_get(rpn_db, "stack.pointer"));
274                                                         db_put(rpn_db, "stack.pointer", ftos(i+1));
275                                                         db_put(rpn_db, strcat("stack.", ftos(i)), s);
276                                                         if(!i)
277                                                                 db_put(rpn_db, "stack.pos", "0");
278                                                 }
279                                         } else if(rpncmd == "dbpop") {
280                                                 i = stof(db_get(rpn_db, "stack.pointer"));
281                                                 if(i)
282                                                 {
283                                                         s = ftos(i-1);
284                                                         db_put(rpn_db, "stack.pointer", s);
285                                                         rpn_push(db_get(rpn_db, strcat("stack.", s)));
286                                                         j = stof(db_get(rpn_db, "stack.pos"));
287                                                         if(j >= i)
288                                                                 db_put(rpn_db, "stack.pos", ftos(i-2));
289                                                 } else {
290                                                         rpn_error = 1;
291                                                         LOG_INFO("rpn: database underflow\n");
292                                                 }
293                                         } else if(rpncmd == "dbget") {
294
295                                                 i = stof(db_get(rpn_db, "stack.pointer"));
296                                                 if(i)
297                                                 {
298                                                         rpn_push(db_get(rpn_db, strcat("stack.", ftos(i-1))));
299                                                 } else {
300                                                         rpn_error = 1;
301                                                         LOG_INFO("rpn: database empty\n");
302                                                 }
303                                         } else if(rpncmd == "dblen") {
304                                                 rpn_push(db_get(rpn_db, "stack.pointer"));
305                                         } else if(rpncmd == "dbclr") {
306                                                 db_close(rpn_db);
307                                                 rpn_db = db_create();
308                                                 db_put(rpn_db, "stack.pointer", "0");
309                                                 db_put(rpn_db, "stack.pos", "-1");
310                                         } else if(rpncmd == "dbsave") {
311                                                 s = rpn_pop();
312                                                 if(!rpn_error)
313                                                         db_save(rpn_db, s);
314                                         } else if(rpncmd == "dbload") {
315                                                 s = rpn_pop();
316                                                 if(!rpn_error)
317                                                 {
318                                                         db_close(rpn_db);
319                                                         rpn_db = db_load(s);
320                                                 }
321                                         } else if(rpncmd == "dbins") {
322                                                 s = rpn_pop();
323                                                 if(!rpn_error)
324                                                         //if(rpn_sp > 0)
325                                                 {
326                                                         j = stof(db_get(rpn_db, "stack.pointer"));
327                                                         i = stof(db_get(rpn_db, "stack.pos"));
328
329                                                         if(i < 0)
330                                                         {
331                                                                 i = 0;
332                                                                 db_put(rpn_db, "stack.pos", "0");
333                                                         }
334
335                                                         db_put(rpn_db, "stack.pointer", ftos(j+1));
336                                                         for(--j; j >= i; --j)
337                                                         {
338                                                                 db_put(rpn_db, strcat("stack.", ftos(j+1)),
339                                                                                          db_get(rpn_db, (strcat("stack.", ftos(j))))
340                                                                         );
341                                                         }
342                                                         db_put(rpn_db, strcat("stack.", ftos(i)), s);
343                                                 }
344                                         } else if(rpncmd == "dbext") {
345                                                 j = stof(db_get(rpn_db, "stack.pointer"));
346                                                 i = stof(db_get(rpn_db, "stack.pos"));
347                                                 if(!j)
348                                                 {
349                                                         rpn_error = true;
350                                                         LOG_INFO("rpn: empty database\n");
351                                                 } else {
352                                                         --j;
353                                                         rpn_push(db_get(rpn_db, strcat("stack.", ftos(i))));
354                                                         db_put(rpn_db, "stack.pointer", ftos(j));
355                                                         if(i == j)
356                                                         {
357                                                                 db_put(rpn_db, "stack.pos", ftos(j-1));
358                                                         } else {
359                                                                 while(i < j)
360                                                                 {
361                                                                         db_put(rpn_db, strcat("stack.", ftos(i)),
362                                                                                                  db_get(rpn_db, (strcat("stack.", ftos(i+1))))
363                                                                                 );
364                                                                         ++i;
365                                                                 }
366                                                         }
367                                                 }
368                                         } else if(rpncmd == "dbread") {
369                                                 s = db_get(rpn_db, "stack.pos");
370                                                 if(stof(s) >= 0)
371                                                 {
372                                                         rpn_push(db_get(rpn_db, strcat("stack.", s)));
373                                                 } else {
374                                                         rpn_error = 1;
375                                                         LOG_INFO("rpn: empty database\n");
376                                                 }
377                                         } else if(rpncmd == "dbat") {
378                                                 rpn_push(db_get(rpn_db, "stack.pos"));
379                                         } else if(rpncmd == "dbmov") {
380                                                 j = stof(db_get(rpn_db, "stack.pointer"));
381                                                 i = stof(db_get(rpn_db, "stack.pos"));
382                                                 i += rpn_popf();
383                                                 if(!rpn_error)
384                                                 {
385                                                         if(i < 0 || i >= j)
386                                                         {
387                                                                 LOG_INFO("rpn: database cursor out of bounds\n");
388                                                                 rpn_error = true;
389                                                         }
390                                                         if(!rpn_error)
391                                                         {
392                                                                 db_put(rpn_db, "stack.pos", ftos(i));
393                                                         }
394                                                 }
395                                         } else if(rpncmd == "dbgoto") {
396                                                 s = rpn_pop();
397                                                 j = stof(db_get(rpn_db, "stack.pointer"));
398                                                 if(!j)
399                                                 {
400                                                         rpn_error = true;
401                                                         LOG_INFO("rpn: empty database, cannot move cursor\n");
402                                                 }
403                                                 if(!rpn_error)
404                                                 {
405                                                         if(s == "end")
406                                                                 i = stof(db_get(rpn_db, "stack.pointer"))-1;
407                                                         else if(s == "beg")
408                                                                 i = 0;
409                                                         else
410                                                                 i = stof(s);
411
412                                                         j = stof(db_get(rpn_db, "stack.pointer"));
413                                                         if(i < 0 || i >= j)
414                                                         {
415                                                                 LOG_INFO("rpn: database cursor destination out of bounds\n");
416                                                                 rpn_error = true;
417                                                         }
418                                                         if(!rpn_error)
419                                                         {
420                                                                 db_put(rpn_db, "stack.pos", ftos(i));
421                                                         }
422                                                 }
423                                         } else if(rpncmd == "union") {
424                                                 // s s2 union
425                                                 s2 = rpn_pop();
426                                                 s = rpn_get();
427                                                 f = tokenize_console(s);
428                                                 f2 = tokenize_console(strcat(s, " ", s2));
429                                                 // tokens 0..(f-1) represent s
430                                                 // tokens f..f2 represent s2
431                                                 // UNION: add all tokens to s that are in s2 but not in s
432                                                 s = "";
433                                                 for(i = 0; i < f; ++i)
434                                                         s = strcat(s, " ", argv(i));
435                                                 for(i = f; i < f2; ++i) {
436                                                         for(j = 0; j < f; ++j)
437                                                                 if(argv(i) == argv(j))
438                                                                         goto skip_union;
439                                                         s = strcat(s, " ", argv(i));
440                                                         :skip_union
441                                                 }
442                                                 if(substring(s, 0, 1) == " ")
443                                                         s = substring(s, 1, 99999);
444                                                 rpn_set(s);
445                                                 tokenize_console(command);
446                                         } else if(rpncmd == "intersection") {
447                                                 // s s2 intersection
448                                                 s2 = rpn_pop();
449                                                 s = rpn_get();
450                                                 f = tokenize_console(s);
451                                                 f2 = tokenize_console(strcat(s, " ", s2));
452                                                 // tokens 0..(f-1) represent s
453                                                 // tokens f..f2 represent s2
454                                                 // INTERSECTION: keep only the tokens from s that are also in s2
455                                                 s = "";
456                                                 for(i = 0; i < f; ++i) {
457                                                         for(j = f; j < f2; ++j)
458                                                                 if(argv(i) == argv(j))
459                                                                 {
460                                                                         s = strcat(s, " ", argv(i));
461                                                                         break;
462                                                                 }
463                                                 }
464                                                 if(substring(s, 0, 1) == " ")
465                                                         s = substring(s, 1, 99999);
466                                                 rpn_set(s);
467                                                 tokenize_console(command);
468                                         } else if(rpncmd == "difference") {
469                                                 // s s2 difference
470                                                 s2 = rpn_pop();
471                                                 s = rpn_get();
472                                                 f = tokenize_console(s);
473                                                 f2 = tokenize_console(strcat(s, " ", s2));
474                                                 // tokens 0..(f-1) represent s
475                                                 // tokens f..f2 represent s2
476                                                 // DIFFERENCE: keep only the tokens from s that are not in s2
477                                                 s = "";
478                                                 for(i = 0; i < f; ++i) {
479                                                         for(j = f; j < f2; ++j)
480                                                                 if(argv(i) == argv(j))
481                                                                         goto skip_difference;
482                                                         s = strcat(s, " ", argv(i));
483                                                         :skip_difference
484                                                 }
485                                                 if(substring(s, 0, 1) == " ")
486                                                         s = substring(s, 1, 99999);
487                                                 rpn_set(s);
488                                                 tokenize_console(command);
489                                         } else if(rpncmd == "shuffle") {
490                                                 // s shuffle
491                                                 s = rpn_get();
492                                                 f = tokenize_console(s);
493
494                                                 for(i = 0; i < f - 1; ++i) {
495                                                         // move a random item from i..f-1 to position i
496                                                         s = "";
497                                                         f2 = floor(random() * (f - i) + i);
498                                                         for(j = 0; j < i; ++j)
499                                                                 s = strcat(s, " ", argv(j));
500                                                         s = strcat(s, " ", argv(f2));
501                                                         for(j = i; j < f; ++j)
502                                                                 if(j != f2)
503                                                                         s = strcat(s, " ", argv(j));
504                                                         f = tokenize_console(s);
505                                                 }
506
507                                                 if(substring(s, 0, 1) == " ")
508                                                         s = substring(s, 1, 99999);
509                                                 rpn_set(s);
510                                                 tokenize_console(command);
511                                         } else if(rpncmd == "fexists_assert") {
512                                                 s = rpn_pop();
513                                                 if(!rpn_error)
514                                                 {
515                                                         if (!fexists(s))
516                                                         {
517                                                                 LOG_INFO("rpn: ERROR: ", s, " does not exist!\n");
518                                                                 rpn_error = true;
519                                                         }
520                                                 }
521                                         } else if(rpncmd == "fexists") {
522                                                 s = rpn_get();
523                                                 if(!rpn_error)
524                                                 {
525                                                         if (fexists(s))
526                                                                 rpn_setf(1);
527                                                         else
528                                                                 rpn_setf(0);
529                                                 }
530                                         } else if(rpncmd == "localtime") {
531                                                 rpn_set(strftime(true, rpn_get()));
532                                         } else if(rpncmd == "gmtime") {
533                                                 rpn_set(strftime(false, rpn_get()));
534                                         } else if(rpncmd == "time") {
535                                                 rpn_pushf(time);
536                                         } else if(rpncmd == "digest") {
537                                                 s = rpn_pop();
538                                                 rpn_set(digest_hex(s, rpn_get()));
539                                         } else if(rpncmd == "sprintf1s") {
540                                                 s = rpn_pop();
541                                                 rpn_set(sprintf(s, rpn_get()));
542                                         } else if(rpncmd == "eval") {
543                                                 s = rpn_pop();
544                                                 command = strcat(s, substring(command, argv_end_index(rpnpos), -1));
545                                                 argc = tokenize_console(command);
546                                                 rpnpos = -1;
547                                         } else {
548                                                 rpn_push(cvar_string(rpncmd));
549                                         }
550                                         if(rpn_error)
551                                                 break;
552                                 }
553                                 while(rpn_sp > 0)
554                                 {
555                                         s = rpn_pop();
556                                         LOG_INFO("rpn: still on stack: ", s, "\n");
557                                 }
558                         }
559
560                         return;
561                 }
562
563                 default:
564                 case CMD_REQUEST_USAGE:
565                 {
566                         LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " rpn EXPRESSION...\n"));
567                         LOG_INFO("    Operator description (x: string, s: set, f: float):\n");
568                         LOG_INFO("    x pop ----------------------------->     : removes the top\n");
569                         LOG_INFO("    x dup -----------------------------> x x : duplicates the top\n");
570                         LOG_INFO("    x x exch --------------------------> x x : swap the top two\n");
571                         LOG_INFO("    /cvarname load --------------------> x   : loads a cvar\n");
572                         LOG_INFO("    /cvarname x def ------------------->     : writes to a cvar\n");
573                         LOG_INFO("    f f add|sub|mul|div|mod|pow -------> f   : adds/... two numbers\n");
574                         LOG_INFO("    f f and|or|xor|bitand|bitor|bitxor > f   : logical and bitwise operations\n");
575                         LOG_INFO("    f f eq|ne|gt|ge|lt|le|max|min -----> f   : compares two numbers\n");
576                         LOG_INFO("    f neg|abs|sgn|rand|floor|ceil------> f   : negates/... a number\n");
577                         LOG_INFO("    f not|bitnot ----------------------> f   : logical and bitwise negation\n");
578                         LOG_INFO("    f exp|log|sin|cos -----------------> f   : exponential function & Co.\n");
579                         LOG_INFO("    f f f bound -----------------------> f   : bounds the middle number\n");
580                         LOG_INFO("    f1 f2 b when ----------------------> f   : f1 if b, f2 otherwise\n");
581                         LOG_INFO("    s s union|intersection|difference -> s   : set operations\n");
582                         LOG_INFO("    s shuffle -------------------------> s   : randomly arrange elements\n");
583                         LOG_INFO("    /key /value put ------------------->     : set a database key\n");
584                         LOG_INFO("    /key get --------------------------> s   : get a database value\n");
585                         LOG_INFO("    x dbpush -------------------------->     : pushes the top onto the database\n");
586                         LOG_INFO("    dbpop|dbget -----------------------> x   : removes/reads DB's top\n");
587                         LOG_INFO("    dblen|dbat ------------------------> f   : gets the DB's size/cursor pos\n");
588                         LOG_INFO("    dbclr ----------------------------->     : clear the DB\n");
589                         LOG_INFO("    s dbsave|dbload-------------------->     : save/load the DB to/from a file\n");
590                         LOG_INFO("    x dbins --------------------------->     : moves the top into the DB\n");
591                         LOG_INFO("    dbext|dbread ----------------------> x   : extract/get from the DB's cursor\n");
592                         LOG_INFO("    f dbmov|dbgoto -------------------->     : move or set the DB's cursor\n");
593                         LOG_INFO("    s localtime -----------------------> s   : formats the current local time\n");
594                         LOG_INFO("    s gmtime --------------------------> s   : formats the current UTC time\n");
595                         LOG_INFO("    time ------------------------------> f   : seconds since VM start\n");
596                         LOG_INFO("    s /MD4 digest ---------------------> s   : MD4 digest\n");
597                         LOG_INFO("    s /SHA256 digest ------------------> s   : SHA256 digest\n");
598                         LOG_INFO("    s /formatstring sprintf1s ---------> s   : sprintf with 1 string (pad, cut)\n");
599                         LOG_INFO("    s eval ---------------------------->     : does something eval\n");
600                         LOG_INFO("    Set operations operate on 'such''strings'.\n");
601                         LOG_INFO("    Unknown tokens insert their cvar value.\n");
602                         return;
603                 }
604         }
605 }