Stack Symbol Table[adapted from slide by John Werth.]
During compilation, the compiler performs a depth-first traversal of the tree of procedures.
Since a procedure can access its symbols and the symbols of its ancestors, the symbol table could be structured as a stack.
Searching backwards through the stack implements shadowing , i.e. the closest definition of a symbol with a given name takes precedence.
When parsing of a procedure is finished, its local symbol table can be popped off the stack.
Alternatively, the whole tree of symbol tables can be maintained, with each node having a pointer to its parent.