Compilers: Programming Assignment 4

Type checking php--

Due date: Friday, April 4, 2008

The goal of this programming assignment is to implement the type checker for php-- and thereby gain experience writing code that analyzes programs by recursively navigating abstract syntax trees.


What you need to do

    Read this assignment and the php-- type rules in their entirety. If you follow the type rules carefully, this assignment is fairly straightforward.

    Download the starter project, try compiling and running it. As it stands, it is not good for much: it can only successfully type check echo statements over string literals such as:

      echo "hello", "bye";
    

  1. Implement and test type checking for assignment statements.

  2. Implement and test type checking for typed expressions.

  3. Implement and test type checking for any remaining literal expressions and unary- and binary-operator expressions.

  4. Implement and test type checking for compound statements, if statements, while statements and foreach statements. Do not forget to test both kinds of if statements and both kinds of foreach statements.

  5. Implement and test type checking for functions, call expressions, call statements, and return statements.

  6. Implement and test type checking for array expressions, subscript expressions, and append statements. Be careful when handling empty arrays.

  7. Test your project as thoroughly as possible. This means trying both valid php-- programs and programs that have type errors. Here are several examples (though you should also write your own).


Binaries

You may find it useful to experiment with the binaries for the solution.


Submission

Upload the sources for the three relevant files for your type_check package here.