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.6 on page 339 of the text.

  5. This exercise has three parts.
    1. Exercise 6.8 on page 340 of the text.
    2. Show a parse tree using your grammar for the following string
      x, y, z: integer
    3. Decorate your parse tree with attribute values, using arrows to show the order of attribute evaluation.

  6. Exercise 6.9 on page 340 of the text.