58 |
typedef struct { |
typedef struct { |
59 |
stackitem *head; /* Head of the stack */ |
stackitem *head; /* Head of the stack */ |
60 |
hashtbl symbols; /* Hash table of all variable bindings */ |
hashtbl symbols; /* Hash table of all variable bindings */ |
61 |
|
int err; /* Error flag */ |
62 |
} environment; |
} environment; |
63 |
|
|
64 |
/* A type for pointers to external functions */ |
/* A type for pointers to external functions */ |
255 |
} |
} |
256 |
|
|
257 |
/* Print newline. */ |
/* Print newline. */ |
258 |
extern void nl() |
extern void nl(environment *env) |
259 |
{ |
{ |
260 |
printf("\n"); |
printf("\n"); |
261 |
} |
} |
349 |
return out_item; |
return out_item; |
350 |
} |
} |
351 |
|
|
352 |
|
/* Recall a value from a symbol, if bound */ |
353 |
extern void rcl(environment *env) |
extern void rcl(environment *env) |
354 |
{ |
{ |
355 |
value *val; |
value *val; |
364 |
return; |
return; |
365 |
} |
} |
366 |
val=((symbol *)(env->head->item->content.ptr))->val; |
val=((symbol *)(env->head->item->content.ptr))->val; |
367 |
|
if(val == NULL){ |
368 |
|
printerr("Unbound variable"); |
369 |
|
return; |
370 |
|
} |
371 |
toss(env); /* toss the symbol */ |
toss(env); /* toss the symbol */ |
372 |
push_val(&(env->head), val); /* Return its bound value */ |
push_val(&(env->head), val); /* Return its bound value */ |
373 |
} |
} |
644 |
toss(env); |
toss(env); |
645 |
} |
} |
646 |
|
|
647 |
|
/* List all defined words */ |
648 |
extern void words(environment *env) |
extern void words(environment *env) |
649 |
{ |
{ |
650 |
symbol *temp; |
symbol *temp; |