How to Write a Compiler/The Compilation Pipeline
Appearance
The job of accepting a source file, analyzing it and producing a target file can be roughly divided up into a number of discrete steps. These steps are organised as a pipeline, with every step working on the output from the previous step and producing the input for the next one. This is called the compilation pipeline and can be found in one form or another in each compiler.
For a generic compiler which accepts a higher-level language and produces code in a lower-level language, the steps of the compilation pipeline would be:
- Scanning
- Parsing
- Semantic Analysis
- Generation of the Intermediate Language
- Code optimisation
- Generation of the target language
Depending on the requirements of the language, a compiler may do more or less in each step and may skip steps completely.