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 fprintf(stderr, "tab_clone: tab(%08X)\n", tab);
23 while(elm != SYMNULL) {
24 ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0, elm->param_index, elm->soffset);
30 struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check, int param_index, int soffset)
32 struct symbol *elm = tab;
33 struct symbol *new_elm;
35 fprintf(stderr, "tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i), param_index(%i), soffset(%i)\n", tab, ident, type, check, param_index, soffset);
39 /* kann statt return -3, -4 verursachen... (z.b. codea_ag_snafu_01.3) */
40 if(param_index >= 6) {
41 fprintf(stderr, "eine methode hat zu viele parameter (max. 6 inkl. this erlaubt)\n");
46 if(tab_lookup(tab, ident, type) != SYMNULL || (type == S_VAR && tab_lookup(tab, ident, S_PARM) != SYMNULL)) {
48 fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident);
51 tab = tab_remove_symbol(tab, ident, type);
55 new_elm = (struct symbol *) malloc(sizeof(struct symbol));
56 new_elm->next = SYMNULL;
57 new_elm->ident = strdup(ident);
59 new_elm->param_index = param_index;
60 new_elm->soffset = soffset;
62 if(tab == SYMNULL) return new_elm;
64 while(elm->next != SYMNULL) {
72 struct symbol *tab_lookup(struct symbol *tab, char *ident, short type)
74 struct symbol *elm = tab;
76 if(tab == SYMNULL) return SYMNULL;
79 if((elm->type & type) && (strcmp(elm->ident, ident) == 0)) {
83 } while(elm != SYMNULL);
88 struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check)
90 struct symbol *elm = to_add;
91 struct symbol *ntab = tab_clone(tab);
93 fprintf(stderr, "tab_merge: tab(%08X), to_add(%08X), check(%i), ntab(%08X)\n", tab, to_add, check, ntab);
96 while(elm != SYMNULL) {
97 ntab = tab_add_symbol(ntab, elm->ident, elm->type, check, elm->param_index, elm->soffset);
104 struct symbol *tab_remove_symbol(struct symbol *tab, char *ident, short type)
106 struct symbol *elm = tab;
107 struct symbol *previous_elm = SYMNULL;
109 while(elm != SYMNULL) {
110 if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) {
111 if(previous_elm == SYMNULL) {
114 previous_elm->next = elm->next;
116 (void)free(elm->ident);
127 void check(struct symbol *tab, char *ident, short type)
131 fprintf(stderr, "check: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm);
134 if(type & (S_VAR | S_PARM)) {
135 elm = tab_lookup(tab, ident, type);
141 /* keine passende variable gefunden?
142 * => vllt gibt es ja ein passenden feldnamen */
143 elm = tab_lookup(tab, ident, S_FIELD);
145 fprintf(stderr, "Unbekannter Identifier: \"%s\"\n", ident);