Question
Given the following syntax directed translation rules:
Rule 1:
Rule 2:
Rule 3:
Which ONE is the CORRECT option among the following?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2025 answer key
Solution
Check each rule against the definitions of S-attributed (only synthesized attributes) and L-attributed (inherited attributes depend only on parent or left siblings).
- Rule 1: Computes attributes of RHS symbols and (so it is not S-attributed), and depends on , which is to the right of in (so it is not L-attributed).
- Rule 2: Computes , which is an inherited attribute of RHS symbol (so it is not S-attributed). Since depends only on its left sibling , and is a synthesized attribute of the LHS symbol , Rule 2 is L-attributed.
- Rule 3: Computes only the synthesized attribute of the LHS symbol from the attributes of its children and . Hence Rule 3 is both S-attributed and L-attributed.
Final answer
Option (C)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 22 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.