Which sequence below best describes the order in which the phases of a…
2023
Which sequence below best describes the order in which the phases of a compiler typically work?
- A.
Syntax analysis, lexical analysis, χ semantic analysis, code optimization, intermediate code generation
- B.
Lexical analysis, syntax analysis, semantic analysis, code optimization, intermediate code generation
- C.
Syntax analysis, lexical analysis, syntax analysis, semantic analysis, syntax analysis,intermediate code generation, code optimization
- D.
Lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization
Attempted by 214 students.
Show answer & explanation
Correct answer: D
The standard compilation process follows a specific sequence of phases. It begins with lexical analysis, which tokenizes the source code. This is followed by syntax analysis (parsing) to build a parse tree, and then semantic analysis to check for meaning. Next, intermediate code generation creates an abstract representation, which is optimized before final code generation produces the target machine code.