Names in the Symbol table
S id := E
{p = lookup(id.place);
if p <> nil then emit(p := E.place)
else error}
E id
{p = lookup(id.name);
if p <> nil then E.place = p
else error}
The operation lookup in the translation scheme above checks if there is an entry for this occurrence of the name in the symbol table. If an entry is found, pointer to the entry is returned else nil is returned. lookup first checks whether the name appears in the current symbol table. If not then it looks for the name in the symbol table of the enclosing procedure and so on. The pointer to the symbol table of the enclosing procedure is obtained from the header of the symbol table.
|