Due: 10:00 pm, Monday, October 18.
Project 3 is to read chapter five of the text and build a static-semantics checker for Appel's Tiger language.
Your code should perform the static-semantics checks decribed in Chapter 5:
Your semant
module should export
a function with this signature:
transProg : Absyn.exp -> unit
that checks an AST and outputs error messages if anything is wrong.
(Why is our type-checker called transProg
rather than
something like typeCheck
?
Because we'll be extending it in project 4 to type-check
and translate the AST to our intermediate representation.)
You will find a structure Types
defining a datatype
to represent Tiger types in $TIGER/chap5/types.sml
.
If you wish to use the type lattice I sketched out in my types lecture for
your compiler, you will have to extend Appel's definition to include a
"bottom" type (compatible with everything)
for the type of break
expressions.
This will permit your typechecker to pass expressions such as
if y = 0 then break else x / y x / (if y = 0 then break else y) a[break] := x x := break
This is a permitted extension to the compiler. It's not required, however.
You should submit:
semant.sml
file containing your codesources.cm
fileWords to the wise:
Types.ty
Absyn.ty
Absyn.ty
chunk of Tiger type syntax
to a Types.ty
value.
But don't confuse the two different datatypes.
Anytime you must handle a description of a Tiger type,
be clear in your mind:
are you handling a semantic value or a chunk of syntax?
type a = b type b = abut this is:
type a = b type c = int type b = cI know of at least two good ways to do this, and many more bad ways. Give it some thought.