Homework #35


This problem requires Lecture 34 and book section 5.1-5.4.1.

Part A - Exercise 5.11, p.199 - (30 minutes)

Add to our language the expression instanceof exp class-name. It is true if and only if the object obtained by evaluating exp is an instance of class-name or one of its subclasses. In our framework, why must this be an expression rather than a primitive?

The book omits the BNF:

The BNF for <expression> (with instanceof)

<expression> ::= instanceof <expression> <identifier>
 

Part B - Exercise 5.20, p.200 - (30 minutes)

In our interpreters, the class object is a special case because it is not explicitly represented in the class environment. What procedures must be aware of this special case? Eliminate these special cases by placing a class whose name is object into the intial class environment. Give the class object an initialize method, so that it is possible to create an object of class object, and so that there is a default initialize method.

Implement both of these in the same interpreter and submit it as a single file.

Base your implementation on the simple implementation of an object-oriented interpreter.


You must log in first before submitting homework assignments.

Instructions on submitting homework is here


Last updated at 10:32 am on Wednesday, April 05, 2006.