Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Symbol table: Consider the following program is lexically-scoped language such a

ID: 3826590 • Letter: S

Question

Symbol table: Consider the following program is 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*/

How can the compiler organize symbol table information at compile time to handle nested scoping? Draw the logical state of the symbol tables(s).

Answer: The compiler can use nested symbol tables, one table per scope. Symbol table contain a pointer to the table of their enclosing scope.

What symbols are visible at points A, B, C?

Answer:

A: x, f, p, y, z, i, j

B: x, f, p, y, z

C: x, y, f

Explanation / Answer

[1]

The compiler can use nested symbol tables, one table per scope. Symbol table contain a pointer to the table of their enclosing scope. Symbol table is an important data structure created and maintained by compilers in order to store information about the occurrence of various entities such as variable names, function names, objects, classes, interfaces, etc.If a compiler is to handle a small amount of data, then the symbol table can be implemented as an unordered list.

[2]

At Point A :
int i,j,y,z,p,x

At Point B :
int y,z,p,x

At Point C :
int x,y