I am reading Modern Compiler Implementation In ML, and trying to do the compiler project (the tiger language).
In chapter 5, semantic analysis, it uses functional data structure for constructing symbol stable. So insert table key value
will return a new table, instead of modify the existing table, and the old table is preserved when the function returns. So when type checking is done, the symbol table is still empty.
My question is, does it mean the symbol table is purely used for type checking? Because I've read this SO post, which says symbol table is also going to be used in code generation (I haven't gone that far yet).
If symbol table should be used after semantic analysis, should I use imperative data structure?
Any concrete example would be appreciated. :)