SlideShare a Scribd company logo
2
Most read
3
Most read
14
Most read
Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423 603
(An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune)
NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Computer Engineering
(NBA Accredited)
Dr. S. N. Gunjal
Assistant Professor
E-mail : gunjasanjay@sanjivani.org.in
Contact No: 91301 91301 Ext :145, 9503916876
Course- System Software
(CO312)
Unit-III Syntax Directed Definitions
Dr. S.N Gunjal
 “Dependency graphs” are a useful tool for determining an evaluation order for the attribute
instances in a given parse tree.
 While an annotated parse tree shows the values of attributes, a dependency graph helps us
determine how those values can be computed.
 We define two important classes of SDD’s: the “S-attributed” and the more general “L-attributed”
SDDs

Evaluation Orders for SDD’s
 A dependency graph indicate the flow of information among the instances of attributes in a
given parse tree.
 An edge from one attribute instance to another means that the value of the first is needed to
compute the second.
 Edges express constraints implied by the semantic rules.
Dependency Graphs
 For each parse-tree node, say a node labeled by grammar symbol X, the dependency graph has a
node for each attribute associated with X.
Evaluation Orders for SDD’s
 Suppose that a semantic rule associated with a production p defines the value of synthesized
attribute A.b in terms of the value of X.c (the rule may define A.b in terms of other attributes in
addition to X.c) . Then, the dependency graph has an edge from X.c to A.b.
 Suppose that a semantic rule associated with a production p defines the value of inherited
attribute B.i in terms of the value of X.a. Then, the dependency graph has an edge from X.a to
B.i.
Example 5.1 Synthesize E.val from E1.val and E2.val.
Solution. Consider the following production and rule:
Production Rule :
 E → E1 + T
Semantic Rule :
 E.val = E1.val + T.val
 As a convention, we shall show the parse tree edges as dotted lines, while the edges of the
dependency graph are solid.
Evaluation Orders for SDD’s Dependency graphs
 Example 5.2 Construct a Dependency graph for the annotated parse tree of Fig. 5.3, whose
 SDD is given in Table 5.1.
Evaluation Orders for SDD’s Dependency graphs
Evaluation Orders for SDD’s Dependency graphs
15/06/20 DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
• The dependency graph characterizes the possible orders in which we can evaluate the attributes at the
various nodes of a parse tree.
• If the dependency graph has an edge from node M to node N, then the attribute corresponding to M must
be evaluated before the attribute of N.
• Thus, the only allowable orders of evaluation are those sequences of nodes N1, N2,. . . , Nk such that if
there is an edge of the dependency graph from Ni to Nj; then i < j. Such an ordering embeds a directed
graph into a linear order, and is called a topological sort of the graph.
Ordering the Evaluation of Attributes
Ordering the Evaluation of Attributes
15/06/20 DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon
• If there is any cycle in the graph, then there are no topological sorts; that is there is no way to evaluate
the SDD on this parse tree.
• If there are no cycles, however, then there is always at least one topological sort. To see why, since there
are no cycles, we can surely find a node with no edge entering.
• For if there were no such node, we could proceed from predecessor to predecessor until we came back to
some node we had already seen, yielding a cycle. Make this node the first in the topological order,
remove it from the dependency graph, and repeat the process on the remaining nodes.
 An SDD is S-attributed if every attribute is synthesized.
Example 5.5: The SDD of Table. 5.2 is an example of an S-attributed definition. Each
attribute, L.val, E.va1, T.val, and F.val is synthesized.
S-Attributed Definitions
 The second class of SDD’s is called L-attributed definitions.
 For these definitions, edges of dependency graph, corresponding to the attributes associated with
production body, can go from left to right but not from right to left in production symbols. More
precisely, each attribute must be either
 1. Synthesized, or
 2. Inherited, but with the rules limited as follows. Suppose that there is a production
 A → X1,X2...Xn, and that there is an inherited attribute Xi.a computed by a rule
