Compiler Introduction: Overview, compiler Overview
First of all, I declare that this series of blog posts is a record in the process of learning compilation principles. The main reference book is Allen I Holub's Compiler design in C.
First of all, I would like to express my gratitude to the author of this book, such as the dragon book, the tiger book, and the whale book. The basic book is too advanced. You can also read and understand the core ideas, but there is still a distance from writing the actual code by myself. I think it is really meaningful to write the code by myself, so I will rewrite the Code with the book (the original book is the C version, I tried to change to the Java version by myself) and split the overall structure of the compiler in order to sort out clear lines so that I can really understand and recall them later. The above is my original intention.
According to the organizational structure of the original book, it is also divided into lexical analyzer generator (LEX) and syntax analyzer generator (YACC). First, put a structure map of the recently combed lexical analyzer, it will be further explored in the future.
The figure is drawn using the Mind Map freeplane. It is too big. Let's look at it in a few pieces.
Figure 1 Overall graph of lexical analyzer
Figure 2 input buffer Structure
Figure 3 structure of lexical analyzer Generator
Figure 4 uncertain finite automaton Structure
Figure 5 finite automaton Structure
Figure 6 analyzer generation
Figure 7 Template File
The code for the current project is attached:
Compiler generator Compiler: https://github.com/9527hello/Compiler
C compiler CCompiler: https://github.com/9527hello/CCompiler