Difficulty: Easy
Correct Answer: Both of the above
Explanation:
Introduction / Context:
Compilers transform source programs into target code through a series of well-defined phases. Recognizing these phases helps developers understand diagnostics, optimization opportunities, and tool behavior.
Given Data / Assumptions:
Concept / Approach:
Lexical analysis tokenizes character streams into tokens. Code generation emits target code (machine code or intermediate forms). While “static analysis” is sometimes a broader term for compile-time checks, the question asks which listed items are compilation phases, and both lexical analysis and code generation are canonical phases.
Step-by-Step Solution:
Verification / Alternative check:
Compiler textbooks outline these phases explicitly, with examples from widely used compilers such as GCC and LLVM.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing lexical analysis with parsing; equating static analysis tools (linters) with compiler internals, though they share techniques.
Final Answer:
Both of the above
Discussion & Comments