Exercise 6: Featherweight Java
Hand in:Friday, December 21.
The provided framework is self-contained and can be downloaded as zip.
Assignment
In this assignment you will implement Featherweight Java as presented in the document Featherweight Java A Minimal Core Calculus for Java and GJ" by Atsushi Igarashi, Benjamin Pierce and Philip Wadler in 1999. This is your most advanced assignment, and you are supposed to be able to follow the paper directly for this implementation. You are also given three weeks instead of the usual two.
You have to implement both a type checker and an interpreter for Featherweight Java. The input program has to be type checked, and if it is type correct the type is printed then each step of the reduction is printed on a separate line. If there is a type error, a meaningful error message and the offending position in the source code has to be printed.
Framework description
To get you up to speed, we included a full building parser for the language. You are free (encouraged) to modify it if it doesn't suit your needs (or find some bugs). You can even write your own parser from scratch. This framework is entirely optional. A few remarks about the framework:
-
The
FieldDef
tree is used to represent both fields and parameter lists in methods and constructors. All three are really just lists of type and name pairs. -
All names are plain strings. In a production compiler one
would use
Symbols
to keep track of names and associated information (like types). We don't do that.
- The paper talks about a global class table, and it might be useful to implement such a thing.