Spring 2002, CSE 428: Quiz 2.3 - 24 Jan 2002


Please write your Name, Student ID, and Section at the top of the page.
  1. [Points 2] What is the typical function of a compiler (circle only one answer, please)

    1. takes a program (represented as a parse tree) and executes it
    2. takes a list of tokens and produces a parse tree
    3. translates the source code of a program into machine code
    4. takes a program and produces a list of tokens
    5. takes a grammar and produces all possible parse trees

  2. [Points 2] What is the purpose of the environment in an interpreter (circle only one answer, please)

    1. it provides the list of identifiers that are valid in the grammar
    2. it keeps the value of previous (sub)expressions
    3. it keeps the pointer to the parse tree
    4. it maintains the associations between identifiers and their values
    5. it tells the interpreter what are the resources available in the machine

  3. [Points 3] Consider the following rule for assignment:


                  sigma |- Exp eval Val
       ____________________________________________
       sigma |-  X = Exp ===> sigma union {(X,Val)}
    

    Here, union is the usual set union operator. Why is placing union in this inference rule wrong? (Circle only one answer.)

    1. Val might be associated two different variables.
    2. The result of the union might be empty.
    3. X might have two values in the union.
    4. The union should be interaction.

  4. [Points 3] Consider a declaration such as the following:
    
      int  x, y.
      bool b, c.
    

    This specification declares that two variables are integer and two are boolean. What is the type mapping that is intended by this declaration? Write your answer as a set of pairs.