Exercise 6: Featherweight Java
Hand in:Friday, December 24.
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. You should be able to follow the paper directly for this implementation.
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 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. - You are free to modify the framework in order to give more meaningful type errors or fix any bugs you encounter.
-
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.