Institutt for Informatikk
Universitetet i Bergen
INF 225 - Innføring i Programoversettelse - H05
Voluntary Exercise Set 6 (Group meeting 7.10.2005)
Using a linked-tables implementation of a symbol table
similar to the examples covered in class,
show the structure and contents of the symbol table structure
for the C- program below.
(We called this the clean-maybe-wastful implementation of structured scope.)
Note that there are four blocks in the program, and so your structure
should have five symbol tables linked together in appropriate fashion,
one for the globals plus one for each of the blocks.
int b;
int first (int a, int b)
{ int c;
...
while (a < 10)
{ int b;
...
}
}
int second (int y)
{ int a; int x;
...
}
void main (void)
{ int b; int c;
...
}
Using an all-in-one array of stacks implementation of a symbol table,
show the structure and contents of the symbol table structure
for the C- program above.
(We called this
the quick-and-dirty-but-slow implementation of structured scope.)
For this problem you should show what the symbol-table structure
looks like just prior to the "parse" of each end of block symbol }.
Note that there are four such end of block symbols in the program.