7 getvar(char *s) /* return value of variable s (usually pointer) */
15 ERROR "no such variable as %s", s WARNING;
17 ERROR "no such place as %s", s WARNING;
24 getfval(char *s) /* return float value of variable s */
33 setfval(char *s, double f) /* set variable s to f */
37 if ((p = lookup(s)) != NULL)
42 makevar(char *s, int t, YYSTYPE v) /* make variable named s in table */
43 /* assumes s is static or from tostring */
47 for (p = stack[nstack].p_symtab; p != NULL; p = p->s_next)
48 if (strcmp(s, p->s_name) == 0)
50 if (p == NULL) { /* it's a new one */
51 p = (struct symtab *) malloc(sizeof(struct symtab));
53 ERROR "out of symtab space with %s", s FATAL;
54 p->s_next = stack[nstack].p_symtab;
55 stack[nstack].p_symtab = p; /* stick it at front */
64 lookup(char *s) /* find s in symtab */
69 for (i = nstack; i >= 0; i--) /* look in each active symtab */
70 for (p = stack[i].p_symtab; p != NULL; p = p->s_next)
71 if (strcmp(s, p->s_name) == 0)
77 freesymtab(struct symtab *p) /* free space used by symtab at p */
81 for ( ; p != NULL; p = q) {
83 free(p->s_name); /* assumes done with tostring */
89 freedef(char *s) /* free definition for string s */
91 struct symtab *p, *q, *op;
93 for (p = op = q = stack[nstack].p_symtab; p != NULL; p = p->s_next) {
94 if (strcmp(s, p->s_name) == 0) { /* got it */
95 if (p->s_type != DEFNAME)
97 if (p == op) /* 1st elem */
98 stack[nstack].p_symtab = p->s_next;
100 q->s_next = p->s_next;
108 /* ERROR "%s is not defined at this point", s WARNING; */