4 |
|
*/ |
5 |
|
#ifndef _RAD_CALCOMP_H_ |
6 |
|
#define _RAD_CALCOMP_H_ |
7 |
+ |
|
8 |
+ |
#include <stdio.h> |
9 |
+ |
|
10 |
|
#ifdef __cplusplus |
11 |
|
extern "C" { |
12 |
|
#endif |
13 |
|
|
11 |
– |
|
12 |
– |
#include "copyright.h" |
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 { |
32 |
– |
int type; /* node type */ |
33 |
– |
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 |
+ |
/* defined in biggerlib.c */ |
76 |
+ |
extern void biggerlib(void); |
77 |
+ |
|
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); |
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); |
141 |
– |
/* defined in savestr.c */ |
142 |
– |
extern char *savestr(char *str); |
143 |
– |
extern void freestr(char *s); |
144 |
– |
extern int shash(char *s); |
145 |
– |
/* defined in ealloc.c */ |
146 |
– |
extern char *emalloc(unsigned int n); |
147 |
– |
extern char *ecalloc(unsigned int ne, unsigned int es); |
148 |
– |
extern char *erealloc(char *cp, unsigned int n); |
149 |
– |
extern void efree(char *cp); |
150 |
– |
/* miscellaneous */ |
151 |
– |
extern void eputs(char *s); |
152 |
– |
extern void wputs(char *s); |
153 |
– |
extern void quit(int code); |
146 |
|
/* defined by client */ |
147 |
|
extern double chanvalue(int n); |
148 |
|
|