Semantic analysis and symbol tables
Compiler Design · Engineering
Study notes
Analyze '{ int x; x = 3.5; }': the symbol table enters x as int in the block scope. The assignment x = 3.5 triggers a type error (float to int needs cast) or a coercion warning. Exiting the block pops the scope, so a later 'x' is undeclared. Three checks: declaration, types, scope, all from the table.