Institutt for Informatikk
Universitetet i Bergen
I 125 - Innf°ring i Programoversettelse


Voluntary Exercise Set 7 (Gruppe°velser. 7)

  1. 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;

    ...
    }

  2. 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.

  3. Exercise 6.2 on page 339 of the text.

  4. Exercise 6.5 on page 339 of the text.

  5. Exercise 6.6 on page 339 of the text.

  6. Exercise 6.10 on page 340 of the text.