implement create_tables

This commit is contained in:
2026-03-14 13:35:55 +01:00
parent c3f252e807
commit 925047ee5d
+8 -10
View File
@@ -20,16 +20,14 @@ static void destroy_string_list(void);
// All strings are entered into the string_list
void create_tables(void)
{
// TODO:
// First use find_globals() to create the global symbol table.
// As global symbols are added, function symbols get their own local symbol tables as well.
//
// Once all global symbols are added, go through all functions bodies and bind references.
//
// Binding should performed by bind_names(function symbol table, function body AST node).
// IDENTIFIERs that reference declarations should point to the symbol_t they reference.
// It handles pushing and popping scopes, and adding variables to the local symbol table.
// A final task performed by bind_names(...), is adding strings to the global string list.
find_globals();
for (int i = 0; i < global_symbols->n_symbols; i++) {
symbol_t *symbol = global_symbols->symbols[i];
if (symbol->type == SYMBOL_FUNCTION) {
bind_names(symbol->function_symtable, symbol->node);
}
}
}
// Prints the global symbol table, and the local symbol tables for each function.