Using Stacks for Symbol Tables or not

780 Views Asked by At

I'm working on creating a compiler and have come across some text that suggests two different ways of implementing symbol tables. With one, there is a symbol table for each level of nesting which is stored on a stack. With the second option there are only two symbol tables, one symbol table is constructed for maintaining all entries, and the other is used to keep track of changes to the primary table in order to know which entries to remove once you've made it past that particular block. What are the strengths and weaknesses of these different implementations? I'm sure that the first option will be faster as far as removing the symbol table for an individual block, however this comes at some overhead (of which I am unclear). The second is clearly resource intensive as far as when a large block with many declarations is to be removed, but it allows for constant time when accessing the variables.

0

There are 0 best solutions below