Question:

In a compiler, type checking is normally done during which phase?

Show Hint

Type checking belongs to semantic analysis, not syntax or lexical analysis.
Updated On: Feb 8, 2026
  • Lexical analysis
  • Syntax analysis
  • Syntax directed translation
  • Code optimization
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Understanding type checking.
Type checking ensures that operations in a program are applied to compatible data types, such as preventing addition of an integer and a string.
Step 2: Role of compiler phases.
Lexical analysis identifies tokens, while syntax analysis checks grammatical structure. Neither phase checks semantic correctness like type compatibility.
Step 3: Syntax-directed translation.
Type checking is part of semantic analysis, which is implemented using syntax-directed translation with attributes attached to grammar symbols.
Step 4: Final conclusion.
Hence, type checking is normally performed during syntax-directed translation.
Was this answer helpful?
0
0