COSC 152 Programming Languages
Fall 2006
Homework Assignment #10
Type Checking, Part II
Due: Wednesday, Nov 29, 2:00PM CST
Submit: E-mail electronic
copy to professor, with a subject header "COSC 152 HW#10".
Work may be completed in groups of up to three students. Each group
should submit only once. Be certain to put all team member names on
work submitted. It would be courteous to carbon-copy your team mates
when e-mailing the final submission.
For this assignment, extend the grammar from HW
#9 with a type annotation for lists as noted below:
<type> |
   ::=    |
listtype <type> |
In addition, the syntax for primitive "emptylist" should now
be extended to take a type as a parameter.
Extend your type-check function to handle type checking for
all of the list-related primitives: cons, car, cdr, list, empty-list,
and empty?.
Notes:
The new static type rules for lists are far more restrictive than
Scheme's dynamic type checking. Many list operations that would
be legal in Scheme will be type errors in our new language.
Your internal representation of types must be able to represent
and match base types (int,bool,) function types
(arrow types,) the void type, and now listtype
types.
Because all statements have a return type of void,
your type checker will return void as the result type
of all properly formed programs in the full grammar. For development
and testing purposes, you may find it helpful to temporarily pare
down the grammar to the expression subset to debug at that level.
Emit useful error messages upon encountering a type error. Give
at least the offending syntax, the expected type, and the found type.
Back