Java Reference
In-Depth Information
Hash
Scope
Display
Table
f
void func
(float,float,float)
H
V
L
g
H
void func(int)
V
L
0
1
float
L
H
z
V
w
int
V
L
H
2
V
L
H
x
float
int
V
L
H
x
Figure 8.8: Detailed layout of the symbol table for Figure 8.1. The V,
L, and H fields abbreviate the Var, Level, and Hash fields,
respectively
chains. Thus, we expect that only a few iterations of the loop at Marker 6
should be necessary to locate a symbol or to detect that the symbol has not
been properly declared.
enter
first locates the currently active definition for name ,should
any exist in the table. Marker 9 checks that no declaration already exists
in the current scope. A new symbol table entry is generated at Marker 10 .
The symbol is added to those in the current scope by linking it into the scope
display. The remaining code inserts the new symbol into the table. If an active
scope contains a definition of the symbol name, then that name is removed
from the table and referenced by the var field of the new symbol.
Recalling the discussion in Section 8.2.2, an alternative approach segre-
gates symbols by scope. A stack of symbol tables results (one symbol table per
scope), as shown in Figure 8.3. The code to manage such a structure is left as
an exercise. (See Exercise 4.)
S
ymbol
8.4 Advanced Features
We next examine how to extend the simple symbol table framework to accom-
modate advanced features of modern programming languages. Extensions to
our simple framework fall generally in the following categories:
Name augmentation (overloading)
 
 
Search WWH ::




Custom Search