associated with this production. Then the rule may use only:
L-Attributed Definitions
(a) Inherited attributes associated with the head A.
(b) Either inherited or synthesized attributes associated with the occurrences of symbols X1, X2, ... ,
Xi−1 occurring to the left of Xi.
(c) Inherited or synthesized attributes associated with this occurrence of Xi itself, but only in such a
way that there are no cycles in a dependency graph formed by the attributes of this Xi.
L-Attributed Definitions
L-Attributed Definitions
References
1. Compilers : Principles, Techniques, & Tools 2nd Edition" by Alfred V Aho and
Ravi Sethi

More Related Content

Similar to Evaluation Orders for SDD’s Dependency graphs (20)

PPT
Chapter_5_Syntax_Directed_Translation.ppt
JigarThummar1
 
PDF
Compiler Design UNIT III PPT (SDD, SDT).pdf
Shiva350357
 
PPTX
Lecture 11 semantic analysis 2
Iffat Anjum
 
PDF
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
 
PDF
Syntax directed translation
Akshaya Arunan
 
PPTX
SyntaxDirectedTranslation in Compiler Design
Ratnakar Mikkili
 
PPTX
Chapter -4.pptx
woldu2
 
PPTX
Compiler Design_Syntax Directed Translation.pptx
RushaliDeshmukh2
 
PPT
syntax-directed-translation.ppt syntax-directed-translation.ppt
dejusertse
 
PPTX
L attribute in compiler design
khush_boo31
 
PDF
COMPILER DESIGN- Syntax Directed Translation
Jyothishmathi Institute of Technology and Science Karimnagar
 
PDF
Syntax Directed Translation PPTs for Third Year CSE
DrRajurkarArchanaMil
 
PPTX
Syntax Directed Definition and Translation
ProfMonikaShah
 
PPTX
Attribute grammer
ahmed51236
 
PDF
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
RishikeshPathak10
 
PPT
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
venkatapranaykumarGa
 
PPT
Chapter 5 -Syntax Directed Translation - Copy.ppt
FamiDan
 
PDF
CSE-303 Chapter-05 compiler bison flex syntax
Arik98
 
Chapter_5_Syntax_Directed_Translation.ppt
JigarThummar1
 
Compiler Design UNIT III PPT (SDD, SDT).pdf
Shiva350357
 
Lecture 11 semantic analysis 2
Iffat Anjum
 
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
 
Syntax directed translation
Akshaya Arunan
 
SyntaxDirectedTranslation in Compiler Design
Ratnakar Mikkili
 
Chapter -4.pptx
woldu2
 
Compiler Design_Syntax Directed Translation.pptx
RushaliDeshmukh2
 
syntax-directed-translation.ppt syntax-directed-translation.ppt
dejusertse
 
L attribute in compiler design
khush_boo31
 
COMPILER DESIGN- Syntax Directed Translation
Jyothishmathi Institute of Technology and Science Karimnagar
 
Syntax Directed Translation PPTs for Third Year CSE
DrRajurkarArchanaMil
 
Syntax Directed Definition and Translation
ProfMonikaShah
 
Attribute grammer
ahmed51236
 
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
RishikeshPathak10
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
venkatapranaykumarGa
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
FamiDan
 
CSE-303 Chapter-05 compiler bison flex syntax
Arik98
 

Recently uploaded (20)

PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
Ad

