GATE CS 2025, set 2 · Question 22 · Compiler Design · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Given the following syntax directed translation rules:
Rule 1: R → AB {B.i = R.i - 1; A.i = B.i; R.i = A.i + 1;}
Rule 2: P → CD {P.i = C.i + D.i; D.i = C.i + 2;}
Rule 3: Q → EF {Q.i = E.i + F.i;}
Which ONE is the CORRECT option among the following?

  1. (A) Rule 1 is S-attributed and L-attributed; Rule 2 is S-attributed and not L-attributed; Rule 3 is neither S-attributed nor L-attributed
  2. (B) Rule 1 is neither S-attributed nor L-attributed; Rule 2 is S-attributed and L-attributed; Rule 3 is S-attributed and L-attributed
  3. (C) Rule 1 is neither S-attributed nor L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed
  4. (D) Rule 1 is S-attributed and not L-attributed; Rule 2 is not S-attributed and is L-attributed; Rule 3 is S-attributed and L-attributed
Answer

Answer (C)

Answer from the official GATE CS 2025 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes