Chapter1 Introduction
Chapter1 Introduction
Parsing
Semantic Analysis
Optimization
Code Generation
Lexical Analysis
• First steps: recognize words
- Smallest unit above letters
This is a sentence
subject object
sentence
Parsing
if num1 == num2 then result = 1; else result = 2;
if-then-else
Semantic Analysis
• Once sentence structure is understood, we can try to understand
“meaning”.
• A ‘type mismatch’ between Tom and her, we know they are different
people.
Optimization
• Automatically modify programs so that they
• Run faster
• Use less memory
• Reduce the amount of power
• Reduce the number of network messages
• Reduce the number of database accesses.
Optimization
A = B * 0 is the same as A = 0
Code Generation
• Produces assembly code (usually)
Semantic Code
Lexical Analysis Parsing Optimization
Analysis Generation
Lexical Code
Parsing Semantic Analysis Optimization
Analysis Gen
• Compiler translates from one language to another