Question

Consider the following two sets:

Set XSet Y
P. Lexical Analyzer1. Abstract Syntax Tree
Q. Syntax Analyzer2. Token
R. Intermediate Code Generator3. Parse Tree
S. Code Optimizer4. Constant Folding

Which one of the following options is the CORRECT match from Set X to Set Y ?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2024 answer key

Solution

Match each compiler phase with its characteristic output or technique.

  • P. Lexical Analyzer scans the source character stream and produces 2. Token.
  • Q. Syntax Analyzer parses the token stream according to the grammar to build a 3. Parse Tree.
  • R. Intermediate Code Generator uses/constructs an 1. Abstract Syntax Tree (or three-address code).
  • S. Code Optimizer applies transformations such as 4. Constant Folding.

Thus the correct match is P - 2; Q - 3; R - 1; S - 4.

Final answer

Option (B)

Common trap

Swapping Parse Tree (Syntax Analyzer) and Abstract Syntax Tree (Intermediate Code Generator) in Option (C).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
Question
21 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.