Evaluation Orders for SDD’s Dependency graphs

  • 1. Sanjivani Rural Education Society’s Sanjivani College of Engineering, Kopargaon-423 603 (An Autonomous Institute, Affiliated to Savitribai Phule Pune University, Pune) NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Computer Engineering (NBA Accredited) Dr. S. N. Gunjal Assistant Professor E-mail : [email protected] Contact No: 91301 91301 Ext :145, 9503916876 Course- System Software (CO312) Unit-III Syntax Directed Definitions Dr. S.N Gunjal
  • 2.  “Dependency graphs” are a useful tool for determining an evaluation order for the attribute instances in a given parse tree.  While an annotated parse tree shows the values of attributes, a dependency graph helps us determine how those values can be computed.  We define two important classes of SDD’s: the “S-attributed” and the more general “L-attributed” SDDs  Evaluation Orders for SDD’s
  • 3.  A dependency graph indicate the flow of information among the instances of attributes in a given parse tree.  An edge from one attribute instance to another means that the value of the first is needed to compute the second.  Edges express constraints implied by the semantic rules. Dependency Graphs
  • 4.  For each parse-tree node, say a node labeled by grammar symbol X, the dependency graph has a node for each attribute associated with X. Evaluation Orders for SDD’s
  • 5.  Suppose that a semantic rule associated with a production p defines the value of synthesized attribute A.b in terms of the value of X.c (the rule may define A.b in terms of other attributes in addition to X.c) . Then, the dependency graph has an edge from X.c to A.b.  Suppose that a semantic rule associated with a production p defines the value of inherited attribute B.i in terms of the value of X.a. Then, the dependency graph has an edge from X.a to B.i.
  • 6. Example 5.1 Synthesize E.val from E1.val and E2.val. Solution. Consider the following production and rule: Production Rule :  E → E1 + T Semantic Rule :  E.val = E1.val + T.val  As a convention, we shall show the parse tree edges as dotted lines, while the edges of the dependency graph are solid.
  • 8.  Example 5.2 Construct a Dependency graph for the annotated parse tree of Fig. 5.3, whose  SDD is given in Table 5.1.
  • 11. 15/06/20 DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon • The dependency graph characterizes the possible orders in which we can evaluate the attributes at the various nodes of a parse tree. • If the dependency graph has an edge from node M to node N, then the attribute corresponding to M must be evaluated before the attribute of N. • Thus, the only allowable orders of evaluation are those sequences of nodes N1, N2,. . . , Nk such that if there is an edge of the dependency graph from Ni to Nj; then i < j. Such an ordering embeds a directed graph into a linear order, and is called a topological sort of the graph. Ordering the Evaluation of Attributes Ordering the Evaluation of Attributes
  • 12. 15/06/20 DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon • If there is any cycle in the graph, then there are no topological sorts; that is there is no way to evaluate the SDD on this parse tree. • If there are no cycles, however, then there is always at least one topological sort. To see why, since there are no cycles, we can surely find a node with no edge entering. • For if there were no such node, we could proceed from predecessor to predecessor until we came back to some node we had already seen, yielding a cycle. Make this node the first in the topological order, remove it from the dependency graph, and repeat the process on the remaining nodes.
  • 13.  An SDD is S-attributed if every attribute is synthesized. Example 5.5: The SDD of Table. 5.2 is an example of an S-attributed definition. Each attribute, L.val, E.va1, T.val, and F.val is synthesized. S-Attributed Definitions
  • 14.  The second class of SDD’s is called L-attributed definitions.  For these definitions, edges of dependency graph, corresponding to the attributes associated with production body, can go from left to right but not from right to left in production symbols. More precisely, each attribute must be either  1. Synthesized, or  2. Inherited, but with the rules limited as follows. Suppose that there is a production  A → X1,X2...Xn, and that there is an inherited attribute Xi.a computed by a rule associated with this production. Then the rule may use only: L-Attributed Definitions
  • 15. (a) Inherited attributes associated with the head A. (b) Either inherited or synthesized attributes associated with the occurrences of symbols X1, X2, ... , Xi−1 occurring to the left of Xi. (c) Inherited or synthesized attributes associated with this occurrence of Xi itself, but only in such a way that there are no cycles in a dependency graph formed by the attributes of this Xi. L-Attributed Definitions
  • 17. References 1. Compilers : Principles, Techniques, & Tools 2nd Edition" by Alfred V Aho and Ravi Sethi