CS712/CS812
Project Phase 3
Spring 2009
Due Sunday April 19


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.

You should provide support for class instance creation, but you do not need to call a constructor. Simply ensure that all fields are given the correct default value. Also provide support for the null literal, field access, casts, reference assignment, and reference equality.

For full credit, also add support for arrays of objects. (If you have not yet implemented arrays of integers, you must first do that.) This requires supporting array reference assignment, array creation expressions, array access expressions, casts to and from array types, and the equality operator applied to array references. You should support multidimensional arrays.

You should extend your scanner to recognize the additional tokens required for this phase. The scanner should still be capable of running in stand-alone mode.

You should extend your parser to recognize the additional syntax required for this phase. Your parser should build an AST for the whole program. The compiler may stop at the first parse error.

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 2, 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).

You should try to identify all semantic errors in the input. When an error is found, report it with the appropriate line number and an appropriate error message. (Sometimes because of how flex and bison work, your line number may unavoidably be off by one. This is okay.) Error messages should be written to stderr. Try to avoid a cascade of error messages caused by a single error.

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 and Phase 2 specification, regarding command-line switches, AST dump format, Makefile goals, README file, etc.

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.c" 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 agate.cs.unh.edu using my "submit" script. 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 (on agate.cs.unh.edu):
~cs712/bin/submit phase3 phase3.tar

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

Please read this specification carefully and try to follow it exactly. I will use scripts to test your compiler and therefore it is important that you follow my directions for the file names, command-line options, Makefile goals, tar file name, etc. (Points may be deducted if you do not follow the directions.)

To obtain 70% of the points for this assignment, you should support class instance creation, the null literal, field access, reference assignment, and reference equality. At this level you do not need to detect semantic errors. Testing at this level will assume your compiler is correctly working at the 70% level for the Phase 2 functionality.

To obtain 80% of the points for this assignment, you should first complete the 70% requirements. And then add support for casts. At this level you do not need to detect semantic errors.

To obtain 90% of the points for this assignment, you should first complete the 80% requirements. And then add support for semantic error detection. This includes upgrading your semantic error detection for the 60%-level and 70%-level operators of Phase 2 to consider the incorrect use of object types.

To obtain 100% of the points for this assignment, you should first complete the 90% requirements. And then add support for arrays of objects. Testing at this level will assume your compiler is correctly working at the 100% level for the Phase 2 functionality.

Note: You must approach this assignment by first completing the 70% level, then the 80% level, then the 90% level, and finally the 100% level. First, I believe this will most likely lead to the greatest success for the most of you. You need to get a piece of the assignment working and then add to it as much as you can until you run out of time (or energy). ( Do not try to sit down and do the whole assignment at once! ) Second, this is how I will grade it. For example, my tests for the 80% level will assume you have the 70% level done.

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday April 20. 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 30, 2009.

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