CSCE 425/825 - Compiler Construction

CSCE 425/825
Course Home Page
Course Description
Calendar
Project Upload
Resources
Project
Java
ANTLR
JVM and ASM
Eclipse and Plugins

Milestone 3 : Type Checking

Your task in this milestone is to extend the StaticJava type checker to support ExtendedStaticJava programs. The differences between StaticJava and ExtendedStaticJava are highlighted in the EBNF for ExtendedStaticJava. Most of the work in this milestone requires you to override the TypeChecker/ASTVisitor visit methods in ExtendedTypeChecker.java to implement the new type rules for ESJ.

You must submit your assignment through the course Project Upload site by 11:59pm CDT on Friday Nov. 2, 2007. Solutions submitted after the deadline will have their score reduced by 10% for each hour that they are late; late times will be rounded up to the next highest hour for this calculation.


Setup

Download the file myname-milestone3.zip

This contains a skeletal implementation of the milestone with a JUnit testing framework for your use.

In order to import the projects into your workspace, do the following:

Goto the "File" menu, select "Import". Expand "General" and select "Existing Projects into Workspace". Click "Next". Select "Select archive file:" and click the "Browse" button associated with it. In the file browser, points to the myname-milestone3.zip that you downloaded.

You should see "myname-milestone3", check the box, and click "Finish".

If you run Eclipse appropriately (i.e., using Java 5.0 and the right versions of plugins and by following the instructions in the course quick notes website), your workspace should be set.

Make sure you rename "myname" in the project's name into your CIS username by right clicking the project, select "Refactor" -> "Rename...".


Instructions and Hints

Your assignment is to implement the type checker for ESJ. You will do this by adding to the file:

sjc.type.checker.extended.ExtendedTypeChecker

which transfers the the actions for the basic SJ type checker into a skeleton for your ESJ type checker.

We are providing the file:

sjc.parser.extended.esj-ast.g

which contains a solution to milestone 2 that passes all of the test cases for that milestone. You can use that to see how to handle any features in ESJ that you did not completely handle in milestone 2.

You can tell if you are making progress by running the JUnit test suite. This is done by highlighting the class:

sjc.test.extended.ExtendedTypeCheckingTest
, right clicking and selecting "Run As" -> "JUnit Test". The results will be shown in total and on a per test case basis.

You can see the source of the test cases in src-examples directory of the milestone. For this milestone, the unit testing is done by differencing the output produced by running custom symbol and type table printing routines with output produced by our solution. Those files are stored with a .etc suffix.

You are done when all of the test cases pass or your run out of time.

It is a useful design strategy to write down a type rule for each new construct in ESJ before implementing it. Use the type rules from
lecture as a guide. Then you can map your rule to an implementation following the model of the StaticJava type checker.

IMPORTANT: Try to reuse as much of the StaticJava type checker as possible. You will definitely need to make some changes and perhaps add new visit methods, but there is much that can be reused and there is lots to learn from studying that code.

An extended symbol processing pass is supplied for your use. It is similar to what was covered in class except that in addition to the name and method maps there is now a fieldTypeMap (in class ClassType).

You will need to convert between JDT AST types and SJ/ESJ's type representation. Use the ExtendedTypeChecker.Visitor.convertType method to do this. At this point in the semester, you should be able to read code like this and understand what it does.


What To Submit

Your solution should consist of the following :

  • a modified version of ExtendedTypeChecker.java that correctly type checks ExtendedStaticJava
  • a description of all of the new type rules you implemented to handlethe ESJ features. These should be integrated into the header comments for each type checking method in the visitor that you create. Note that while these are comments, I expect them to be precise
  • a single text file that describe your implementation including any limitations and anything special you had to do to handle the extensions

Export your solution project as a single file named yourname-milestone3.zip, including the text files in the root directory of your project, and upload that file.

As with all programming, I expect that you provide reasonable internal documentation describing tricky/subtle parts of your implementation. If you have any limitations in your implementation you should include documentation describing those as well, since if we find them we will assume that you did not.

Your grade will be based on your solution (80%), your in type rule documentation (15%), and the description of limitations you provide (5%).

If you admit to failing a test then you will lose only half of the points associated with that test in comparison to our finding out you fail the test when we run your solution.