Given the following syntax directed translation rules:
Rule 1: R→ABR→AB [B.i=R.i−1;A.i=B.iR.i=A.i+1;B.i=R.i−1;A.i=B.iR.i=A.i+1;]
Rule 2: P→CDP→CD [P.i=C.i+D.i;D.i=C.i+2P.i=C.i+D.i;D.i=C.i+2]
Rule 3: Q→EFQ→EF [Q.i=E.i+F.i;Q.i=E.i+F.i;]
Which ONE is the CORRECT option among the following?
Solution :
The correct option is: 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.
To determine the correct classification of each Syntax-Directed Translation (SDT) rule, let us first review the definitions of S-attributed and L-attributed definitions:
1. S-attributed definition:
An SDD is S-attributed if it uses only synthesized attributes. In a syntax-directed definition, a synthesized attribute at a node is computed from the attributes of its children. In grammar terms, for a production , only the attribute of the left-hand side symbol is computed, and it depends solely on the attributes of the right-hand side symbols .
2. L-attributed definition:
An SDD is L-attributed if every attribute is either synthesized, or inherited with the restriction that the inherited attributes of a sibling symbol on the right-hand side of a production can depend only on:
- The inherited attributes of the left-hand side parent head .
- The attributes (either synthesized or inherited) of sibling symbols that lie to the left of .
Note that every S-attributed definition is also an L-attributed definition, because S-attributed definitions do not have any inherited attributes and thus trivially satisfy the constraints of L-attributed definitions.
Let us analyze each rule step-by-step:
Analysis of Rule 1:
Production:
Semantic Rules:
Looking at the action , the attribute of the symbol (which is to the left of ) depends on the attribute of the symbol (which is to the right of ). This right-to-left dependency violates the constraint of L-attributed definitions. Furthermore, since it contains inherited attributes (such as and ), it is not S-attributed. Thus, Rule 1 is neither S-attributed nor L-attributed.
Analysis of Rule 2:
Production:
Semantic Rules:
Here, the inherited attribute of (which is ) depends on (an attribute of its left sibling symbol ). This is a valid dependency for an L-attributed definition. The attribute of the head is synthesized from the right-hand side attributes. Because it contains the inherited attribute on the right-hand side, it is not S-attributed. Therefore, Rule 2 is not S-attributed but is L-attributed.
Analysis of Rule 3:
Production:
Semantic Rules:
In this rule, the attribute of the left-hand side head is computed using only the attributes of the right-hand side symbols and . There are no inherited attributes computed for any of the right-hand side symbols. This makes the rule S-attributed. Since all S-attributed definitions are a subset of L-attributed definitions, Rule 3 is both S-attributed and L-attributed.
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
Prepare for GATE 2026 Civil Engineering with the latest question papers, previous year papers, detailed solutions, syllabus, exam pattern, preparation tips, mock tests, and subject-wise study material. Download GATE 2026 CE question papers with solutions in PDF format and boost your preparation for top engineering institutes and PSU recruitment.
Prepare effectively for GATE 2026 Electronics & Communication Engineering (EC) with this comprehensive Question Paper with Solutions. This resource includes detailed explanations, concept-wise solutions, previous year paper analysis, and exam-oriented practice to help aspirants strengthen core subjects like Electronic Devices, Analog Circuits, Digital Circuits, Signals & Systems, Network Theory, Control Systems, Electromagnetics, Communications, and more. Perfect for revision, self-assessment, and boosting your GATE 2026 EC preparation strategy.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.