Java Reference
In-Depth Information
procedure
open
S
cope
()
depth depth +
1
scopeDisplay [ depth ]
null
end
procedure
close
S
cope
()
foreach sym scopeDisplay [ depth ] do
prevsym sym . var
3
call
delete
( sym )
4
if prevsym
null
5
then call
add
( prevsym )
depth depth
1
end
function
( name ) returns Symbol
sym HashTable . get( name )
retrieve
S
ymbol
while sym
null do
if sym . name = name
then return sym
6
sym sym . hash
7
return ( null )
end
8
procedure
enter
S
ymbol
( name , type )
oldsym ← retrieve
S
ymbol
( name )
if oldsym
null and oldsym . depth = depth
9
then call
error
(” Duplicate de f inition o f
, name )
newsym ← create
N
ew
S
ymbol
( name , type )
10
/
Add to scope display
/
newsym . level scopeDisplay [ depth ]
newsym . depth depth
scopeDisplay [ depth ]
newsym
/
Add to hash table
/
if oldsym =
null
then call
add
( newsym )
else
call
delete
( oldsym )
( newsym )
newsym . var oldsym
end
call
add
function
declared
L
ocally
( name ) returns Boolean
/
See Exercise 7.
/
end
Figure 8.7: Symbol table management
 
Search WWH ::




Custom Search