I don't know if I'll be teaching the course again, but if I wait until next year I'll forget feedback I've received. Note that more test cases have been added (if you pull the new starter code); those are for the (potential) future!
After building an AST, a compiler typically builds an intermediate representation of the program, which typically consists of some form of a control-flow graph. Before or after building the IR, and perhaps in multiple passes, the compiler also performs validation and possibly analyses (which may be necessary for building the IR or final code generation, or only necessary if optimizations are being performed).
Our lab project will not require building an IR, but if you wish to extend your compiler beyond this course, that is something you may want to look into. I am happy to provide guidance.
In this lab, your task will be to perform static type validation on the AST:
You are not required to check anything else, e.g. you do not need to check that operands of binary expressions have the same type.
The test cases used for marking are provided in the starter code’s test
directory.
See the comment at the top of each file for a description.
On top of the 2 failure cases in test/lab3
, we will run your code through the 3 success cases in test/lab2
.