# Compilers Principles
# reading Notes
# 2016.02.03
# Victor
1 Introduction
1.1 Compilation process
Begin: Source program
# Front end: related to source code
A. Character Stream-->[lexical analysis]-->
B. Symbolic stream-->[syntax analysis]-->
C. Syntax tree-->[semantic Analysis]-->
D. Syntax Tree-->[intermediate code generation]-->
# middle End
E. Intermediate representation-->[machine-independent code optimization]-->
F. Intermediate representation-->[code generation]-->
# back end: related to target machine
G. Target machine language-->[machine-related code optimization]-->
End: Target machine language
Lexical analysis of 1.1.1
The lexical parser reads a stream of characters, organizes them into meaningful morphemes, each morpheme, and uses the lexical unit (token) as the output.
Lexical unit: <token_name,attribute_value>.token_name is an abstract symbol used in the parsing phase, and the second component points to the entry for the lexical unit in the symbol table.
Input example:position = initial + rate * 60;
Analysis
Position: The <id,1> ID represents an identifier, and 1 indicates the entry to which it is pointing;
=: <=> assignment operator, attribute value omitted;
Initial: <id,2>;
+: <+>;
Rate: <id,3>;
*: <*>;
: <60>;
1.1.2 Syntax Analysis
Compilation principle--reading Note