10 struct symbol *tab_new(void)
15 struct symbol *tab_clone(struct symbol *tab)
17 struct symbol *elm = tab;
18 struct symbol *ntab = tab_new();
20 printf("tab_clone: tab(%08X)\n", tab);
23 while(elm != SYMNULL) {
24 ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0);
30 struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check)
32 struct symbol *elm = tab;
33 struct symbol *new_elm;
35 printf("tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i)\n", tab, ident, type, check);
38 if(tab_lookup(tab, ident, type) != SYMNULL) {
40 fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident);
43 tab = tab_remove_symbol(tab, ident, type);
47 new_elm = (struct symbol *) malloc(sizeof(struct symbol));
48 new_elm->next = SYMNULL;
49 new_elm->ident = strdup(ident);
56 while(elm->next != SYMNULL) {
64 struct symbol *tab_lookup(struct symbol *tab, char *ident, short type)
66 struct symbol *elm = tab;
73 if((elm->type & type) && (strcmp(elm->ident, ident) == 0)) {
77 } while(elm != SYMNULL);
82 struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check)
84 struct symbol *elm = to_add;
85 struct symbol *ntab = tab_clone(tab);
87 printf("tab_merge: tab(%08X), to_add(%08X), check(%i), ntab(%08X)\n", tab, to_add, check, ntab);
90 while(elm != SYMNULL) {
91 ntab = tab_add_symbol(ntab, elm->ident, elm->type, check);
98 struct symbol *tab_remove_symbol(struct symbol *tab, char *ident, short type)
100 struct symbol *elm = tab;
101 struct symbol *previous_elm = SYMNULL;
103 while(elm != SYMNULL) {
104 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
105 if(previous_elm == SYMNULL) {
108 previous_elm->next = elm->next;
110 (void)free(elm->ident);
121 void check(struct symbol *tab, char *ident, short type)
125 printf("check: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm);
128 if(type & (S_VAR | S_PARM)) {
129 elm = tab_lookup(tab, ident, type);
135 /* keine passende variable gefunden?
136 * => vllt gibt es ja ein passenden feldnamen */
137 elm = tab_lookup(tab, ident, S_FIELD);
139 fprintf(stderr, "Unbekannter Identifier: \"%s\"\n", ident);