The Syntax Analysis phase checks the source code against the grammar rules to ensure correct syntax. It builds a parse tree representing the code structure.
Lexical Analysis reads the source code and converts it into tokens, which are the basic units like keywords, identifiers, and symbols.
Semantic Analysis checks the meaning of the code, ensuring type correctness, proper declarations, and valid operations.
Code Generation converts intermediate code into machine code. Code Optimization improves the intermediate code to run faster or use less memory before final code generation.
1. Semantic Analysis
2. Lexical Analysis
3. Code Generation
4. Syntax Analysis
The correct order is Lexical Analysis (tokens), Syntax Analysis (structure), Semantic Analysis (meaning), and Code Generation (machine code).
