82 |
|
|
83 |
|
|
84 |
|
EPNODE * |
85 |
< |
eparse(expr) /* parse an expression string */ |
86 |
< |
char *expr; |
85 |
> |
eparse( /* parse an expression string */ |
86 |
> |
char *expr |
87 |
> |
) |
88 |
|
{ |
89 |
|
EPNODE *ep; |
90 |
|
|
98 |
|
|
99 |
|
|
100 |
|
double |
101 |
< |
eval(expr) /* evaluate an expression string */ |
102 |
< |
char *expr; |
101 |
> |
eval( /* evaluate an expression string */ |
102 |
> |
char *expr |
103 |
> |
) |
104 |
|
{ |
105 |
|
register EPNODE *ep; |
106 |
|
double rval; |
113 |
|
|
114 |
|
|
115 |
|
int |
116 |
< |
epcmp(ep1, ep2) /* compare two expressions for equivalence */ |
117 |
< |
register EPNODE *ep1, *ep2; |
116 |
> |
epcmp( /* compare two expressions for equivalence */ |
117 |
> |
register EPNODE *ep1, |
118 |
> |
register EPNODE *ep2 |
119 |
> |
) |
120 |
|
{ |
121 |
|
double d; |
122 |
|
|
163 |
|
|
164 |
|
|
165 |
|
void |
166 |
< |
epfree(epar) /* free a parse tree */ |
167 |
< |
register EPNODE *epar; |
166 |
> |
epfree( /* free a parse tree */ |
167 |
> |
register EPNODE *epar |
168 |
> |
) |
169 |
|
{ |
170 |
|
register EPNODE *ep; |
171 |
|
|
199 |
|
|
200 |
|
/* the following used to be a switch */ |
201 |
|
static double |
202 |
< |
eargument(ep) |
203 |
< |
EPNODE *ep; |
202 |
> |
eargument( |
203 |
> |
EPNODE *ep |
204 |
> |
) |
205 |
|
{ |
206 |
|
return(argument(ep->v.chan)); |
207 |
|
} |
208 |
|
|
209 |
|
static double |
210 |
< |
enumber(ep) |
211 |
< |
EPNODE *ep; |
210 |
> |
enumber( |
211 |
> |
EPNODE *ep |
212 |
> |
) |
213 |
|
{ |
214 |
|
return(ep->v.num); |
215 |
|
} |
216 |
|
|
217 |
|
static double |
218 |
< |
euminus(ep) |
219 |
< |
EPNODE *ep; |
218 |
> |
euminus( |
219 |
> |
EPNODE *ep |
220 |
> |
) |
221 |
|
{ |
222 |
|
register EPNODE *ep1 = ep->v.kid; |
223 |
|
|
225 |
|
} |
226 |
|
|
227 |
|
static double |
228 |
< |
echannel(ep) |
229 |
< |
EPNODE *ep; |
228 |
> |
echannel( |
229 |
> |
EPNODE *ep |
230 |
> |
) |
231 |
|
{ |
232 |
|
return(chanvalue(ep->v.chan)); |
233 |
|
} |
234 |
|
|
235 |
|
static double |
236 |
< |
eadd(ep) |
237 |
< |
EPNODE *ep; |
236 |
> |
eadd( |
237 |
> |
EPNODE *ep |
238 |
> |
) |
239 |
|
{ |
240 |
|
register EPNODE *ep1 = ep->v.kid; |
241 |
|
|
243 |
|
} |
244 |
|
|
245 |
|
static double |
246 |
< |
esubtr(ep) |
247 |
< |
EPNODE *ep; |
246 |
> |
esubtr( |
247 |
> |
EPNODE *ep |
248 |
> |
) |
249 |
|
{ |
250 |
|
register EPNODE *ep1 = ep->v.kid; |
251 |
|
|
253 |
|
} |
254 |
|
|
255 |
|
static double |
256 |
< |
emult(ep) |
257 |
< |
EPNODE *ep; |
256 |
> |
emult( |
257 |
> |
EPNODE *ep |
258 |
> |
) |
259 |
|
{ |
260 |
|
register EPNODE *ep1 = ep->v.kid; |
261 |
|
|
263 |
|
} |
264 |
|
|
265 |
|
static double |
266 |
< |
edivi(ep) |
267 |
< |
EPNODE *ep; |
266 |
> |
edivi( |
267 |
> |
EPNODE *ep |
268 |
> |
) |
269 |
|
{ |
270 |
|
register EPNODE *ep1 = ep->v.kid; |
271 |
|
double d; |
280 |
|
} |
281 |
|
|
282 |
|
static double |
283 |
< |
epow(ep) |
284 |
< |
EPNODE *ep; |
283 |
> |
epow( |
284 |
> |
EPNODE *ep |
285 |
> |
) |
286 |
|
{ |
287 |
|
register EPNODE *ep1 = ep->v.kid; |
288 |
|
double d; |
304 |
|
} |
305 |
|
|
306 |
|
static double |
307 |
< |
ebotch(ep) |
308 |
< |
EPNODE *ep; |
307 |
> |
ebotch( |
308 |
> |
EPNODE *ep |
309 |
> |
) |
310 |
|
{ |
311 |
|
eputs("Bad expression!\n"); |
312 |
|
quit(1); |
315 |
|
|
316 |
|
|
317 |
|
EPNODE * |
318 |
< |
ekid(ep, n) /* return pointer to a node's nth kid */ |
319 |
< |
register EPNODE *ep; |
320 |
< |
register int n; |
318 |
> |
ekid( /* return pointer to a node's nth kid */ |
319 |
> |
register EPNODE *ep, |
320 |
> |
register int n |
321 |
> |
) |
322 |
|
{ |
323 |
|
|
324 |
|
for (ep = ep->v.kid; ep != NULL; ep = ep->sibling) |
330 |
|
|
331 |
|
|
332 |
|
int |
333 |
< |
nekids(ep) /* return # of kids for node ep */ |
334 |
< |
register EPNODE *ep; |
333 |
> |
nekids( /* return # of kids for node ep */ |
334 |
> |
register EPNODE *ep |
335 |
> |
) |
336 |
|
{ |
337 |
|
register int n = 0; |
338 |
|
|
344 |
|
|
345 |
|
|
346 |
|
void |
347 |
< |
initfile(fp, fn, ln) /* prepare input file */ |
348 |
< |
FILE *fp; |
349 |
< |
char *fn; |
350 |
< |
int ln; |
347 |
> |
initfile( /* prepare input file */ |
348 |
> |
FILE *fp, |
349 |
> |
char *fn, |
350 |
> |
int ln |
351 |
> |
) |
352 |
|
{ |
353 |
|
static char inpbuf[MAXLINE]; |
354 |
|
|
363 |
|
|
364 |
|
|
365 |
|
void |
366 |
< |
initstr(s, fn, ln) /* prepare input string */ |
367 |
< |
char *s; |
368 |
< |
char *fn; |
369 |
< |
int ln; |
366 |
> |
initstr( /* prepare input string */ |
367 |
> |
char *s, |
368 |
> |
char *fn, |
369 |
> |
int ln |
370 |
> |
) |
371 |
|
{ |
372 |
|
infp = NULL; |
373 |
|
infile = fn; |
379 |
|
|
380 |
|
|
381 |
|
void |
382 |
< |
getscanpos(fnp, lnp, spp, fpp) /* return current scan position */ |
383 |
< |
char **fnp; |
384 |
< |
int *lnp; |
385 |
< |
char **spp; |
386 |
< |
FILE **fpp; |
382 |
> |
getscanpos( /* return current scan position */ |
383 |
> |
char **fnp, |
384 |
> |
int *lnp, |
385 |
> |
char **spp, |
386 |
> |
FILE **fpp |
387 |
> |
) |
388 |
|
{ |
389 |
|
if (fnp != NULL) *fnp = infile; |
390 |
|
if (lnp != NULL) *lnp = lineno; |
394 |
|
|
395 |
|
|
396 |
|
int |
397 |
< |
scan() /* scan next character, return literal next */ |
397 |
> |
scan(void) /* scan next character, return literal next */ |
398 |
|
{ |
399 |
|
register int lnext = 0; |
400 |
|
|
426 |
|
|
427 |
|
|
428 |
|
char * |
429 |
< |
long2ascii(l) /* convert long to ascii */ |
430 |
< |
long l; |
429 |
> |
long2ascii( /* convert long to ascii */ |
430 |
> |
long l |
431 |
> |
) |
432 |
|
{ |
433 |
|
static char buf[16]; |
434 |
|
register char *cp; |
453 |
|
|
454 |
|
|
455 |
|
void |
456 |
< |
syntax(err) /* report syntax error and quit */ |
457 |
< |
char *err; |
456 |
> |
syntax( /* report syntax error and quit */ |
457 |
> |
char *err |
458 |
> |
) |
459 |
|
{ |
460 |
|
register int i; |
461 |
|
|
480 |
|
|
481 |
|
|
482 |
|
void |
483 |
< |
addekid(ep, ekid) /* add a child to ep */ |
484 |
< |
register EPNODE *ep; |
485 |
< |
EPNODE *ekid; |
483 |
> |
addekid( /* add a child to ep */ |
484 |
> |
register EPNODE *ep, |
485 |
> |
EPNODE *ekid |
486 |
> |
) |
487 |
|
{ |
488 |
|
if (ep->v.kid == NULL) |
489 |
|
ep->v.kid = ekid; |
497 |
|
|
498 |
|
|
499 |
|
char * |
500 |
< |
getname() /* scan an identifier */ |
500 |
> |
getname(void) /* scan an identifier */ |
501 |
|
{ |
502 |
|
static char str[RMAXWORD+1]; |
503 |
|
register int i, lnext; |
514 |
|
|
515 |
|
|
516 |
|
int |
517 |
< |
getinum() /* scan a positive integer */ |
517 |
> |
getinum(void) /* scan a positive integer */ |
518 |
|
{ |
519 |
|
register int n, lnext; |
520 |
|
|
529 |
|
|
530 |
|
|
531 |
|
double |
532 |
< |
getnum() /* scan a positive float */ |
532 |
> |
getnum(void) /* scan a positive float */ |
533 |
|
{ |
534 |
|
register int i, lnext; |
535 |
|
char str[RMAXWORD+1]; |
571 |
|
|
572 |
|
|
573 |
|
EPNODE * |
574 |
< |
getE1() /* E1 -> E1 ADDOP E2 */ |
574 |
> |
getE1(void) /* E1 -> E1 ADDOP E2 */ |
575 |
|
/* E2 */ |
576 |
|
{ |
577 |
|
register EPNODE *ep1, *ep2; |
593 |
|
|
594 |
|
|
595 |
|
EPNODE * |
596 |
< |
getE2() /* E2 -> E2 MULOP E3 */ |
596 |
> |
getE2(void) /* E2 -> E2 MULOP E3 */ |
597 |
|
/* E3 */ |
598 |
|
{ |
599 |
|
register EPNODE *ep1, *ep2; |
615 |
|
|
616 |
|
|
617 |
|
EPNODE * |
618 |
< |
getE3() /* E3 -> E4 ^ E3 */ |
618 |
> |
getE3(void) /* E3 -> E4 ^ E3 */ |
619 |
|
/* E4 */ |
620 |
|
{ |
621 |
|
register EPNODE *ep1, *ep2; |
637 |
|
|
638 |
|
|
639 |
|
EPNODE * |
640 |
< |
getE4() /* E4 -> ADDOP E5 */ |
640 |
> |
getE4(void) /* E4 -> ADDOP E5 */ |
641 |
|
/* E5 */ |
642 |
|
{ |
643 |
|
register EPNODE *ep1, *ep2; |
665 |
|
|
666 |
|
|
667 |
|
EPNODE * |
668 |
< |
getE5() /* E5 -> (E1) */ |
668 |
> |
getE5(void) /* E5 -> (E1) */ |
669 |
|
/* VAR */ |
670 |
|
/* NUM */ |
671 |
|
/* $N */ |
743 |
|
|
744 |
|
|
745 |
|
EPNODE * |
746 |
< |
rconst(epar) /* reduce a constant expression */ |
747 |
< |
register EPNODE *epar; |
746 |
> |
rconst( /* reduce a constant expression */ |
747 |
> |
register EPNODE *epar |
748 |
> |
) |
749 |
|
{ |
750 |
|
register EPNODE *ep; |
751 |
|
|
762 |
|
|
763 |
|
|
764 |
|
int |
765 |
< |
isconstvar(ep) /* is ep linked to a constant expression? */ |
766 |
< |
register EPNODE *ep; |
765 |
> |
isconstvar( /* is ep linked to a constant expression? */ |
766 |
> |
register EPNODE *ep |
767 |
> |
) |
768 |
|
{ |
769 |
|
register EPNODE *ep1; |
770 |
|
|
788 |
|
|
789 |
|
|
790 |
|
int |
791 |
< |
isconstfun(ep) /* is ep linked to a constant function? */ |
792 |
< |
register EPNODE *ep; |
791 |
> |
isconstfun( /* is ep linked to a constant function? */ |
792 |
> |
register EPNODE *ep |
793 |
> |
) |
794 |
|
{ |
795 |
|
register EPNODE *dp; |
796 |
|
register LIBR *lp; |