Com S 342 --- Principles of Programming Languages EXERCISE 11: INTERPRETER BASICS (File $Date: 2004/03/31 03:49:52 $) The purpose of this exercise is for you to learn about the basics of the interepreters in chapter 3 of EOPL. As with all exercises, this is to be done individually. And it is due the day this topic is planned to be discussed in class, unless specified otherwise (see the syllabus at: http://www.cs.iastate.edu/~cs342/syllabus.shtml). As with all exercises, you have two choices for doing the work. You can either: - complete it as specified or - write down questions or problems that you had in trying to complete it. If you write down questions or problems you have, these should be detailed enough so that we can tell that you have read the materials and thought about them. (Don't just write: "I didn't understand how to do it". Instead, say what you tried and what you didn't understand.) During the class where this exercise is discussed, you should ask about these difficulties, and clear them up. Don't be shy; there will be other people with the same problem, and everyone can learn by discussing these issues. And you'll most likely see similar things on the homework, so it's best to understand them now. 1. [specifications of procedures in the interpreter] Read sections 3.1-3.2 of "Essentials of Programming Languages" (2nd ed., 2001) by Friedman, Wand, and Haynes. Describe, in your own words, what each of the following procedures in the interpreter does. a. eval-program b. eval-expression c. eval-rands d. eval-rand e. apply-primitive f. init-env 2. [Changes to the interpreter] Describe, in your own words, what would happen if you made the following changes in the interpreter: a. Changed eval-program to pass (empty-env) instead of (init-env) to eval-expression. b. Changed the var-exp case of eval-expression to be (var-exp (id) id) c. Changed the primapp-exp case of eval-expression to be (primapp-exp (prim rands) (apply-primitieve prim rands)) d. Changed the add-prim case of apply-primiteve to be (add-prim () (+ (car args) (cdr args))) WHAT TO HAND IN You should have at the beginning of class, written answers to the above questions (or written out questions and problems you encountered for each part). Make sure your name is on these. Attach the printouts, if any, requested above.