Skip to content
Official PYQ · 1998

GATE CS 1998 Q1.27 — Parsing (LL, LR)

Explain with AI

Type checking is normally done during

Choose one option
View worked solution

Answer: C

Type checking is a core task of the semantic analysis phase of a compiler. It ensures that the operators and their operands are type-compatible according to the language specification.

Here is how the phases relate to the options:

  • Lexical Analysis (A): Groups characters into meaningful sequences called tokens (e.g., identifiers, keywords). It has no concept of types or grammar.
  • Syntax Analysis (B): Checks whether the token stream conforms to the grammatical rules of the language and constructs a parse tree. It does not verify semantic meanings like type compatibility.
  • Syntax Directed Translation (C): Semantic analysis (including type checking) is typically implemented using Syntax-Directed Translation (SDT). In SDT, semantic actions and attributes are associated with the production rules of the context-free grammar, allowing the compiler to perform type checking and generate intermediate code while parsing or traversing the parse tree.
  • Code Optimization (D): Transforms the intermediate code to make it run faster or consume less memory, which happens long after types have been checked and verified.

Thus, type checking is normally performed during syntax directed translation.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions