By Johan E. Thelin
I've begun designing my own compiler lately after reading 'Let's Build a Compiler' by Crenshaw (see links). This page will contain the compiler source code, a text concerning the implementation of each part (the compiler will be created gradually) and useful links concerning compilers, compiler design, and other close subjects (OS specifics, hardware specifics, etc.). I hope that you will enjoy reading this page.
This tutorial is written 'as I go'. It is strongly influenced by 'Let's Build a Compiler' but is also flavored by myself. The language defined is a pseudo-pascal with the following features:
The variable types word and byte.
- No automatic type conversion, i.e. control.
- The control structures if-else, while-wend and repeat-until.
- Support of the following unary operators +,- and the following binary operators +,-,/,* and parenthesis.The language supports functions and procedures (even recursive ones).
- Other thing that we find necessary later.
- Chapter I - How is the compiler supposed to work and how should the language look?
- Chapter II - Let's get Compiling
- Chapter III - Get the Compiler Counting
- Chapter IV - Our First Control Structure
- Chapter V - Variables, Procedures and Functions
- Chapter VI - More About Variables, Procedures and Functions