8 struct symbol *new_tab(void)
13 struct symbol *clone_tab(struct symbol *tab)
16 struct symbol *new_tabx;
18 printf("clone_tab: tab(%08X)\n", tab);
23 while(elm != SYMNULL) {
24 new_tabx = tab_add_symbol(new_tabx, elm->ident, elm->type, 0);
31 struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check)
34 struct symbol *new_elm;
36 printf("tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i)\n", tab, ident, type, check);
39 if(tab_lookup(tab, ident, type) != SYMNULL) {
41 fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident);
44 tab = tab_remove_symbol(tab, ident, type);
48 new_elm = (struct symbol *) malloc(sizeof(struct symbol));
49 new_elm->next = SYMNULL;
50 new_elm->ident = strdup(ident);
58 while(elm->next != SYMNULL) {
66 struct symbol *tab_lookup(struct symbol *tab, char *ident, short type)
68 struct symbol *elm = tab;
75 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
79 } while(elm != SYMNULL);
84 struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check)
86 struct symbol *elm = to_add;
87 struct symbol *new_tab = clone_tab(tab);
89 printf("tab_merge: tab(%08X), to_add(%08X), check(%i), new_tab(%08X)\n", tab, to_add, check, new_tab);
92 while(elm != SYMNULL) {
93 new_tab = tab_add_symbol(new_tab, elm->ident, elm->type, check);
100 struct symbol *tab_remove_symbol(struct symbol *tab, char *ident, short type)
102 struct symbol *elm = tab;
103 struct symbol *previous_elm = SYMNULL;
105 while(elm != SYMNULL) {
106 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
107 if(previous_elm == SYMNULL) {
110 previous_elm->next = elm->next;
112 (void)free(elm->ident);
123 void check(struct symbol *tab, char *ident, short type)
127 printf("check: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm);
131 elm = tab_lookup(tab, ident, type);
137 elm = tab_lookup(tab, ident, S_FIELD);
139 fprintf(stderr, "Unbekannter Identifier: \"%s\"\n", ident);