The GATE Grind

GATE 2024 CS (CS2) – Question 21

Compiler Design · Intermediate Code Generation · 1 mark · Multiple choice

Consider two sets. Set X: P. Lexical Analyzer, Q. Syntax Analyzer, R. Intermediate Code Generator, S. Code Optimizer. Set Y: 1. Abstract Syntax Tree, 2. Token, 3. Parse Tree, 4. Constant Folding. Which one of the following options is the CORRECT match from Set X to Set Y?

  1. P – 4; Q – 1; R – 3; S – 2
  2. P – 2; Q – 3; R – 1; S – 4
  3. P – 2; Q – 1; R – 3; S – 4
  4. P – 4; Q – 3; R – 2; S – 1

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) P – 2; Q – 3; R – 1; S – 4

Explanation

Lexer produces tokens, syntax analyzer builds the parse tree, intermediate code generation works from the abstract syntax tree, and the optimizer performs constant folding.