Next: , Previous: , Up: TC-4   [Contents][Index]


4.8.5 TC-4 Options

These are features that you might want to implement in addition to the core features.

type::Error

One problem is that type error recovery can generate false errors. For instance our compiler usually considers that the type for incorrect constructs is Int, which can create cascades of errors:

"666" = if 000 then 333 else "666"

File 4.38: is_devil.tig

$ tc -T is_devil.tig
error→is_devil.tig:1.9-34: type mismatch
error→  then clause type: int
error→  else clause type: string
error→is_devil.tig:1.1-34: type mismatch
error→  left operand type: string
error→  right operand type: int
⇒5

Example 4.47: tc -T is_devil.tig

One means to avoid this issue consists in introducing a new type, type::Error, that the type checker would never complain about. This can be a nice complement to ast::Error.

Various Desugaring

See TC-D, for more details. This is quite an easy option, and a very interesting one. Note that implementing desugaring makes TC-5 easier.

Bounds Checking

If you felt TC-D was easy, then implementing bounds checking should be easy too. See TC-B.

Overloaded Tiger

See TC-A, for a description of this ambitious option.

Renaming object-oriented constructs

Like TC-R, this task consists in writing a visitor renaming AST nodes holding names (either defined or used), this time with support for object-oriented constructs (option --object-rename). This visitor, object::Renamer, shall also update named types (type::Named) and collect the names of all (renamed) classes. This option is essentially a preliminary step of TC-O (see the next item).

Desugaring Tiger to Panther

If your compiler is complete w.r.t. object constructs (in particular, the type-checking and the renaming of objects is a requirement), then you can implement this very ambitious option, whose goal is to convert a Tiger program with object constructs into a program with none of them (i.e., in the subset of Tiger called Panther). This work consists in completing the object::DesugarVisitor and implementing the --object-desugar option. See TC-O.


Next: , Previous: , Up: TC-4   [Contents][Index]