CS G111 Machine Problem 7: Extending a Type Checker

Out: November 13, 2007

Due: November 20, 2007

Designed by Bryan Chadwick

In directory mp7. is a class dictionary for a simple PL with numbers and booleans with single argument lambdas.

The Evaluator handles LetRec and multiple Arg Lambdas without any changes to the code (just an adjustment of the field name "formal" -> "formals" in the Edge control) so you will not need to change EvalFunc.java or LetrecEvalFunc.java.

You should proceed as follows:

1) Read through and understand the code (at least the important parts). You will be changing the files in the 'extra' directory, but you shouldn't need to make any changes to more than a few lines of already written code. Bryan setup the files so that the files Letrec*.java contain all the code dealing with the new constructs.

2) Get the Jar working... For this mp there is a new version of the Jar. Bryan added an initialization check that edges to be bypassed actually exist; this will help you to debug in the single to multiple args conversion. The method lookup is also much better with some decent output available for debugging.

Util.setDebug(true) and/or Bc.setDebug(true) should help. 

3) Add code for LetrecAddrTrans.java which helps transform Syms into Addr for the Evaluator - To help you in this step Bryan added a command line 'switch' to Main to disable the type checking or evaluation. Running DemeterJ as:

demeterj test NoTypeCheck     or
demeterj test NoRun
will skip type-checking or evaluation respectively, so you can test parts of your implementation separately. Why does DemeterJ know to compile the .java files in the extra directory? It is being told in program.prj file.

4) Add Code for LetrecTypeChecker.java to type-check LetRecs. Here you need to update the type environment, (TEnv update(LetRec l, TEnv te){ ... }) and do checking of LetRec (Type combine(LetRec l, Type a, Type e, Type body){ ... })

5) Update program.beh, TypeChecker.java, and AddrTrans.java to support multiple arg Lambdas. It seems like some work, but it's really only 20 lines of code, and almost no code modification. Bryan included some simple but interesting tests for stages of letrec, and multiple arguments [of course factorial is there :)].

The new jar is placed at: /home/chadwick/www/demeterf/mp7package.jar

As you did last week, you should add additional tests to demonstrate the extensions you write for this problem. Your tests must include both programs that pass your type checker and those that fail, to show that it rejects all the programs it should.

Your tests should include running the programs, not just typechecking them.

Last modified: November 2007