SlideShare a Scribd company logo
1 of 10
L- ATTRIBUTE
Name: Khushboo Jethwa
Enrollment no. : 140950107028
Subject: Compiler Design
Subject Guide: Avneet Saluja
Attribute Grammar
• Attribute grammar is a special form of context-free
grammar where some additional information
(attributes) are appended to one or more of its non-
terminals in order to provide context-sensitive
information. Each attribute has well-defined domain of
values, such as integer, float, character, string, and
expressions.
• Attribute grammar is a medium to provide semantics
to the context-free grammar and it can help specify the
syntax and semantics of a programming language.
Attribute grammar (when viewed as a parse-tree) can
pass values or information among the nodes of a tree.
EXAMPLE
E → E + T { E.value = E.value + T.value }
• The right part of the CFG contains the semantic rules
that specify how the grammar should be interpreted.
Here, the values of non-terminals E and T are added
together and the result is copied to the non-terminal E.
• Semantic attributes may be assigned to their values
from their domain at the time of parsing and evaluated
at the time of assignment or conditions. Based on the
way the attributes get their values, they can be broadly
divided into two categories : synthesized attributes and
inherited attributes.
Synthesized attributes
• These attributes get values from the attribute
values of their child nodes. To illustrate, assume
the following production:
S → ABC
• If S is taking values from its child nodes (A,B,C),
then it is said to be a synthesized attribute, as the
values of ABC are synthesized to S.
• As in our previous example (E → E + T), the
parent node E gets its value from its child node.
Synthesized attributes never take values from
their parent nodes or any sibling nodes.
Inherited attributes
• In contrast to synthesized attributes, inherited
attributes can take values from parent and/or
siblings. As in the following production,
S → ABC
• A can get values from S, B and C. B can take
values from S, A, and C. Likewise, C can take
values from S, A, and B.
L-attributed SDT
• This form of SDT uses both synthesized and inherited
attributes with restriction of not taking values from right
siblings.
• In L-attributed SDTs, a non-terminal can get values from its
parent, child, and sibling nodes. As in the following
production
S → ABC
• S can take values from A, B, and C (synthesized). A can take
values from S only. B can take values from S and A. C can
get values from S, A, and B. No non-terminal can get values
from the sibling to its right.
• Attributes in L-attributed SDTs are evaluated by depth-first
and left-to-right parsing manner.
All S-attributes are L-attribute but all S-
arrtibute may or may not be L-attribute.
EXAMPLE
State whether the following are l attribute or
not.
1) A-> QR { R.i = f(A.i), Q.i =f(R.i) }
checking one by one semantic actions.
• for R.i = f(A.i), it’s a l-attribute as it’s a
inherited attibute from the parent.
• for Q.i =f(R.i), it’s not a l-attribute as it’s
inherited from the right sibling.
2) A-> BC { B.S = A.S }
checking one by one semantic actions.
• for B.S = A.S, it’s a l-attribute as it’s a
inherited attibute from the parent.
THANK YOU

More Related Content

What's hot

Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsNikhil Sharma
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazationSiva Sathya
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designSadia Akter
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Aman Sharma
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler designRajkumar R
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.mohanrathod18
 
Timing and control
Timing and controlTiming and control
Timing and controlchauhankapil
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Notion of an algorithm
Notion of an algorithmNotion of an algorithm
Notion of an algorithmNisha Soms
 

What's hot (20)

Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Cpu organisation
Cpu organisationCpu organisation
Cpu organisation
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
Run time storage
Run time storageRun time storage
Run time storage
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Parsing
ParsingParsing
Parsing
 
Timing and control
Timing and controlTiming and control
Timing and control
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Notion of an algorithm
Notion of an algorithmNotion of an algorithm
Notion of an algorithm
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 

Similar to L attribute in compiler design

Attribute grammer
Attribute grammerAttribute grammer
Attribute grammerahmed51236
 
L14 Semantic analysis This process is crucial in various applications such a...
L14 Semantic analysis  This process is crucial in various applications such a...L14 Semantic analysis  This process is crucial in various applications such a...
L14 Semantic analysis This process is crucial in various applications such a...CodingChamp1
 
Semantic Analysis.pptx
Semantic Analysis.pptxSemantic Analysis.pptx
Semantic Analysis.pptxZarfaMasood
 
Semantics analysis
Semantics analysisSemantics analysis
Semantics analysisBilalzafar22
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applicationsShivanandManjaragi2
 
Ch6_Semantic_Analysis_ppt_fgjdkidskjfdd.ppt
Ch6_Semantic_Analysis_ppt_fgjdkidskjfdd.pptCh6_Semantic_Analysis_ppt_fgjdkidskjfdd.ppt
Ch6_Semantic_Analysis_ppt_fgjdkidskjfdd.pptFutureTechnologies3
 
19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdfGOWTHAMR721887
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).pptIshuIswarya3
 
Chapter -4.pptx
Chapter -4.pptxChapter -4.pptx
Chapter -4.pptxwoldu2
 
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translationUnit iv-syntax-directed-translation
Unit iv-syntax-directed-translationAjith kumar M P
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Iffat Anjum
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Iffat Anjum
 
Presentation of saad on e-r diagram.
Presentation of saad on e-r diagram.Presentation of saad on e-r diagram.
Presentation of saad on e-r diagram.sumit gyawali
 
Database Design and Entity relationship Model.pptx
Database Design and Entity relationship Model.pptxDatabase Design and Entity relationship Model.pptx
Database Design and Entity relationship Model.pptxyamuna67903
 

Similar to L attribute in compiler design (20)

