CS712/CS812
Project Phase 3
Spring 2008
Due Sunday April 6


Add support for classes to your T compiler. However, you do not need to implement methods (or constructors or destructors) for this phase. Methods (and constructors and destructors) will be added in Phase 4.

Therefore, you are responsible for implementing class declarations, including fields and the specification of the superclass. You should also implement class instance creation, but you do not need to call a constructor. Simply ensure that all fields are given the correct default value. Also implement field access.

First, you should fix all bugs in your compiler with respect to Phases 1 and 2. Testing (and grading) your Phase 3 submission will depend on the Phase 1 and Phase 2 functionality.

You will need to upgrade your scanner to add support for the keywords required by class declaration and class instance creation. Also add tokens for the field access operator and the null literal.

You will need to upgrade your parser to add the necessary productions and build AST nodes for class declarations, class instance creation expressions, field access expressions, cast expressions and null literals.

You will need to upgrade your semantic analysis routines to properly handle classes, including the pre-defined class Object. Be sure to detect the necessary semantic errors and issue appropriate messages to stderr. Note that, now that we have more than just int type, we can test semantic errors involving some of the operators implemented in Phase 1, such as adding an int to a reference to a class instance. And, note that, as well as handling class instance creation, field access and cast, you need to upgrade previously implemented operators that can take class instance operands (assignment and equality).

Finally, you will need to upgrade your code generator to generate code for classes. Note that this will include tracking the types of class instances at run time. Be sure to consider detecting run-time errors involving cast expressions, null references and class instance creation.

Your compiler should maintain all the behavior mandated by the Phase 1 specification, regarding command-line switches, AST dump format, Makefile goals, README file, etc.

Add a new command-line flag "-classes" that will dump all class types to stderr. For each class, show the class name, the super class name and the list of fields, indicating the name and type of each field. The exact format of this display can vary but please make yours easily understandable. This dump should include the pre-defined class Object.

Archive all your files in a tar file called "phase3.tar". This tar file should un-tar into a single directory called "phase3", which should contain the Makefile, the README file, the "RTS.cxx" file and all the source files. All submitted files should be placed directly in the top-level of this directory. (That is, please do not use subdirectories.) You should submit your tar archive from euler.unh.edu or zeno.unh.edu using my "submit" script. (The submission script will not work from gauss.unh.edu.) Please note: the tar file you submit should not be compressed. But, please, do not include any executable or object files in the tar file.

To turn in this assignment, type:
~cs712/bin/submit phase3 phase3.tar

Submissions can be checked by typing (also on euler.unh.edu or zeno.unh.edu):
~cs712/bin/scheck phase3

Points will be assigned for this assignment in the following manner:

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday April 7. Late submissions will be accepted at a penalty of 2 points for one day late, 5 points for two days late, 10 points for three days late, 20 points for four days late, and 40 points for five days late. No program may be turned in more than 5 days late.

Remember: you are expected to do your own work on this assignment.


Last modified on March 2, 2008.

Comments and questions should be directed to hatcher@unh.edu