SlideShare uma empresa Scribd logo
1 de 34
Submitted By
Ujjwal matoliya
Atal Bihari Vajpayee Vishwavidyalaya
Department of Computer Science and Information
Session 2022-23
(SDT)Syntax Directed Translation
INDEX
Semantic Analizer
Application of Syntax Directed Translation
How to Evaluate a SDT
Differences between Synthesized and Inherited
Attributes
S-attributed SDT
L-attributed SDT
Compiler Phases
Semantic Analizer
INPUT
OUTPUT
Syntax directed translation
In syntax directed translation, along with the
grammar we associate some informal
notations and these notations are called as
semantic rules.
So we can say that
Grammar + semantic rule = SDT (syntax directed translati
on)
Application of Syntax Directed Translation
We use SDT(Syntax Directed Translation) for
Executing Arithmetic Expressions
Conversion from infix to postfix expression
Conversion from infix to prefix expression
For Binary to decimal conversion
Counting the number of Reductions
Creating a Syntax tree
Generating intermediate code
Storing information into the symbol table
Type checking
Production Semantic Rules
E → E # T / T E.val := E.val * T.val
T → T & F / F T.val := T.val + F.val
F →id F.val := id.l.val
How to Evaluate a SDT
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->db {printf (5)}
C->c {printf (6)}
(SDT)Syntax Directed Translation
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->db {printf (5)}
C->c {printf (6)}
(SDT)Syntax Directed Translation
INPUT STRING = aadbc
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->db {printf (5)}
C->c {printf (6)}
(SDT)Syntax Directed Translation
INPUT STRING = aadbc
OUTPUT STRING= ?
S S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
A B 2
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
A B 2
d B 5
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
A B 2
d B 5
b C 4
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
A B 2
d B 5
b C 4
C 6
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
A B 2
d B 5
b C 4
C 6
Top Down
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
S
A S 1
A B 2
d B 5
b C 4
C 6
Top Down
Bottom Up
S
A S 1
A B 2
d B 5
b C 4
C 6
Top Down
S
A S 1
A B 2
d B 5
b C 4
C 6
Top Down
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
A 3
A 3
S
A S 1
A B 2
d B 5
b C 4
C 6
Top Down
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
A 3
A 3
S
A S 1
A B 2
d B 5
b C 4
C 6
Bottom Up
S->AS {printf (1)}
S->AB {printf (2)}
A->a {printf (3)}
B->bc {printf (4)}
B->dB {printf (5)}
C->c {printf (6)}
A 3
A 3
Synthesized
Inherited
Synthesized
S-attributed SDT :
If an SDT uses only synthesized attributes, it is called as S-attributed
SDT.
S-attributed SDTs are evaluated in bottom-up parsing, as the values
of the parent nodes depend upon the values of the child nodes.
Semantic actions are placed in rightmost place of RHS.
L-attributed SDT:
If an SDT uses both synthesized attributes and inherited attributes
with a restriction that inherited attribute can inherit values from left
siblings only, it is called as L-attributed SDT.
Attributes in L-attributed SDTs are evaluated by depth-first and left-
to-right parsing manner.
Semantic actions are placed anywhere in RHS.
Example : S->ABC, Here attribute B can only obtain its value either
from the parent – S or its left sibling A but It can’t inherit from its
right sibling C. Same goes for A & C – A can only get its value from
its parent & C can get its value from S, A, & B as well because C is
the rightmost attribute in the given production.
Differences between Synthesized
and Inherited Attributes
S.NO Synthesized Attributes Inherited Attributes
1.
An attribute is said to be Synthesized attribute if its
parse tree node value is determined by the attribute
value at child nodes.
An attribute is said to be Inherited
attribute if its parse tree node value is
determined by the attribute value at
parent and/or siblings node.
2. The production must have non-terminal as its head.
The production must have non-
terminal as a symbol in its body.
3.
A synthesized attribute at node n is defined only in
terms of attribute values at the children of n itself.
A Inherited attribute at node n is
defined only in terms of attribute
values of n’s parent, n itself, and n’s
siblings.
4.
It can be evaluated during a single bottom-up
traversal of parse tree.
It can be evaluated during a single
top-down and sideways traversal of
parse tree.
5.
Synthesized attributes can be contained by both the
terminals or non-terminals.
Inherited attributes can’t be
contained by both, It is only
contained by non-terminals.
6.
Synthesized attribute is used by both S-attributed
SDT and L-attributed SDT.
Inherited attribute is used by only L-
attributed SDT.
compiler design ujjwal matoliya 2nd sem MCA.pptx

