The GATE Grind

GATE 2021 CS (CS2) – Question 13

Compiler Design · Syntax-Directed Translation · 1 mark · Multiple choice

Which phase of a seven-phase ANSI C compiler reports the error?

int main() {
 Integer x;
 return 0;
}

Assume Integer has not been declared as a type.

  1. Lexical analyser
  2. Syntax analyser
  3. Semantic analyser
  4. Machine-dependent optimizer

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) Semantic analyser

Explanation

Integer is a lexically valid identifier. The declaration-like token sequence is structurally recognizable, but Integer is not a declared C type in the symbol/type environment. The source’s compiler-phase model attributes this undeclared-type error to semantic analysis, C.

More Syntax-Directed Translation questions

All Syntax-Directed Translation questions →