Com S 342 --- Principles of Programming Languages EXERCISE 04: RECURSION AND FOLLOWING THE GRAMMAR (File $Date: 2005/02/07 22:14:53 $) The purpose of this exercise is to have you learn about how to follow a grammar when writing recursive programs. 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). We expect this to help you think about the readings (see below). If you don't have an answer or an answer that you think is good, write down what you read, and a question or two that would have helped you make progress. Then you can ask that question in class; 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. READINGS: Read through the end of section 5.2 of "Following the Grammar" which is available from the course resources web page and also directly at: http://www.cs.iastate.edu/~cs342/docs/follow-grammar.pdf 1. [total-width] Look at exercise in section 5.2.3 of "Following the Grammar" which is available from the course resources web page and also directly at: http://www.cs.iastate.edu/~cs342/docs/follow-grammar.pdf For this problem we just want you to write out (on the computer) an outline for a set of procedures that follows the "window layout" grammar. You don't have to get your procedures to work, just write out the defines for the procedures needed, code to choose between any cases, and code to call the other procedures in your outline. Make a printout of this outline. WHAT TO HAND IN You should have at the beginning of class, written answers for 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. IF YOU HAVE MORE TIME You can solve the problem completely. If you wish, you can also test your solution using: (test-ex "total-width") ADDITIONAL READINGS If you have time, read sections 1.1-1.2 of "Essentials of Programming Languages" (2nd ed., 2001), by Friedman, Wand, and Haynes.