Mais conteúdo relacionado

Semelhante a compiler design ujjwal matoliya 2nd sem MCA.pptx

Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusemailharmeet
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptChapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptFamiDan
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applicationsShivanandManjaragi2
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.pptvenkatapranaykumarGa
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Iffat Anjum
 
Chapter 5 - Syntax Directed Translation.ppt
Chapter 5 - Syntax Directed Translation.pptChapter 5 - Syntax Directed Translation.ppt
Chapter 5 - Syntax Directed Translation.pptMulugetaGebino
 
Chapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptChapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptJigarThummar1
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures Pradipta Mishra
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structuresPradipta Mishra
 
Chapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptChapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptSatyamVerma61
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftChris Bailey
 
Attribute grammer
Attribute grammerAttribute grammer
Attribute grammerahmed51236
 
InterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and WhenInterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and WhenChris Bailey
 

Semelhante a compiler design ujjwal matoliya 2nd sem MCA.pptx (20)

Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
 
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.pptChapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.ppt
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
C Programming
C ProgrammingC Programming
C Programming
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applications
 
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
 
Haskell Jumpstart
Haskell JumpstartHaskell Jumpstart
Haskell Jumpstart
 
18560 lecture6
18560 lecture618560 lecture6
18560 lecture6
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
 
Chapter 5 - Syntax Directed Translation.ppt
Chapter 5 - Syntax Directed Translation.pptChapter 5 - Syntax Directed Translation.ppt
Chapter 5 - Syntax Directed Translation.ppt
 
Chapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptChapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.ppt
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
Chapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptChapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.ppt
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and Swift
 
Attribute grammer
Attribute grammerAttribute grammer
Attribute grammer
 
Parsing
ParsingParsing
Parsing
 
InterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and WhenInterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and When
 
07.05 division
07.05 division07.05 division
07.05 division
 
Compiler Design Material 2
Compiler Design Material 2Compiler Design Material 2
Compiler Design Material 2
 

Mais de ujjwalmatoliya

kisan bill ujjwal matoliya.pptx
kisan bill ujjwal matoliya.pptxkisan bill ujjwal matoliya.pptx
kisan bill ujjwal matoliya.pptxujjwalmatoliya
 
Data Frames and Scatterplots in R language ujjwal matoliya.pptx
Data Frames and Scatterplots in R language ujjwal matoliya.pptxData Frames and Scatterplots in R language ujjwal matoliya.pptx
Data Frames and Scatterplots in R language ujjwal matoliya.pptxujjwalmatoliya
 
Floyd’s and Warshal’s Algorithm ujjwal matoliya.pptx
Floyd’s and Warshal’s Algorithm ujjwal matoliya.pptxFloyd’s and Warshal’s Algorithm ujjwal matoliya.pptx
Floyd’s and Warshal’s Algorithm ujjwal matoliya.pptxujjwalmatoliya
 
congestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxcongestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxujjwalmatoliya
 
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptxGlobal Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptxujjwalmatoliya
 
Instruction format UJJWAL MATOLIYA.pptx
Instruction format UJJWAL MATOLIYA.pptxInstruction format UJJWAL MATOLIYA.pptx
Instruction format UJJWAL MATOLIYA.pptxujjwalmatoliya
 
javascript function ujjwal matoliya.pptx
javascript function ujjwal matoliya.pptxjavascript function ujjwal matoliya.pptx
javascript function ujjwal matoliya.pptxujjwalmatoliya
 
string functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptxstring functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptxujjwalmatoliya
 
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptxujjwalmatoliya
 
3 address code ujjwal matoliya.pptx
3 address code ujjwal matoliya.pptx3 address code ujjwal matoliya.pptx
3 address code ujjwal matoliya.pptxujjwalmatoliya
 
2-3 tree ujjwal matoliya .pptx
2-3 tree ujjwal matoliya .pptx2-3 tree ujjwal matoliya .pptx
2-3 tree ujjwal matoliya .pptxujjwalmatoliya
 
