| 1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 32 |
|
|
| 33 |
|
#define isdecimal(c) (isdigit(c) || (c) == '.') |
| 34 |
|
|
| 35 |
< |
extern double atof(), pow(); |
| 35 |
> |
#ifndef atof |
| 36 |
> |
extern double atof(); |
| 37 |
> |
#endif |
| 38 |
> |
extern double pow(); |
| 39 |
|
extern char *fgets(), *savestr(); |
| 40 |
|
extern char *emalloc(), *ecalloc(); |
| 41 |
|
extern EPNODE *curfunc; |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
|
| 329 |
+ |
getscanpos(fnp, lnp, spp, fpp) /* return current scan position */ |
| 330 |
+ |
char **fnp; |
| 331 |
+ |
int *lnp; |
| 332 |
+ |
char **spp; |
| 333 |
+ |
FILE **fpp; |
| 334 |
+ |
{ |
| 335 |
+ |
if (fnp != NULL) *fnp = infile; |
| 336 |
+ |
if (lnp != NULL) *lnp = lineno; |
| 337 |
+ |
if (spp != NULL) *spp = linbuf+linepos; |
| 338 |
+ |
if (fpp != NULL) *fpp = infp; |
| 339 |
+ |
} |
| 340 |
+ |
|
| 341 |
+ |
|
| 342 |
|
int |
| 343 |
|
scan() /* scan next character, return literal next */ |
| 344 |
|
{ |
| 447 |
|
for (i = 0; i < MAXWORD && isid(lnext); i++, lnext = scan()) |
| 448 |
|
str[i] = lnext; |
| 449 |
|
str[i] = '\0'; |
| 450 |
+ |
while (isid(lnext)) /* skip rest of name */ |
| 451 |
+ |
lnext = scan(); |
| 452 |
|
|
| 453 |
|
return(str); |
| 454 |
|
} |
| 589 |
|
ep2->v.num = -ep2->v.num; |
| 590 |
|
return(ep2); |
| 591 |
|
} |
| 592 |
+ |
if (ep2->type == UMINUS) { /* don't generate -(-E5) */ |
| 593 |
+ |
efree((char *)ep2); |
| 594 |
+ |
return(ep2->v.kid); |
| 595 |
+ |
} |
| 596 |
|
ep1 = newnode(); |
| 597 |
|
ep1->type = UMINUS; |
| 598 |
|
addekid(ep1, ep2); |
| 613 |
|
/* ARG */ |
| 614 |
|
{ |
| 615 |
|
int i; |
| 616 |
+ |
char *nam; |
| 617 |
|
register EPNODE *ep1, *ep2; |
| 618 |
|
|
| 619 |
|
if (nextc == '(') { |
| 636 |
|
#endif |
| 637 |
|
|
| 638 |
|
#if defined(VARIABLE) || defined(FUNCTION) |
| 639 |
< |
if (isalpha(nextc)) { |
| 640 |
< |
ep1 = newnode(); |
| 618 |
< |
ep1->type = VAR; |
| 619 |
< |
ep1->v.ln = varinsert(getname()); |
| 620 |
< |
|
| 639 |
> |
if (isalpha(nextc) || nextc == CNTXMARK) { |
| 640 |
> |
nam = getname(); |
| 641 |
|
#if defined(VARIABLE) && defined(FUNCTION) |
| 642 |
+ |
ep1 = NULL; |
| 643 |
|
if (curfunc != NULL) |
| 644 |
|
for (i = 1, ep2 = curfunc->v.kid->sibling; |
| 645 |
|
ep2 != NULL; i++, ep2 = ep2->sibling) |
| 646 |
< |
if (!strcmp(ep2->v.name, ep1->v.ln->name)) { |
| 626 |
< |
epfree(ep1); |
| 646 |
> |
if (!strcmp(ep2->v.name, nam)) { |
| 647 |
|
ep1 = newnode(); |
| 648 |
|
ep1->type = ARG; |
| 649 |
|
ep1->v.chan = i; |
| 650 |
|
break; |
| 651 |
|
} |
| 652 |
+ |
if (ep1 == NULL) |
| 653 |
|
#endif |
| 654 |
+ |
{ |
| 655 |
+ |
ep1 = newnode(); |
| 656 |
+ |
ep1->type = VAR; |
| 657 |
+ |
ep1->v.ln = varinsert(nam); |
| 658 |
+ |
} |
| 659 |
|
#ifdef FUNCTION |
| 660 |
|
if (nextc == '(') { |
| 661 |
|
ep2 = newnode(); |