CH-1 Review
What is compiling process?
7 steps
- Lexical Analysis
- Syntactical Analysis
- Interpretation
- Machine Independent Optimization
- Storage Assignment
- Code Generation
- Assembly Output
Important
- Steps 1 - 4 are machine independent Analysis
- Steps 5 - 7 are machine dependent Synthesis
Syntactical Analysis
- Use parsing tree to analyze the order of the expression
- Decide the order of execution
Important
Order of execution:
- operator precedence
- association
Semantic Analysis
- Type checking
- Type conversion
Note
Cross Compiler
It is a kind of compiler that produces object codes compilers on other machines to compile
Analysis
- Break source code into pieces
- generate intermediate code as the representation of the source code
Synthesis
- Based on the intermediate code, generate the target code
Syntax Tree
- e.g.
position:= initial + rate * 60
:=
/ \
/ \
position +
/ \
/ \
initial *
/ \
/ \
rate 60
How does a program get compiled and executed?
- Preprocessing
- Compiling
- Assembling
- Linking
- Loading
Phase of Analysis
Lexical Analysis
- Parse the source code into tokens
- e.g.
position:= initial + rate * 60->position,:=,initial,+,rate,*,60
Hierarchical Analysis
- Tokens are put together into a nested structure with collective meanings
Semantic Analysis
- Perform certain checks to ensure the components put together are meaningful
