The block_symtab
class is used for nested block symbol tables and
as the base class for procedure symbol tables. Each one is associated
with a particular tree_block
(or tree_proc
) node in an
abstract syntax tree. See section Block Nodes. Each block symbol table
contains a pointer to the corresponding tree_block
node. The
block
method retrieves the value of this pointer. When a symbol
table is connected to a tree_block
, its block
pointer is
set automatically.
Since label symbols may not be declared in global scopes, the
block_symtab
class is the natural place to provide methods for
working with labels. The new_label
method creates a new label
symbol and enters it in the table (see section Creating New Entries). The
new_unique_label
does the same thing but it first makes sure that
the label will have a unique name. The lookup_label
method
searches for an existing label symbol (see section Lookup Methods).
Block symbol tables also provide a method to create a new child symbol
table, i.e. an inner scope. The new_unique_child
method can be
used to create a new child block symtab with a unique name
(see section Creating New Entries). This method is not provided for global
symbol tables, because their children must correspond to procedures,
which already have unique names.