Lab 6

Symbol Tables and Symbol Table Update Actions

Objectives

The objectives of this laboratory are

Special Notes

You are to begin thinking about the next step in constructing a compiler, which in this case is the inclusion of a symbol table and a determination about where enough information is known during a parse to actually insert information about identifiers into the symbol table.  You will not be graded for whether you actually come up with correct answers.  We are more interested in seeing you come up with reasonable ideas.

To Do - The Symbol Table

1. Examine the following program (this is not exactly in micro Pascal form):


  program lab1;
    var  apple, candy: integer;
       y: float;
       zebra, xyz: integer;
       
   procedure mixit(a, b: integer; var x: float);
      var pony: integer;
      
      function fred(var q: float) returns integer;
      
         begin --fred
        -- Point 1
fred := q + 1; end; -- fred function mary(x: integer) returns integer; begin --mary -- Point 2 mary := x - 1; end; -- mary --Point 3
begin --mixit pony := a + b; end; --mixit begin --lab1 -- Point 4 write(zebra) end. --lab1

1 Draw an illustration of the symbol table structure at points 1, 2, 3, and 4 (see the comments in the program).  Use the single symbol table per scope approach.

2. Bring up your parser and the context free grammar for μPascal on our resources page.

3. Work with your team on a design for a symbol table ADT.  Remember that for your project there must be different symbol tables for each different scope in a program (follow the ideas presented in the lectures). What public methods will your ADT have? What data structure will you use inside the ADT for holding the symbol table values?

To Turn In

Put your names and group number on your work as usual.   Turn it in to the Lab 7 dropbox.