8 static void check_gen(struct symbol *tab, char *ident, short type);
10 struct symbol *new_tab(void)
15 struct symbol *clone_tab(struct symbol *tab)
18 struct symbol *new_tabx;
20 printf("clone_tab: tab(%08X)\n", tab);
25 while(elm != SYMNULL) {
26 new_tabx = tab_add_symbol(new_tabx, elm->ident, elm->type, 0);
33 struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check)
36 struct symbol *new_elm;
38 printf("tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i)\n", tab, ident, type, check);
41 if(tab_lookup(tab, ident, type) != SYMNULL) {
43 fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident);
46 tab = tab_remove_symbol(tab, ident, type);
50 new_elm = (struct symbol *) malloc(sizeof(struct symbol));
51 new_elm->next = SYMNULL;
52 new_elm->ident = strdup(ident);
60 while(elm->next != SYMNULL) {
68 struct symbol *tab_lookup(struct symbol *tab, char *ident, short type)
70 struct symbol *elm = tab;
77 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
81 } while(elm != SYMNULL);
86 struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check)
88 struct symbol *elm = to_add;
89 struct symbol *new_tab = clone_tab(tab);
91 printf("tab_merge: tab(%08X), to_add(%08X), check(%i), new_tab(%08X)\n", tab, to_add, check, new_tab);
94 while(elm != SYMNULL) {
95 new_tab = tab_add_symbol(new_tab, elm->ident, elm->type, check);
102 struct symbol *tab_remove_symbol(struct symbol *tab, char *ident, short type)
104 struct symbol *elm = tab;
105 struct symbol *previous_elm = SYMNULL;
107 while(elm != SYMNULL) {
108 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
109 if(previous_elm == SYMNULL) {
112 previous_elm->next = elm->next;
114 (void)free(elm->ident);
125 void check_variable(struct symbol *tab, char *ident)
127 check_gen(tab, ident, S_VAR);
130 void check_field(struct symbol *tab, char *ident)
132 check_gen(tab, ident, S_FIELD);
135 static void check_gen(struct symbol *tab, char *ident, short type)
137 struct symbol *elm = tab_lookup(tab, ident, type);
139 printf("check_variable: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm);
142 fprintf(stderr, "Unbekannter Identifier: \"%s\"\n", ident);