Graph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxGraph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxujjwalmatoliya
 
Quick Sort in data structure.pptx
Quick Sort in data structure.pptxQuick Sort in data structure.pptx
Quick Sort in data structure.pptxujjwalmatoliya
 
Hadoop With R language.pptx
Hadoop With R language.pptxHadoop With R language.pptx
Hadoop With R language.pptxujjwalmatoliya
 
cyclomatic complecity.pptx
cyclomatic complecity.pptxcyclomatic complecity.pptx
cyclomatic complecity.pptxujjwalmatoliya
 
Congestion control algorithms.pptx
Congestion control algorithms.pptxCongestion control algorithms.pptx
Congestion control algorithms.pptxujjwalmatoliya
 
Game playing With AI.pptx
Game playing With AI.pptxGame playing With AI.pptx
Game playing With AI.pptxujjwalmatoliya
 

Mais de ujjwalmatoliya (20)

kisan bill ujjwal matoliya.pptx
kisan bill ujjwal matoliya.pptxkisan bill ujjwal matoliya.pptx
kisan bill ujjwal matoliya.pptx
 
Data Frames and Scatterplots in R language ujjwal matoliya.pptx
Data Frames and Scatterplots in R language ujjwal matoliya.pptxData Frames and Scatterplots in R language ujjwal matoliya.pptx
Data Frames and Scatterplots in R language ujjwal matoliya.pptx
 
Floyd’s and Warshal’s Algorithm ujjwal matoliya.pptx
Floyd’s and Warshal’s Algorithm ujjwal matoliya.pptxFloyd’s and Warshal’s Algorithm ujjwal matoliya.pptx
Floyd’s and Warshal’s Algorithm ujjwal matoliya.pptx
 
congestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxcongestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptx
 
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptxGlobal Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
 
Instruction format UJJWAL MATOLIYA.pptx
Instruction format UJJWAL MATOLIYA.pptxInstruction format UJJWAL MATOLIYA.pptx
Instruction format UJJWAL MATOLIYA.pptx
 
javascript function ujjwal matoliya.pptx
javascript function ujjwal matoliya.pptxjavascript function ujjwal matoliya.pptx
javascript function ujjwal matoliya.pptx
 
string functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptxstring functions in SQL ujjwal matoliya.pptx
string functions in SQL ujjwal matoliya.pptx
 
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
 
3 address code ujjwal matoliya.pptx
3 address code ujjwal matoliya.pptx3 address code ujjwal matoliya.pptx
3 address code ujjwal matoliya.pptx
 
2-3 tree ujjwal matoliya .pptx
2-3 tree ujjwal matoliya .pptx2-3 tree ujjwal matoliya .pptx
2-3 tree ujjwal matoliya .pptx
 
Graph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxGraph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptx
 
Quick Sort in data structure.pptx
Quick Sort in data structure.pptxQuick Sort in data structure.pptx
Quick Sort in data structure.pptx
 
Hadoop With R language.pptx
Hadoop With R language.pptxHadoop With R language.pptx
Hadoop With R language.pptx
 
LOGIC FAMILY.pptx
LOGIC FAMILY.pptxLOGIC FAMILY.pptx
LOGIC FAMILY.pptx
 
Transaction.pptx
Transaction.pptxTransaction.pptx
Transaction.pptx
 
cyclomatic complecity.pptx
cyclomatic complecity.pptxcyclomatic complecity.pptx
cyclomatic complecity.pptx
 
Congestion control algorithms.pptx
Congestion control algorithms.pptxCongestion control algorithms.pptx
Congestion control algorithms.pptx
 
computer graphic.pptx
computer graphic.pptxcomputer graphic.pptx
computer graphic.pptx
 
Game playing With AI.pptx
Game playing With AI.pptxGame playing With AI.pptx
Game playing With AI.pptx
 

Último

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 

