The document describes the main phases of compilation: lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. Lexical analysis converts the source code into tokens. Syntax analysis groups the tokens into a parse tree. Semantic analysis checks that the program is semantically correct. Intermediate code generation outputs machine-independent code. Code optimization improves the intermediate code. Finally, code generation converts the optimized code into machine-dependent target code.