Loading the code workspace…
Implement a symbol table with proper scope management.
Define data structures:
Symbol: Entry for one identifierScope: Collection of symbols with parent pointerSymbolTable: Manages scope stackImplement scope operations:
scope_enter(): Enter a new scope (function, block)scope_exit(): Leave current scopescope_current(): Get current scope levelImplement symbol operations:
symbol_define(name, type): Add symbol to current scopesymbol_lookup(name): Find symbol (current scope and parents)symbol_lookup_local(name): Find symbol in current scope onlysymbol_exists(name): Check if symbol is defined anywhereHandle edge cases:
Scoped symbol tables are the data structure behind every 'go to definition' in your IDE — clangd and rust-analyzer are essentially symbol tables with a network protocol. The chained-scope design you implement is exactly how C compilers handle block scope and how linkers later resolve the survivors.