CS 5363: Compiler Project, Part #2

Submission Deadline: 5pm, October 4, 2005

Project Overview

In this class, you will be writing an optimizing compiler for a toy programming language, which we will call, TL05 (and targeting the SPIM MIPS Simulator.) This project is tentatively divided into six parts. The first three involve, work on the front-end (Scanning and Parsing, type-checking, IR design and generation), and the last three involve work on optimization and code generation.

You may choose C, C++, or Java to implement your compiler, but it must compile and run on the machines in the Computer Science Department's Linux lab. (If you choose C or C++, you will also need to create a makefile that will build an executable from your source files.) The entire compiler must be your own, independent work, and each assignment will build on the work of the previous assignments.

Second Assignment

Your second assignment is to add type checking to your parser, so that incorrectly typed programs will be rejected. In addition, for all programs that parse correctly (even if they are incorrectly typed), you should create a graphviz DOT file containing that programs AST with the nodes representing (sub-)expressions annotated with their type. (You might chose to do this by coloring nodes of each type differently.)

A set of formal type rules for the TL05 programming language have been provided. But informally,

  1. The operands of all OP2, OP3, and OP4 operators must be integers
  2. The OP2 and OP3 operators create an integer result.
  3. The OP4 operators create boolean results.
  4. All variables must be declared with a particular type.
  5. The left-hand of assignment must be a variable, and the right-hand side must be an expression of the variable's type.
  6. When used as a value, a variable's type is its declared type.
  7. Only integer variables may be assigned the result of READINT.
  8. WRITEINT's expression must be an integer.
  9. The index for arrays must be integers.
  10. The expression guarding IF-statements and WHILE-loops must be boolean.
  11. If x is an "ARRAY # OF INT;," then x[<integer expression>] has type INT.
  12. If x is an "ARRAY # OF BOOL;," then x[<integer expression>] has type BOOL;.
  13. The literals "FALSE" and "TRUE" are boolean constants.
  14. The literal numbers -2147483648 through 2147483647 are integer constants. Numbers outside of that range should be flagged as illegal.

You are also required to adequately test your compiler and submit your test cases along with your source code. Agile programming techniques recommend that you do not write any code without first creating a test case that fails without that code. Your test cases should include both input (as a ASCII .tl05 file) and a description of the expected output. I may also provide some test cases.

Deliverables and Submission

When you have completed your assignment, you should create a tar archive or zip file containing your source files (with the correct package-based directory structure if you're using Java), the makefile (if your compiler is in C or C++), and your test cases. These should be attached to an email to vonronne@cs.utsa.edu. The subject of this email should containing the text "CS 5363 Submission #2", and the body should contain a "cover letter". This "cover letter" must contain:

  1. Your name.
  2. A statement that the attached source files are your own work.
  3. A statement of approximately how many hours it took to complete the assignment.
  4. Instructions for compiling and running your submission.
  5. A description of any known limitations of the implementation being turned in (e.g., incomplete features, test cases that don't run)
  6. A list of deficiencies that were in the parser when part #1 was submitted, but our now fixed.
  7. Anything else you think I should know while grading your assignment

Grading Criteria

As a matter of policy, late work will not be accepted. Partially completed assignments will, however, be evaluated for partial credit. This assignment depends on the parser working correctly, so the correctness or incorrectness of the scanner/parser will be considered when grading this assignment. Projects will be evaluated using a rubric similar to the following:

In addition, extra credit will be given for deficiencies in the parser that have been remedied, since part #1 was turned in. A penalty of up to 50% may be deducted if the program doesn't compile and run on the machines in the department's Linux lab.

Errata

There may need to be corrections, clarifications, or other modifications to these instructions, you are responsible for monitoring the class web site, monitoring your CS account mailboxes, and listening during lecture for announcements related to this assignment.