1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ LBL" */ |
4 |
< |
|
1 |
> |
/* RCSid $Id$ */ |
2 |
|
/* |
3 |
|
* calcomp.h - header file for expression parser. |
7 |
– |
* |
4 |
|
*/ |
5 |
< |
/* EPNODE types */ |
6 |
< |
#define VAR 1 |
7 |
< |
#define NUM 2 |
8 |
< |
#define UMINUS 3 |
9 |
< |
#define CHAN 4 |
10 |
< |
#define FUNC 5 |
11 |
< |
#define ARG 6 |
12 |
< |
#define TICK 7 |
13 |
< |
#define SYM 8 |
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 |
> |
|
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 |
21 |
> |
#define SYM 8 |
22 |
|
/* also: '+', '-', '*', '/', '^', '=', ':' */ |
23 |
|
|
24 |
|
typedef struct { |
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 */ |
32 |
> |
int type; /* node type */ |
33 |
|
struct epnode *sibling; /* next child this level */ |
34 |
|
union { |
35 |
|
struct epnode *kid; /* first child */ |
36 |
< |
double num; /* number */ |
36 |
> |
double num; /* number */ |
37 |
|
char *name; /* symbol name */ |
38 |
|
int chan; /* channel number */ |
39 |
< |
long tick; /* timestamp */ |
39 |
> |
unsigned long tick; /* timestamp */ |
40 |
|
struct vardef { |
41 |
|
char *name; /* variable name */ |
42 |
< |
int nlinks; /* number of references */ |
42 |
> |
int nlinks; /* number of references */ |
43 |
|
struct epnode *def; /* definition */ |
44 |
|
LIBR *lib; /* library definition */ |
45 |
|
struct vardef *next; /* next in hash list */ |
49 |
|
|
50 |
|
typedef struct vardef VARDEF; /* a variable definition */ |
51 |
|
|
52 |
< |
#define MAXWORD 64 /* maximum word/id length */ |
53 |
< |
#define CNTXMARK '`' /* context mark */ |
52 |
> |
#define RMAXWORD 127 /* maximum word/id length */ |
53 |
> |
#define CNTXMARK '`' /* context mark */ |
54 |
|
|
55 |
< |
#define isid(c) (isalnum(c) || (c) == '_' || \ |
55 |
> |
#define isid(c) (isalnum(c) || (c) == '_' || \ |
56 |
|
(c) == '.' || (c) == CNTXMARK) |
57 |
|
|
58 |
< |
extern double eval(), varvalue(), chanvalue(), funvalue(); |
59 |
< |
extern double argument(), getnum(); |
60 |
< |
extern double (*eoper[])(); |
61 |
< |
extern int getinum(); |
62 |
< |
extern char *getname(), *qualname(), *setcontext(), *argfun(); |
63 |
< |
extern EPNODE *eparse(), *ekid(), *dlookup(), *dpop(), *dfirst(), *dnext(); |
64 |
< |
extern EPNODE *getdefn(), *getchan(); |
65 |
< |
extern EPNODE *getE1(), *getE2(), *getE3(), *getE4(), *getE5(), *rconst(); |
66 |
< |
extern VARDEF *varinsert(), *varlookup(), *argf(); |
67 |
< |
extern LIBR *liblookup(); |
68 |
< |
extern long eclock; |
58 |
> |
#define evalue(ep) (*eoper[(ep)->type])(ep) |
59 |
> |
|
60 |
> |
/* flags to set in esupport */ |
61 |
> |
#define E_VARIABLE 001 |
62 |
> |
#define E_FUNCTION 002 |
63 |
> |
#define E_INCHAN 004 |
64 |
> |
#define E_OUTCHAN 010 |
65 |
> |
#define E_RCONST 020 |
66 |
> |
#define E_REDEFW 040 |
67 |
> |
|
68 |
> |
extern double (*eoper[])(EPNODE *); |
69 |
> |
extern unsigned long eclock; |
70 |
> |
extern unsigned int esupport; |
71 |
> |
extern EPNODE *curfunc; |
72 |
|
extern int nextc; |
66 |
– |
extern int errno; |
73 |
|
|
74 |
< |
#define evalue(ep) (*eoper[(ep)->type])(ep) |
74 |
> |
/* defined in biggerlib.c */ |
75 |
> |
extern void biggerlib(void); |
76 |
> |
|
77 |
> |
/* defined in caldefn.c */ |
78 |
> |
extern void fcompile(char *fname); |
79 |
> |
extern void scompile(char *str, char *fname, int ln); |
80 |
> |
extern double varvalue(char *vname); |
81 |
> |
extern double evariable(EPNODE *ep); |
82 |
> |
extern void varset(char *fname, int assign, double val); |
83 |
> |
extern void dclear(char *name); |
84 |
> |
extern void dremove(char *name); |
85 |
> |
extern int vardefined(char *name); |
86 |
> |
extern char *setcontext(char *ctx); |
87 |
> |
extern char *pushcontext(char *ctx); |
88 |
> |
extern char *popcontext(void); |
89 |
> |
extern char *qualname(char *nam, int lvl); |
90 |
> |
extern int incontext(char *qn); |
91 |
> |
extern void chanout(void (*cs)(int n, double v)); |
92 |
> |
extern void dcleanup(int lvl); |
93 |
> |
extern EPNODE *dlookup(char *name); |
94 |
> |
extern VARDEF *varlookup(char *name); |
95 |
> |
extern VARDEF *varinsert(char *name); |
96 |
> |
extern void varfree(VARDEF *ln); |
97 |
> |
extern EPNODE *dfirst(void); |
98 |
> |
extern EPNODE *dnext(void); |
99 |
> |
extern EPNODE *dpop(char *name); |
100 |
> |
extern void dpush(char *nm, EPNODE *ep); |
101 |
> |
extern void addchan(EPNODE *sp); |
102 |
> |
extern void getstatement(void); |
103 |
> |
extern EPNODE *getdefn(void); |
104 |
> |
extern EPNODE *getchan(void); |
105 |
> |
/* defined in calexpr.c */ |
106 |
> |
extern EPNODE *eparse(char *expr); |
107 |
> |
extern double eval(char *expr); |
108 |
> |
extern int epcmp(EPNODE *ep1, EPNODE *ep2); |
109 |
> |
extern void epfree(EPNODE *epar); |
110 |
> |
extern EPNODE *ekid(EPNODE *ep, int n); |
111 |
> |
extern int nekids(EPNODE *ep); |
112 |
> |
extern void initfile(FILE *fp, char *fn, int ln); |
113 |
> |
extern void initstr(char *s, char *fn, int ln); |
114 |
> |
extern void getscanpos(char **fnp, int *lnp, char **spp, FILE **fpp); |
115 |
> |
extern int scan(void); |
116 |
> |
extern char *long2ascii(long l); |
117 |
> |
extern void syntax(char *err); |
118 |
> |
extern void addekid(EPNODE *ep, EPNODE *ekid); |
119 |
> |
extern char *getname(void); |
120 |
> |
extern int getinum(void); |
121 |
> |
extern double getnum(void); |
122 |
> |
extern EPNODE *getE1(void); |
123 |
> |
extern EPNODE *getE2(void); |
124 |
> |
extern EPNODE *getE3(void); |
125 |
> |
extern EPNODE *getE4(void); |
126 |
> |
extern EPNODE *getE5(void); |
127 |
> |
extern EPNODE *rconst(EPNODE *epar); |
128 |
> |
extern int isconstvar(EPNODE *ep); |
129 |
> |
extern int isconstfun(EPNODE *ep); |
130 |
> |
/* defined in calfunc.c */ |
131 |
> |
extern int fundefined(char *fname); |
132 |
> |
extern double funvalue(char *fname, int n, double *a); |
133 |
> |
extern void funset(char *fname, int nargs, int assign, |
134 |
> |
double (*fptr)(char *)); |
135 |
> |
extern int nargum(void); |
136 |
> |
extern double argument(int n); |
137 |
> |
extern VARDEF *argf(int n); |
138 |
> |
extern char *argfun(int n); |
139 |
> |
extern double efunc(EPNODE *ep); |
140 |
> |
extern LIBR *liblookup(char *fname); |
141 |
> |
extern void libupdate(char *fn); |
142 |
> |
/* defined in calprnt.c */ |
143 |
> |
extern void eprint(EPNODE *ep, FILE *fp); |
144 |
> |
extern void dprint(char *name, FILE *fp); |
145 |
> |
/* defined in savestr.c */ |
146 |
> |
extern char *savestr(char *str); |
147 |
> |
extern void freestr(char *s); |
148 |
> |
extern int shash(char *s); |
149 |
> |
/* defined in ealloc.c */ |
150 |
> |
extern char *emalloc(unsigned int n); |
151 |
> |
extern char *ecalloc(unsigned int ne, unsigned int es); |
152 |
> |
extern char *erealloc(char *cp, unsigned int n); |
153 |
> |
extern void efree(char *cp); |
154 |
> |
/* defined by client */ |
155 |
> |
extern double chanvalue(int n); |
156 |
> |
|
157 |
> |
|
158 |
> |
#ifdef __cplusplus |
159 |
> |
} |
160 |
> |
#endif |
161 |
> |
#endif /* _RAD_CALCOMP_H_ */ |
162 |
> |
|