3 static char *symbol_type_names
[] = {
9 static char *symbol_scope_names
[] = {
15 static void symbol_free(struct symbol
*sym
)
20 void symbol_table_create(struct symbol_table
*st
)
25 void symbol_table_free(struct symbol_table
*st
)
27 struct symbol
*sym
, *sym_next
;
37 void symbol_table_dump(struct symbol_table
*st
, FILE *f
)
42 fprintf(f
, "%s (%s | %s)\n", lex_get_tok_str(sym
->name
, NULL
),
43 symbol_type_names
[st
->type
],
44 symbol_scope_names
[st
->scope
]);
49 struct symbol
*symbol_table_add(struct symbol_table
*st
, tok_t name
)
52 sym
= emalloc(sizeof *sym
);
53 memset(sym
, 0, sizeof *sym
);
57 sym
->next
= st
->first
;
59 st
->first
->prev
= sym
;
67 void symbol_table_remove(struct symbol_table
*st
, struct symbol
*sym
)
69 *(sym
->prev
? &sym
->prev
->next
: &st
->first
) = sym
->next
;
70 *(sym
->next
? &sym
->next
->prev
: &st
->last
) + sym
->prev
;