Summary: In today's lab, you will explore a predictive parser for simple expressions that evaluates expressions while parsing them.
Collaboration: Feel free to work on this lab in pairs or trios.
Turning It In: Email me your results.
Grading: I expect that you will gain more from doing this lab than from me grading this lab. I may simply scan through your answers to see if you had any particularly valuable insights.
expression.ss contains a
predictive parser for simple single-digit expressions that evaluates the
expressions as it parses them. You should make a copy of the file and
read through it to give yourself some sense of the procedures it contains.
expression.ss in DrScheme. Evaluate a variety
of expressions to verify that the
works correctly. You should try expressions that involve precedence
and associativity. You should also try erroneous expressions.
expression.ss to support infix max and min operators.
You can choose appropriate characters to represent those operators. You
may assume that they have the same precedence and associativity as the
expression.ss to return a Scheme expression
equivalent to the infix expression, rather than returning the value of
the infix expression. One strategy is to change the portions of the code
in which a value is computed. Another is to change
expression.ss to support numbers with more than
one digit. You'll probably need a new procedure to parse numbers.
expression.ss to support exponentiation. You'll
need to add a new nonterminal (e.g., ExpExp) and modify code in a variety
Monday, 30 September 2002 [Samuel A. Rebelsky]
Tuesday, 1 October 2002 [Samuel A. Rebelsky]
Wednesday, 3 March 2004 [Samuel A> Rebelsky]
I usually create these pages
on the fly, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed May 5 11:46:46 2004.
The source to the document was last modified on Wed Mar 3 21:04:22 2004.
This document may be found at