Skip to main content

GATE CSE 2025Compiler Design › Syntax-Directed Translation & Intermediate CodeVerified

GATE CSE 2025 PYQ: ​​​​Consider the following statements about the use of backpatching in a compiler for intermediate code…

​​​​Consider the following statements about the use of backpatching in a compiler for intermediate code generation:

  1. Backpatching can be used to generate code for Boolean expression in one pass.
  2. Backpatching can be used to generate code for flow-of-control statements in one pass.
Which ONE of the folloeing options is CORRECT?
  1. A
    Only I is correct
  2. B
    Only II is correct
  3. C
    Both I and II are correct
    Correct answer
  4. D
    Neither I nor II is correct

Answer

(C) Both I and II are correct

Approach

Recall what backpatching is: a technique in one-pass intermediate code generation where jump instructions are emitted with placeholder targets, and lists of these incomplete instructions (truelist/falselist/nextlist) are patched later once the target label becomes known. Check whether this technique is applicable to (I) Boolean expressions and (II) flow-of-control statements, both within a single pass over the source.

Backpatching is defined as the one-pass technique of generating jumps with unspecified targets and filling those targets in later via truelist, falselist and nextlist. It is used for both Boolean expressions and flow-of-control statements, so both statement I and statement II hold; hence option C.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.