Comprehensive Examination
Compiler Construction

Spring 1997

This is a closed-notes, closed-book exam administered under the Rice Honor Code. You have two hours to complete the exam.

We have tried to give you all the information required to complete each question. If you reach a point where you are missing a critical piece of information, make a reasonable assumption, record it in your answer book, and continue.


  1. General Knowledge: Each of the following items might be built during compiler construction, during compilation, or during execution. For each item, state (i) what it is, (ii) when it is built, (iii) when it is used, and (iv) what role it plays in translation or execution.
    1. free list
    2. access link
    3. action table
    4. interference graph
    5. dope vector

  2. Storage allocation:
    1. Briefly define "activation record." Be sure to include examples of things that are stored in one.
    2. Describe the various mechanisms that the compiler can use to allocate and free activation records. What language features would influence your choice of allocation discipline for activation records.
    3. When, if ever, is it legal to allocate an activation record statically?

  3. LR Parsing:
    1. Write down the algorithm for parsing a sentence using an LR parse table (the "skeleton parser").
    2. The simple expression grammar on the left hand side was fed to an LR parser generator that produced the action and goto tables on the right. Using the tables to drive your parsing algorithm from part (a) above, parse the string "x * (2 +* y)". Show the state of the stack and the lookahead symbol when the syntax error is discovered. What is the last action taken prior to discovering the error?

      (1) E -> E + T
      (2) E -> T
      (3) T -> T * F
      (4) T -> F
      (5) F -> (E)
      (6) F -> id
      actiongoto
      Stateid+*()$ ETF
      0s5s4123
      1s6acc
      2r2s7r2r2
      3r4r4r4r4
      4s5s4823
      5r6r6r6r6
      6s5s493
      7s5s410
      8s6s11
      9r1s7r1r1
      10r3r3r3r3
      11r5r5r5r5

  4. Data-flow analysis: In solving global data-flow analysis problems, we are often interested in determining the "meet-over-all-paths" (mop) solution to a problem. However, the mop solution is sometimes expensive or impossible to calculate, so we settle for an estimate of the solution that is a "conservative" solution. When estimating each of the following sets, tell whether too-large or too-small estimates are conservative.
    1. available expressions
    2. live variables
    3. interprocedural changed variables
    4. reaching definitions
    Explain your answers in terms of the intended use of the information.

[UP] [CSGSA]