--- stack/stack.c 2002/02/05 22:28:04 1.32 +++ stack/stack.c 2002/02/05 23:00:42 1.33 @@ -58,6 +58,7 @@ typedef struct { stackitem *head; /* Head of the stack */ hashtbl symbols; /* Hash table of all variable bindings */ + int err; /* Error flag */ } environment; /* A type for pointers to external functions */ @@ -254,7 +255,7 @@ } /* Print newline. */ -extern void nl() +extern void nl(environment *env) { printf("\n"); } @@ -348,6 +349,7 @@ return out_item; } +/* Recall a value from a symbol, if bound */ extern void rcl(environment *env) { value *val; @@ -362,6 +364,10 @@ return; } val=((symbol *)(env->head->item->content.ptr))->val; + if(val == NULL){ + printerr("Unbound variable"); + return; + } toss(env); /* toss the symbol */ push_val(&(env->head), val); /* Return its bound value */ } @@ -638,6 +644,7 @@ toss(env); } +/* List all defined words */ extern void words(environment *env) { symbol *temp;