2 * header for complex-number expression parser.
10 typedef struct complex { /* our complex-number representation */
15 typedef struct symlist
{ /* parameter-list for a user-function */
20 typedef struct userfunction
{
21 struct remember
*remkey
;/* stores memory allocation list of tree */
22 struct symbol
*param
; /* parameter to function */
23 struct node
*tree
; /* the 'body' of the function */
26 typedef struct symbol
{ /* general symbol - numerous types */
28 short type
; /* VAR, CONST, BLTIN */
30 Complex val
; /* if VAR or CONST */
31 Complex (*cptr
)(); /* C_BLTIN (function) */
32 double (*rptr
)(); /* R_BLTIN (function) */
33 void (*vptr
)(); /* COMMAND */
34 UserFunc ufunc
; /* USER FUNCTION */
36 struct symbol
*left
, *right
; /* children */
41 Complex val
; /* a complex number */
42 Symbol
*sym
; /* a symbol */
46 int type
; /* type of node */
47 Contents contents
; /* contents of node */
48 struct node
*left
, *right
; /* children */
52 * Convention: if node type is a builtin or unary operator,
53 * the left child will hold the expression that is the
54 * argument to the function.
57 #define sqr(x) (x)*(x)
58 #define sign(x) ((x) >= 0.0 ? '+' : '-')
60 #ifdef __GNUC__ /* Workaround for built-in function name conflicts */
67 #define csqrt my_csqrt
75 #define casin my_casin
76 #define cacos my_cacos
77 #define catan my_catan
78 #define csinh my_csinh
79 #define ccosh my_ccosh
80 #define ctanh my_ctanh
82 /* Lattice-generated prototypes (some of them) */
83 /* Prototypes for functions defined in cmath.c */
84 Complex
cadd(Complex w
, Complex z
);
85 Complex
csub(Complex w
, Complex z
);
86 Complex
cmul(Complex w
, Complex z
);
87 Complex
cdiv(Complex w
, Complex z
);
88 Complex
cneg(Complex z
);
89 Complex
csqr(Complex z
);
90 Complex
csqrt(Complex z
);
91 Complex
conj(Complex z
);
92 Complex
cexp(Complex z
);
93 Complex
clog(Complex z
);
94 Complex
cpow(Complex w
, Complex z
);
95 Complex
csin(Complex z
);
96 Complex
ccos(Complex z
);
97 Complex
ctan(Complex z
);
98 Complex
casin(Complex z
);
99 Complex
cacos(Complex z
);
100 Complex
catan(Complex z
);
101 Complex
csinh(Complex z
);
102 Complex
ccosh(Complex z
);
103 Complex
ctanh(Complex z
);
105 double Re(Complex z
), Im(Complex z
);
106 double arg(Complex z
);
107 double norm(Complex z
);
108 double _cabs(Complex z
);
110 /* Prototypes for functions defined in math.c */
115 errcheck(double, char *);
117 /* Prototypes for functions defined in complex.y */
119 void warning(char *, char *),
121 execerror(char *, char *),
124 int main(int, char **);
126 /* Prototypes for functions defined in symbol.c */
127 Symbol
*lookup(char *s
);
128 Symbol
*allocsym(char *s
, int t
);
129 Symbol
*install(char *s
, int t
, Complex cval
);
130 void printlist(int type
);
132 /* Prototypes for functions defined in init.c */
135 /* Prototypes for functions defined in command.c */
145 /* Prototypes for functions defined in tree.c */
146 Node
*n_asgn(Symbol
*sym
, Node
*arg
);
147 Node
*n_binop(int op
, Node
*left
, Node
*right
);
148 Node
*n_unop(int op
, Node
*arg
);
149 Node
*n_func(int type
, Symbol
*sym
, Node
*arg
);
150 Node
*n_symbol(int type
, Symbol
*sym
);
151 Node
*n_number(double real
, double imag
);
152 Complex
eval_tree(Node
*n
);
153 void delete_tree(Node
*n
);
155 /* Prototypes for functions defined in function.c */
156 void clear_ufunc(UserFunc
*func
);