SlideShare a Scribd company logo
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

More Related Content

Similar to compiler design ujjwal matoliya 2nd sem MCA.pptx

Database normalization
Database normalizationDatabase normalization
Database normalization
VARSHAKUMARI49
 
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.ppt
FamiDan
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Syntax Directed Definition and its applications
Syntax Directed Definition and its applicationsSyntax Directed Definition and its applications
Syntax Directed Definition and its applications
ShivanandManjaragi2
 
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
venkatapranaykumarGa
 
Haskell Jumpstart
Haskell JumpstartHaskell Jumpstart
Haskell Jumpstart
David Vollbracht
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
 
Chapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptChapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.ppt
JigarThummar1
 
Chapter 5 - Syntax Directed Translation.ppt
Chapter 5 - Syntax Directed Translation.pptChapter 5 - Syntax Directed Translation.ppt
Chapter 5 - Syntax Directed Translation.ppt
MulugetaGebino
 
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 structures
Pradipta Mishra
 
Chapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.pptChapter_5_Syntax_Directed_Translation.ppt
Chapter_5_Syntax_Directed_Translation.ppt
SatyamVerma61
 
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
Chris Bailey
 
Attribute grammer
Attribute grammerAttribute grammer
Attribute grammer
ahmed51236
 
Parsing
ParsingParsing
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
Chris Bailey
 

Similar to compiler design ujjwal matoliya 2nd sem MCA.pptx (20)

Database normalization
Database normalizationDatabase normalization
Database normalization
 
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
 

More from ujjwalmatoliya

kisan bill ujjwal matoliya.pptx
kisan bill ujjwal matoliya.pptxkisan bill ujjwal matoliya.pptx
kisan bill ujjwal matoliya.pptx
ujjwalmatoliya
 
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
ujjwalmatoliya
 
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
ujjwalmatoliya
 
congestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptxcongestion ujjwal matoliya.pptx
congestion ujjwal matoliya.pptx
ujjwalmatoliya
 
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
ujjwalmatoliya
 
Instruction format UJJWAL MATOLIYA.pptx
Instruction format UJJWAL MATOLIYA.pptxInstruction format UJJWAL MATOLIYA.pptx
Instruction format UJJWAL MATOLIYA.pptx
ujjwalmatoliya
 
javascript function ujjwal matoliya.pptx
javascript function ujjwal matoliya.pptxjavascript function ujjwal matoliya.pptx
javascript function ujjwal matoliya.pptx
ujjwalmatoliya
 
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
ujjwalmatoliya
 
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
ujjwalmatoliya
 
3 address code ujjwal matoliya.pptx
3 address code ujjwal matoliya.pptx3 address code ujjwal matoliya.pptx
3 address code ujjwal matoliya.pptx
ujjwalmatoliya
 
2-3 tree ujjwal matoliya .pptx
2-3 tree ujjwal matoliya .pptx2-3 tree ujjwal matoliya .pptx
2-3 tree ujjwal matoliya .pptx
ujjwalmatoliya
 
Graph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptxGraph in Discrete mathemaetics.pptx
Graph in Discrete mathemaetics.pptx
ujjwalmatoliya
 
Quick Sort in data structure.pptx
Quick Sort in data structure.pptxQuick Sort in data structure.pptx
Quick Sort in data structure.pptx
ujjwalmatoliya
 
Hadoop With R language.pptx
Hadoop With R language.pptxHadoop With R language.pptx
Hadoop With R language.pptx
ujjwalmatoliya
 
LOGIC FAMILY.pptx
LOGIC FAMILY.pptxLOGIC FAMILY.pptx
LOGIC FAMILY.pptx
ujjwalmatoliya
 
Transaction.pptx
Transaction.pptxTransaction.pptx
Transaction.pptx
ujjwalmatoliya
 
cyclomatic complecity.pptx
cyclomatic complecity.pptxcyclomatic complecity.pptx
cyclomatic complecity.pptx
ujjwalmatoliya
 
Congestion control algorithms.pptx
Congestion control algorithms.pptxCongestion control algorithms.pptx
Congestion control algorithms.pptx
ujjwalmatoliya
 
computer graphic.pptx
computer graphic.pptxcomputer graphic.pptx
computer graphic.pptx
ujjwalmatoliya
 
Game playing With AI.pptx
Game playing With AI.pptxGame playing With AI.pptx
Game playing With AI.pptx
ujjwalmatoliya
 

More from 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
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

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.