This document discusses the phases of a compiler:
1. Lexical analysis breaks the program into individual tokens.
2. Syntax analysis checks that the tokens are arranged according to grammar rules.
3. Semantic analysis checks for semantic errors like variable usage before declaration. It annotates the syntax tree with types.
4. The intermediate code generator produces a three-address code that is easy to optimize and translate to target code.
5. Code optimization simplifies the three-address code through techniques like constant folding and dead code elimination. Target code optimization further improves the code.
6. The code generator produces assembly instructions for the target machine based on the optimized three-address code.