8 struct symbol *tab_new(void)
13 struct symbol *tab_clone(struct symbol *tab)
15 struct symbol *elm = tab;
16 struct symbol *ntab = tab_new();
18 printf("tab_clone: tab(%08X)\n", tab);
21 while(elm != SYMNULL) {
22 ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0);
28 struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check)
30 struct symbol *elm = tab;
31 struct symbol *new_elm;
33 printf("tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i)\n", tab, ident, type, check);
36 if(tab_lookup(tab, ident, type) != SYMNULL) {
38 fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident);
41 tab = tab_remove_symbol(tab, ident, type);
45 new_elm = (struct symbol *) malloc(sizeof(struct symbol));
46 new_elm->next = SYMNULL;
47 new_elm->ident = strdup(ident);
54 while(elm->next != SYMNULL) {
62 struct symbol *tab_lookup(struct symbol *tab, char *ident, short type)
64 struct symbol *elm = tab;
71 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
75 } while(elm != SYMNULL);
80 struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check)
82 struct symbol *elm = to_add;
83 struct symbol *ntab = tab_clone(tab);
85 printf("tab_merge: tab(%08X), to_add(%08X), check(%i), ntab(%08X)\n", tab, to_add, check, ntab);
88 while(elm != SYMNULL) {
89 ntab = tab_add_symbol(ntab, elm->ident, elm->type, check);
96 struct symbol *tab_remove_symbol(struct symbol *tab, char *ident, short type)
98 struct symbol *elm = tab;
99 struct symbol *previous_elm = SYMNULL;
101 while(elm != SYMNULL) {
102 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
103 if(previous_elm == SYMNULL) {
106 previous_elm->next = elm->next;
108 (void)free(elm->ident);
119 void check(struct symbol *tab, char *ident, short type)
123 printf("check: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm);
127 elm = tab_lookup(tab, ident, type);
133 /* keine passende variable gefunden?
134 * => vllt gibt es ja ein passenden feldnamen */
135 elm = tab_lookup(tab, ident, S_FIELD);
137 fprintf(stderr, "Unbekannter Identifier: \"%s\"\n", ident);