Add support for methods, constructors and destructors to your T compiler. This includes method declarations, method calls, method arguments, method return values, method inheritance, method overriding and method overloading. With respect to constructors and destructors, you will need to implement constructor declarations, constructor calls, destructor declarations, delete statements, default constructors and destructors, constructor overloading, implicit superclass constructor invocations and implicit superclass destructor invocations.
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 methods, constructors, destructors and the delete statement. Upgrade your handling of the pre-defined class Object to support its method, its constructor and its destructor.
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 methods, constructors, destructors and the delete statement. Be sure to consider detecting run-time errors.
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.
Upgrade your handling of the command-line flag "-classes" in order to also dump the methods, constructors and destructors. You should show the method name, its return type and its parameter names and types. It is up to you whether you dump the default constructors and destructors. It is also up to you whether you dump the inherited methods for a particular class, or only show the methods explicitly declared in the class.
Archive all your files in a tar file called "phase4.tar". This tar file should un-tar into a single directory called "phase4", 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 phase4 phase4.tar
Submissions can be checked by typing (also on agate.cs.unh.edu):
~cs712/bin/scheck phase4
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 delete statements (with the corresponding destructor calls), method declarations and method invocations with no parameters, and constructor declarations and constructor invocations with no parameters. Method overriding, but not method overloading, should be supported at this level. Be sure to check for the semantic errors appropriate to this level.
To obtain 80% of the points for this assignment, you should first complete the 70% requirements. And then add support for method and constructor parameters. You do not need to support method and constructor overloading at this level. Be sure to check for the semantic errors appropriate to this level.
To obtain 90% of the points for this assignment, you should first complete the 80% requirements. And then add support for method and constructor overloading. Be sure to check for the semantic errors appropriate to this level.
To obtain 100% of the points for this assignment, you should first complete the 90% requirements. And then add support for arrays as class fields, method parameters, constructor parameters and method return values. Also add support for the array field length. Be sure to check for the semantic errors appropriate to this level. Testing at this level will assume your compiler is correctly working at the 100% level for the Phase 3 functionality.
To receive full credit for the assignment, you must turn in your files prior to 8am on Monday May 11. 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.
Comments and questions should be directed to hatcher@unh.edu