Type Rules for the TL07 Language

The formal type rules for TL07 are here, but the informal rules below should be sufficient for implementing your type checker for Part #2.

Informal Type Rules

  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 evaluate to 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. The literals "FALSE" and "TRUE" are boolean constants.
  13. The literal numbers -2147483648 through 2147483647 are integer constants. Numbers outside of that range should be flagged as illegal.

Errata/Clarifications