Último (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 

compiler design ujjwal matoliya 2nd sem MCA.pptx

  • 1. Submitted By Ujjwal matoliya Atal Bihari Vajpayee Vishwavidyalaya Department of Computer Science and Information Session 2022-23 (SDT)Syntax Directed Translation
  • 2. INDEX Semantic Analizer Application of Syntax Directed Translation How to Evaluate a SDT Differences between Synthesized and Inherited Attributes S-attributed SDT L-attributed SDT
  • 4.
  • 7. Syntax directed translation In syntax directed translation, along with the grammar we associate some informal notations and these notations are called as semantic rules. So we can say that Grammar + semantic rule = SDT (syntax directed translati on)
  • 8. Application of Syntax Directed Translation We use SDT(Syntax Directed Translation) for Executing Arithmetic Expressions Conversion from infix to postfix expression Conversion from infix to prefix expression For Binary to decimal conversion Counting the number of Reductions Creating a Syntax tree Generating intermediate code Storing information into the symbol table Type checking
  • 9. Production Semantic Rules E → E # T / T E.val := E.val * T.val T → T & F / F T.val := T.val + F.val F →id F.val := id.l.val
  • 11. S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->db {printf (5)} C->c {printf (6)} (SDT)Syntax Directed Translation
  • 12. S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->db {printf (5)} C->c {printf (6)} (SDT)Syntax Directed Translation INPUT STRING = aadbc
  • 13. S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->db {printf (5)} C->c {printf (6)} (SDT)Syntax Directed Translation INPUT STRING = aadbc OUTPUT STRING= ?
  • 14. S S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 15. S A S 1 S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 16. S A S 1 A B 2 S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 17. S A S 1 A B 2 d B 5 S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 18. S A S 1 A B 2 d B 5 b C 4 S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 19. S A S 1 A B 2 d B 5 b C 4 C 6 S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 20. S A S 1 A B 2 d B 5 b C 4 C 6 Top Down S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)}
  • 21. S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)} S A S 1 A B 2 d B 5 b C 4 C 6 Top Down Bottom Up
  • 22. S A S 1 A B 2 d B 5 b C 4 C 6 Top Down
  • 23. S A S 1 A B 2 d B 5 b C 4 C 6 Top Down S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)} A 3 A 3
  • 24. S A S 1 A B 2 d B 5 b C 4 C 6 Top Down S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)} A 3 A 3
  • 25. S A S 1 A B 2 d B 5 b C 4 C 6 Bottom Up S->AS {printf (1)} S->AB {printf (2)} A->a {printf (3)} B->bc {printf (4)} B->dB {printf (5)} C->c {printf (6)} A 3 A 3
  • 27.
  • 28.
  • 29.
  • 31. S-attributed SDT : If an SDT uses only synthesized attributes, it is called as S-attributed SDT. S-attributed SDTs are evaluated in bottom-up parsing, as the values of the parent nodes depend upon the values of the child nodes. Semantic actions are placed in rightmost place of RHS. L-attributed SDT: If an SDT uses both synthesized attributes and inherited attributes with a restriction that inherited attribute can inherit values from left siblings only, it is called as L-attributed SDT. Attributes in L-attributed SDTs are evaluated by depth-first and left- to-right parsing manner. Semantic actions are placed anywhere in RHS. Example : S->ABC, Here attribute B can only obtain its value either from the parent – S or its left sibling A but It can’t inherit from its right sibling C. Same goes for A & C – A can only get its value from its parent & C can get its value from S, A, & B as well because C is the rightmost attribute in the given production.
  • 32. Differences between Synthesized and Inherited Attributes
  • 33. S.NO Synthesized Attributes Inherited Attributes 1. An attribute is said to be Synthesized attribute if its parse tree node value is determined by the attribute value at child nodes. An attribute is said to be Inherited attribute if its parse tree node value is determined by the attribute value at parent and/or siblings node. 2. The production must have non-terminal as its head. The production must have non- terminal as a symbol in its body. 3. A synthesized attribute at node n is defined only in terms of attribute values at the children of n itself. A Inherited attribute at node n is defined only in terms of attribute values of n’s parent, n itself, and n’s siblings. 4. It can be evaluated during a single bottom-up traversal of parse tree. It can be evaluated during a single top-down and sideways traversal of parse tree. 5. Synthesized attributes can be contained by both the terminals or non-terminals. Inherited attributes can’t be contained by both, It is only contained by non-terminals. 6. Synthesized attribute is used by both S-attributed SDT and L-attributed SDT. Inherited attribute is used by only L- attributed SDT.