static char sccsid
[] = "@(#)for.c 3.1 (CWI) 85/07/30";
char *var
; /* index variable */
char *str
; /* string to push back */
For forstk
[10]; /* stack of for loops */
For
*forp
= forstk
; /* pointer to current top */
forloop(var
, from
, to
, op
, by
, str
) /* set up a for loop */
dprintf("# for %s from %g to %g by %c %g \n",
fatal("for loop nested too deep");
nextfor() /* do one iteration of a for loop */
/* BUG: this should depend on op and direction */
if (getfval(forp
->var
) > SLOP
* forp
->to
) { /* loop is done */
fatal("forstk popped too far");
} else { /* another iteration */
pushsrc(String
, "\nEndfor\n");
pushsrc(String
, forp
->str
);
endfor() /* end one iteration of for loop */
struct symtab
*p
= lookup(forp
->var
);
char *ifstat(expr
, thenpart
, elsepart
)
char *thenpart
, *elsepart
;
dprintf("if %g then <%s> else <%s>\n", expr
, thenpart
, elsepart
? elsepart
: "");
pushsrc(String
, thenpart
);
return thenpart
; /* to be freed later */
pushsrc(String
, elsepart
);