Programming Languages: Optional Homework Assignment 2
For those who did the first optional homework assignment, the best
score between both assignments will be used to complement the mid-term
Due on May 2, 2000, 6:00pm (late homeworks will not be accepted).
- Electronic submissions only.
To be sent by email to firstname.lastname@example.org.
- Send only a single text (ASCII) file as an email message.
- You are required to include a printout of a session
showing a run of your program(s) on some general test data.
This homework can be implemented indifferently in Java or C++.
Consider a simple language for arithmetic expressions, defined as:
Exp ::= Int | Exp + Exp | Exp - Exp | Exp * Exp | Exp / Exp
Represent each kind of arithmetic expression using classes and objects. For
example, the expression
(3+(5+6)) would be created by writing
new AddExp(new IntExp(3), new AddExp(new IntExp(5), new IntExp(6)))
Write an evaluator that takes such an expression, and computes its
value (of type int). Particular care should be taken with
division by 0.
This document was translated from LATEX by HEVEA.