Skip to main content




Transform source code to an executable form.


A compiler transforms the source code of a program (in a source language) to an executable form (in a target language) and consists of the following phases:

  • Parsing: Read the source code and build an Abstract Syntax Tree.
  • Typechecking: Perform a semantic analysis of the code, resolving all names and verifying that the program is type correct.
  • Optimising: Perform optimisations (e.g., constant folding, dead code elimination, call unfolding). This can be seen as a form of Refactoring.
  • Code generation: Generate the final code, this can be assembly language or directly executable code.