📄 crbeqlib.c
字号:
/*
TODO:
0. make it a flag to force integer prior to one of the ops that
needs it (i.e. <<,!,etc.) by inserting an RINT into the EQ
1. make Store and PreStore use linked lists of arrays of 64 members
2. various optimization stuff
3. There's some kind of bug if you turn off the OPTIMIZE flag
*/
/*
*
*
*** THE CRBEQ OPTIMIZING EQUATION COMPILER ****
*
*
* 12-8-95 : no known bugs
*
**********
NOTES :
**********
EQ is in reverse polish :
i.e. :
9
SIN
4
+
means
sin(9) + 4
-------
key to usage :
unless otherwise stated, rules are intuitive.
'~' means "logical xor"
programming operators (|,&,>>,<<) work, but must be used on integers
same for factorial ( ! )
** <> todo: make it a flag to force integer prior to one of these
ops, by inserting an RINT into the EQ
@N means "get from UserVar #N"
UserVars must be allocated by the external program.
'>' means '>>' and '<' means '<<'
LINT 64 / * lower integer * /
GINT 65 / * greater integer * /
RINT 66 / * round integer * /
---
this program rocks!
---
ORDER OF OPS:
0. factorial
1. functions (trig,log,etc.,random order)
2. programming operators (shift,and,or,xor)
3. exponentials
4. mult & div
5. add & sub
*
*
*/
#ifdef _MSC_VER
#pragma warning(disable : 4244) // ulong -> uword
#endif
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <crblib/inc.h>
#include <crblib/memutil.h>
#include <crblib/strutil.h>
#include <crblib/equtil.h>
#include <crblib/crbconv.h>
#include <crblib/floatutil.h>
/*definitions*/
#define STRSIZE 1024
#define MAXDEBUGMESS 1024
#define WRKSIZE (1<<15)
#define MAXNUMPRESTORES 1024
#define MAXNUMSTORES 1024
#define NUMPREPARSETOKENS 1024
#define NUMORDTERMS 1024
#ifndef PI
#define PI ((double)3.14159265358979323846)
#endif
#ifdef ABS
#undef ABS
#endif
#ifndef mabs
#define mabs(x) ( (x) < 0 ? - (x) : (x) )
#endif
const static ubyte STOREubyte = '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -