Turing begets machines, machines beget assembly, assembly begets C, and C begets everything. (From Zhihu user Joy Neop)
This series will show the implementation process of a complete compiler from scratch.
The goal is to translate from an incomplete subset of the C language to x86 assembly language, using tools such as Lex Yacc LLVM, and tentatively implementing garbage collection and object orientation.
All code is hosted on GitHub. The source code of each stage can be viewed here.
The main reference is Tiger Book (“Modern Compilation Principles - C Language Implementation”). According to this book, the implementation is temporarily divided into 11 stages: Lexical analysis Syntax analysis Semantic action Semantic analysis Stack frame layout Translation Normalization Instruction selection Control flow analysis Data flow analysis Register allocation Code outflow.
Completed:
“Implementation of a complete compiler—lexical analysis | Anotherhome”
“Implementation of a complete compiler - syntax analysis | Anotherhome”
To be continued…