Symbol Table: Consider the following program in a lexically scoped language such
ID: 3831855 • Letter: S
Question
Symbol Table: Consider the following program in a lexically scoped language such as C
int x,y;
int f(int p){
int y,z;
{
int i,j;
/* Point A */
}
/* Point B */
}
/*Point C*/
a) How can the compiler organize Symbol table information at compile time to handle nested scoping?
Draw the logical state of the Symbol Table(S)
b) What Symbols are visible at Point A and Point B?
Symbol table: Consider the following program in 2 lexically scoped language such as C. in t x, y; int f(int p) {int y, z; {int i, J; /* point A */} /* point B*/} /*point c*/ a) How the complier organize symbol table information at compile time to handle rested scoping? Draw the logical state of the symbol table(s). b) What symbols are visible at points A and B?Explanation / Answer
the declaration may be from the current scope or some enclosing scope and inner most scope overrides outer scope
there are 3 opeartion for this
insert(name, p) — create record for name at level p
lookup(name) — returns pointer or index • delete(p) — deletes all names declared at level p
so here its a idea
Chain together procedure local hash tables
insert(name, p) adds to the level p table It may need to create the level p table and add it to the chain
lookup(name)
and then delete(p)
The compiler can use nested symbol tables, one table per scope.Symbol table contain a pointer to the table of their enclosing scope.
next part answer
so at point a and b
A: x, f, p, y, z, i, j
B: x, f, p, y, z
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.