2 |
|
/* |
3 |
|
* calcomp.h - header file for expression parser. |
4 |
|
*/ |
5 |
+ |
#ifndef _RAD_CALCOMP_H_ |
6 |
+ |
#define _RAD_CALCOMP_H_ |
7 |
|
|
8 |
< |
#include "copyright.h" |
8 |
> |
#include <stdio.h> |
9 |
|
|
10 |
+ |
#ifdef __cplusplus |
11 |
+ |
extern "C" { |
12 |
+ |
#endif |
13 |
+ |
|
14 |
|
#define VAR 1 |
15 |
|
#define NUM 2 |
16 |
|
#define UMINUS 3 |
17 |
|
#define CHAN 4 |
18 |
|
#define FUNC 5 |
19 |
|
#define ARG 6 |
20 |
< |
#define TICK 7 |
20 |
> |
#define CLKT 7 |
21 |
|
#define SYM 8 |
22 |
|
/* also: '+', '-', '*', '/', '^', '=', ':' */ |
23 |
|
|
25 |
|
char *fname; /* function name */ |
26 |
|
short nargs; /* # of required arguments */ |
27 |
|
short atyp; /* assignment type (':' or '=') */ |
28 |
< |
double (*f)(); /* pointer to function */ |
28 |
> |
double (*f)(char *); /* pointer to function */ |
29 |
|
} LIBR; /* a library function */ |
30 |
|
|
31 |
|
typedef struct epnode { |
26 |
– |
int type; /* node type */ |
27 |
– |
struct epnode *sibling; /* next child this level */ |
32 |
|
union { |
33 |
|
struct epnode *kid; /* first child */ |
34 |
|
double num; /* number */ |
43 |
|
struct vardef *next; /* next in hash list */ |
44 |
|
} *ln; /* link */ |
45 |
|
} v; /* value */ |
46 |
+ |
struct epnode *sibling; /* next child this level */ |
47 |
+ |
int type; /* node type */ |
48 |
|
} EPNODE; /* an expression node */ |
49 |
|
|
50 |
|
typedef struct vardef VARDEF; /* a variable definition */ |
51 |
|
|
52 |
< |
#define MAXWORD 127 /* maximum word/id length */ |
52 |
> |
#define RMAXWORD 127 /* maximum word/id length */ |
53 |
|
#define CNTXMARK '`' /* context mark */ |
54 |
|
|
55 |
|
#define isid(c) (isalnum(c) || (c) == '_' || \ |
65 |
|
#define E_RCONST 020 |
66 |
|
#define E_REDEFW 040 |
67 |
|
|
68 |
< |
extern double (*eoper[])(); |
68 |
> |
extern double (*eoper[])(EPNODE *); |
69 |
|
extern unsigned long eclock; |
70 |
|
extern unsigned int esupport; |
71 |
|
extern EPNODE *curfunc; |
72 |
|
extern int nextc; |
73 |
+ |
extern int eofc; |
74 |
|
|
75 |
< |
#ifdef NOPROTO |
75 |
> |
/* defined in biggerlib.c */ |
76 |
> |
extern void biggerlib(void); |
77 |
|
|
70 |
– |
extern void fcompile(); |
71 |
– |
extern void scompile(); |
72 |
– |
extern double varvalue(); |
73 |
– |
extern double evariable(); |
74 |
– |
extern void varset(); |
75 |
– |
extern void dclear(); |
76 |
– |
extern void dremove(); |
77 |
– |
extern int vardefined(); |
78 |
– |
extern char *setcontext(); |
79 |
– |
extern char *pushcontext(); |
80 |
– |
extern char *popcontext(); |
81 |
– |
extern char *qualname(); |
82 |
– |
extern int incontext(); |
83 |
– |
extern void chanout(); |
84 |
– |
extern void dcleanup(); |
85 |
– |
extern EPNODE *dlookup(); |
86 |
– |
extern VARDEF *varlookup(); |
87 |
– |
extern VARDEF *varinsert(); |
88 |
– |
extern void varfree(); |
89 |
– |
extern EPNODE *dfirst(); |
90 |
– |
extern EPNODE *dnext(); |
91 |
– |
extern EPNODE *dpop(); |
92 |
– |
extern void dpush(); |
93 |
– |
extern void addchan(); |
94 |
– |
extern void getstatement(); |
95 |
– |
extern EPNODE *getdefn(); |
96 |
– |
extern EPNODE *getchan(); |
97 |
– |
extern EPNODE *eparse(); |
98 |
– |
extern double eval(); |
99 |
– |
extern int epcmp(); |
100 |
– |
extern void epfree(); |
101 |
– |
extern EPNODE *ekid(); |
102 |
– |
extern int nekids(); |
103 |
– |
extern void initfile(); |
104 |
– |
extern void initstr(); |
105 |
– |
extern void getscanpos(); |
106 |
– |
extern int scan(); |
107 |
– |
extern char *long2ascii(); |
108 |
– |
extern void syntax(); |
109 |
– |
extern void addekid(); |
110 |
– |
extern char *getname(); |
111 |
– |
extern int getinum(); |
112 |
– |
extern double getnum(); |
113 |
– |
extern EPNODE *getE1(); |
114 |
– |
extern EPNODE *getE2(); |
115 |
– |
extern EPNODE *getE3(); |
116 |
– |
extern EPNODE *getE4(); |
117 |
– |
extern EPNODE *getE5(); |
118 |
– |
extern EPNODE *rconst(); |
119 |
– |
extern int isconstvar(); |
120 |
– |
extern int isconstfun(); |
121 |
– |
extern int fundefined(); |
122 |
– |
extern double funvalue(); |
123 |
– |
extern void funset(); |
124 |
– |
extern int nargum(); |
125 |
– |
extern double argument(); |
126 |
– |
extern VARDEF *argf(); |
127 |
– |
extern char *argfun(); |
128 |
– |
extern double efunc(); |
129 |
– |
extern LIBR *liblookup(); |
130 |
– |
extern void libupdate(); |
131 |
– |
extern void eprint(); |
132 |
– |
extern void dprint(); |
133 |
– |
extern char *savestr(); |
134 |
– |
extern void freestr(); |
135 |
– |
extern int shash(); |
136 |
– |
extern char *emalloc(); |
137 |
– |
extern char *ecalloc(); |
138 |
– |
extern char *erealloc(); |
139 |
– |
extern void efree(); |
140 |
– |
extern void eputs(); |
141 |
– |
extern void wputs(); |
142 |
– |
extern void quit(); |
143 |
– |
|
144 |
– |
extern double chanvalue(); |
145 |
– |
|
146 |
– |
#else |
78 |
|
/* defined in caldefn.c */ |
79 |
|
extern void fcompile(char *fname); |
80 |
|
extern void scompile(char *str, char *fname, int ln); |
81 |
|
extern double varvalue(char *vname); |
82 |
|
extern double evariable(EPNODE *ep); |
83 |
< |
extern void varset(char *fname, int assign, double val); |
83 |
> |
extern void varset(char *vname, int assign, double val); |
84 |
|
extern void dclear(char *name); |
85 |
|
extern void dremove(char *name); |
86 |
|
extern int vardefined(char *name); |
87 |
< |
extern char *setcontext(char *ctx); |
87 |
> |
extern char *calcontext(char *ctx); |
88 |
|
extern char *pushcontext(char *ctx); |
89 |
|
extern char *popcontext(void); |
90 |
|
extern char *qualname(char *nam, int lvl); |
91 |
|
extern int incontext(char *qn); |
92 |
< |
extern void chanout(int (*cs)()); |
92 |
> |
extern void chanout(void (*cs)(int n, double v)); |
93 |
|
extern void dcleanup(int lvl); |
94 |
|
extern EPNODE *dlookup(char *name); |
95 |
|
extern VARDEF *varlookup(char *name); |
100 |
|
extern EPNODE *dpop(char *name); |
101 |
|
extern void dpush(char *nm, EPNODE *ep); |
102 |
|
extern void addchan(EPNODE *sp); |
103 |
< |
extern void getstatement(); |
104 |
< |
extern EPNODE *getdefn(); |
105 |
< |
extern EPNODE *getchan(); |
103 |
> |
extern void getstatement(void); |
104 |
> |
extern EPNODE *getdefn(void); |
105 |
> |
extern EPNODE *getchan(void); |
106 |
|
/* defined in calexpr.c */ |
107 |
|
extern EPNODE *eparse(char *expr); |
108 |
|
extern double eval(char *expr); |
131 |
|
/* defined in calfunc.c */ |
132 |
|
extern int fundefined(char *fname); |
133 |
|
extern double funvalue(char *fname, int n, double *a); |
134 |
< |
extern void funset(char *fname, int nargs, int assign, double (*fptr)()); |
134 |
> |
extern void funset(char *fname, int nargs, int assign, |
135 |
> |
double (*fptr)(char *)); |
136 |
|
extern int nargum(void); |
137 |
|
extern double argument(int n); |
138 |
|
extern VARDEF *argf(int n); |
143 |
|
/* defined in calprnt.c */ |
144 |
|
extern void eprint(EPNODE *ep, FILE *fp); |
145 |
|
extern void dprint(char *name, FILE *fp); |
214 |
– |
/* defined in savestr.c */ |
215 |
– |
extern char *savestr(char *str); |
216 |
– |
extern void freestr(char *s); |
217 |
– |
extern int shash(char *s); |
218 |
– |
/* defined in ealloc.c */ |
219 |
– |
extern char *emalloc(unsigned int n); |
220 |
– |
extern char *ecalloc(unsigned int ne, unsigned int es); |
221 |
– |
extern char *erealloc(char *cp, unsigned int n); |
222 |
– |
extern void efree(char *cp); |
223 |
– |
/* miscellaneous */ |
224 |
– |
extern void eputs(char *s); |
225 |
– |
extern void wputs(char *s); |
226 |
– |
extern void quit(int code); |
146 |
|
/* defined by client */ |
147 |
|
extern double chanvalue(int n); |
148 |
|
|
149 |
+ |
|
150 |
+ |
#ifdef __cplusplus |
151 |
+ |
} |
152 |
|
#endif |
153 |
+ |
#endif /* _RAD_CALCOMP_H_ */ |
154 |
+ |
|