Attribute grammer
Attribute grammerAttribute grammer
Attribute grammer
 
L14 Semantic analysis This process is crucial in various applications such a...
L14 Semantic analysis  This process is crucial in various applications such a...L14 Semantic analysis  This process is crucial in various applications such a...
L14 Semantic analysis This process is crucial in various applications such a...
 
Semantic Analysis.pptx
Semantic Analysis.pptxSemantic Analysis.pptx
Semantic Analysis.pptx
 
Semantics analysis
Semantics analysisSemantics analysis
Semantics analysis
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applications
 
Ch6_Semantic_Analysis_ppt_fgjdkidskjfdd.ppt
Ch6_Semantic_Analysis_ppt_fgjdkidskjfdd.pptCh6_Semantic_Analysis_ppt_fgjdkidskjfdd.ppt
Ch6_Semantic_Analysis_ppt_fgjdkidskjfdd.ppt
 
19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
Chapter -4.pptx
Chapter -4.pptxChapter -4.pptx
Chapter -4.pptx
 
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translationUnit iv-syntax-directed-translation
Unit iv-syntax-directed-translation
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
 
Data Models.pptx
Data Models.pptxData Models.pptx
Data Models.pptx
 
ER-Diagram.pptx
ER-Diagram.pptxER-Diagram.pptx
ER-Diagram.pptx
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
 
Presentation of saad on e-r diagram.
Presentation of saad on e-r diagram.Presentation of saad on e-r diagram.
Presentation of saad on e-r diagram.
 
Database Design and Entity relationship Model.pptx
Database Design and Entity relationship Model.pptxDatabase Design and Entity relationship Model.pptx
Database Design and Entity relationship Model.pptx
 
DBMS Class 3
DBMS Class 3DBMS Class 3
DBMS Class 3
 
10287 lecture5(2)
10287 lecture5(2)10287 lecture5(2)
10287 lecture5(2)
 
Day 1 SQL.pptx
Day 1 SQL.pptxDay 1 SQL.pptx
Day 1 SQL.pptx
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 

More from khush_boo31

Classification of data mart
Classification of data martClassification of data mart
Classification of data martkhush_boo31
 
statement interface
statement interface statement interface
statement interface khush_boo31
 
context free language
context free languagecontext free language
context free languagekhush_boo31
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#khush_boo31
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programmingkhush_boo31
 

More from khush_boo31 (6)

Classification of data mart
Classification of data martClassification of data mart
Classification of data mart
 
statement interface
statement interface statement interface
statement interface
 
context free language
context free languagecontext free language
context free language
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
Knapsack problem using dynamic programming
Knapsack problem using dynamic programmingKnapsack problem using dynamic programming
Knapsack problem using dynamic programming
 
Parsing
ParsingParsing
Parsing
 

Recently uploaded

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 

Recently uploaded (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 

L attribute in compiler design

  • 1. L- ATTRIBUTE Name: Khushboo Jethwa Enrollment no. : 140950107028 Subject: Compiler Design Subject Guide: Avneet Saluja
  • 2. Attribute Grammar • Attribute grammar is a special form of context-free grammar where some additional information (attributes) are appended to one or more of its non- terminals in order to provide context-sensitive information. Each attribute has well-defined domain of values, such as integer, float, character, string, and expressions. • Attribute grammar is a medium to provide semantics to the context-free grammar and it can help specify the syntax and semantics of a programming language. Attribute grammar (when viewed as a parse-tree) can pass values or information among the nodes of a tree.
  • 3. EXAMPLE E → E + T { E.value = E.value + T.value } • The right part of the CFG contains the semantic rules that specify how the grammar should be interpreted. Here, the values of non-terminals E and T are added together and the result is copied to the non-terminal E. • Semantic attributes may be assigned to their values from their domain at the time of parsing and evaluated at the time of assignment or conditions. Based on the way the attributes get their values, they can be broadly divided into two categories : synthesized attributes and inherited attributes.
  • 4. Synthesized attributes • These attributes get values from the attribute values of their child nodes. To illustrate, assume the following production: S → ABC • If S is taking values from its child nodes (A,B,C), then it is said to be a synthesized attribute, as the values of ABC are synthesized to S. • As in our previous example (E → E + T), the parent node E gets its value from its child node. Synthesized attributes never take values from their parent nodes or any sibling nodes.
  • 5. Inherited attributes • In contrast to synthesized attributes, inherited attributes can take values from parent and/or siblings. As in the following production, S → ABC • A can get values from S, B and C. B can take values from S, A, and C. Likewise, C can take values from S, A, and B.
  • 6. L-attributed SDT • This form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings. • In L-attributed SDTs, a non-terminal can get values from its parent, child, and sibling nodes. As in the following production S → ABC • S can take values from A, B, and C (synthesized). A can take values from S only. B can take values from S and A. C can get values from S, A, and B. No non-terminal can get values from the sibling to its right. • Attributes in L-attributed SDTs are evaluated by depth-first and left-to-right parsing manner.
  • 7. All S-attributes are L-attribute but all S- arrtibute may or may not be L-attribute.
  • 8. EXAMPLE State whether the following are l attribute or not. 1) A-> QR { R.i = f(A.i), Q.i =f(R.i) } checking one by one semantic actions. • for R.i = f(A.i), it’s a l-attribute as it’s a inherited attibute from the parent. • for Q.i =f(R.i), it’s not a l-attribute as it’s inherited from the right sibling.
  • 9. 2) A-> BC { B.S = A.S } checking one by one semantic actions. • for B.S = A.S, it’s a l-attribute as it’s a inherited attibute from the parent.