This semester we also learned the principles of compiling knowledge, summed up, a total of several steps:
1. Lexical Analysis: The task is to convert the source program into an internal format;
2. Grammar Analysis: The task is to determine whether the source program structure conforms to the language syntax;
3. Semantic Analysis: The task is to ensure the semantic correctness of the source program;
4. Intermediate code Generation: Converts the source program into an equivalent intermediate language code;
5. Code optimization: Optimized processing of intermediate code
6. Target code generation: translates intermediate code into machine or assembly language. The methods and algorithms used in lexical analysis are: state transition diagram and finite automaton.
Among them, we mainly study lexical analysis and grammatical analysis part.
Lexical analysis:
The characters are read in turn, the identifiers are identified according to the poor automatic state machine, and their addresses are mapped.
The picture is a poor state machine.
Syntax Analysis:
Grammar analysis is divided into top-down and bottom-up analysis methods.
The method of top-down analysis using derivation is the key to the construction of the predictive analysis table, and its weak analysis ability.
The key of using the method of the bottom-up analysis method is to establish the SLR (1) Analysis table, which is superior to the top-down analysis method.
Mathematical modeling software of semester summary--compiling principle