255 |
} |
} |
256 |
|
|
257 |
/* Print newline. */ |
/* Print newline. */ |
258 |
extern void nl(environment *env) |
extern void nl() |
259 |
{ |
{ |
260 |
printf("\n"); |
printf("\n"); |
261 |
} |
} |
489 |
break; |
break; |
490 |
} |
} |
491 |
/* If symbol */ |
/* If symbol */ |
492 |
if((convert= sscanf(in_line, "%[^][ ;\n\r_]%[^\n\r]", temp, rest))) { |
if((convert= sscanf(in_line, "%[^][ ;\n\r]%[^\n\r]", temp, rest))) { |
493 |
push_sym(env, temp); |
push_sym(env, temp); |
494 |
break; |
break; |
495 |
} |
} |
659 |
} |
} |
660 |
} |
} |
661 |
|
|
662 |
|
/* Forgets a symbol (remove it from the hash table) */ |
663 |
|
extern void forget(environment *env) |
664 |
|
{ |
665 |
|
char* sym_id; |
666 |
|
stackitem *stack_head= env->head; |
667 |
|
symbol **hash_entry, *temp; |
668 |
|
|
669 |
|
if(stack_head==NULL || stack_head->item->type!=symb) { |
670 |
|
printerr("Stack empty or not a symbol"); |
671 |
|
return; |
672 |
|
} |
673 |
|
|
674 |
|
sym_id= ((symbol*)(stack_head->item->content.ptr))->id; |
675 |
|
toss(env); |
676 |
|
|
677 |
|
hash_entry= hash(env->symbols, sym_id); |
678 |
|
temp= *hash_entry; |
679 |
|
*hash_entry= (*hash_entry)->next; |
680 |
|
|
681 |
|
if(temp->val!=NULL) { |
682 |
|
free_val(temp->val); |
683 |
|
} |
684 |
|
free(temp->id); |
685 |
|
free(temp); |
686 |
|
} |
687 |
|
|
688 |
int main() |
int main() |
689 |
{ |
{ |
690 |
environment myenv; |
environment myenv; |