CS712/CS812
Possible Phase 4 Assignments
Spring 2001


You will be assigned one of the following tasks. Please let me know by Tuesday April 24 any preference you might have. I will give you a definite assignment no later than Wednesday April 25. This phase ends on Sunday May 13.

  1. Add semantic analysis and code generation support for structs and unions. This first involves implementing the operators for member reference (e.g. s.m and p->m). Next you need to be sure the previously implemented operators (ASSIGN, DEREF, etc.) are upgraded to properly handle structs and unions. You should also be sure that structs and unions can be passed to functions and returned from functions (if legal). The struct and union operations provide additional lval possibilities, so you will need to fix the isLval and isModifiableLval routines. And you need to think hard about whether there are additional places in the compiler that need to be upgraded for structs and unions.

    Be sure to carefully consider what semantic errors need to be detected and reported in the processing of structs and unions. When errors are encountered, use the "error TYPE" to denote the existence of the error in the abstract-syntax tree and key on the "error TYPE" to avoid a cascade of errors. This is in addition to issuing an appropriate error message through the message module, of course.

  2. Add support to the compiler for enum and typedef declarations. Also add support for operations on enum values. (An enum value is just treated like an int, so this should be relatively easy.)

    The typedef declaration was studied by a student during phase 1. His report and test files will be made available to you.

  3. Add support to the compiler for the declaration of incomplete array types. Also add support for operations on string literals. In addition, check that parameters and arguments of array type are properly handled (and fix the compiler if necessary).

  4. Add support to the compiler for "old-style" functions and for prototypes with a variable number of arguments. This will require modifications for both declarations and function calls. Also allow a function to be called that has not been previously declared.

  5. Add support to the compiler for constant expressions. Evaluate the expression at compile time and build a tree node for the resulting constant. Reinstate constant expression to the places in the grammar where we had removed it, such as array dimensions.

  6. Add support for initializers to the compiler. Be sure to consider array and structure initialization, as well as primitive types.

  7. Add support for bit fields to the compiler. This should include both declarations and uses of bit fields.

  8. Evaluate how the compiler currently represents qualified types. Fully implement qualified types, in particular the necessary semantic checks for qualified types.

Code produced by the class during Phase 3 will be available in ~cs712/public/phase4. I will place code there as soon as I have had a chance to evaluate the Phase 3 submissions. You must build your phase 4 contribution upon this "officially sanctioned" code base.


Last modified on April 19, 2001.

Comments and questions should be directed to pjh@cs.unh.edu