Renaming & Typechecking

1. Renaming

An optional second phase of a compiler is renaming, designed to ensure the program is well-scoped. This involves distingushing between variables with the same name, and ensuring that each variable is declared before use.

A renamer needs to globally keep track of teh variables in the scope, and perform a counter on how many times a variable with the same name has been referenced.

2. Typechecking

Typechecking may be done in a bottom-up or top-down way:

We want to "parse" not "validate" - i.e. gain information about the types instead of just checking if they match up. In general, we always want to gain as much information as we can about the program at each stage of compilation.

Back to Home