Input Code --> Compiler --> Output Code
Compiler: Front-end --> Back-end
Front-end: Morphology --> Syntax
Back-end: Instruct --> Optimize
Morphology analysis --> Syntax analysis --> Semantic analysis --> Generate Code
The sequence of characters --> Marks --> Abstruct Syntax Tree --> Middle Code --> Target Code
A compiler is combined with multi phases, and each phase handles different problems. (There should be use different data structure and algorithms)
Source code: Function Sum
Target machine: A stack computer
Mission: To compile a program 1 + 2 + 3 to stack computer
Syntax analysis and semantic analysis
Generate AST (Abstract Syntax Tree)
Generate Code