6.035 - Fall 1999 - TA: Daniel Barkalow le04

Static semantic checker project

1 Reintroducing le04

Chris Laas (golem) Mike Phillips (mpp) Jim Waldrop (jlwfnord)

2 Division of Labor

Mike wrote Parser.cup. Jim wrote Semant.java, which was then absorbed into Parser.cup. Chris wrote the IR2 framework. Actually, that’s not really accurate. Everyone managed to muck with everyone else’s code.

3 Clarifications, Assumptions, Additions

We assumed that both sides of a conditional expression needed to be booleans.

4 Overview

The point of this project was to build a static semantic checker for Decaf. To do this, we drastically extended our Parser framework from the last project (in Parser.cup) and wrote an intermediate representation package (IR2). Semantic checking rules were approximately evenly split between internal methods and error checks in IR2, and grammar extensions in Parser.cup.

5 Implementation Issues and Insights

For each of the semantic rules, we had to decide whether to implement the rule in the Parser.cup grammar specification or in another class (Semant.java). We initially planned to implement about half of the semantic rules in Semant.java - as we worked on the project, this was gradually whittled down to no rules in Semant.java and all rules in the Parser.cup spec (luckily a bit of code reuse was possible...)

We also wrote our IR from scratch (package IR2)... this made our project take a little longer - on the other hand, our IR is slightly more efficient and easier to use, and this will pay off later on tenfold.

6 Code

Attached.

7 Known Problems and Wish List

Known problems: The error recovery from type check errors doesn’t work all the time, resulting in errors that the compiler can’t recover from. This could/will be fixed with a little more bughunting. Wish list: We wish the due time could be pushed back an hour or so, so that the fact that jlwfnord and mpp have 6.001 tutorials from 1pm to 5pm on Monday and Tuesday doesn’t make us chronically “late by just this much”.