際際滷

際際滷Share a Scribd company logo
UNIT-III
Intermediate Code Generation: Syntax Directed Definitions,
Evaluation Orders for Syntax Directed Definitions-Intermediate
Languages: Syntax Tree, Three Address Code, Types and Declarations-
Translation of Expressions, Type Checking
Syntax-Directed Definition
 Inherited and Synthesized Attributes
 Evaluating an SDD at the nodes of a parse tree
Semantic Analysis
 The third phase of the compiler called semantic analysis.
 The main goal of the semantic analysis is to check the correctness of program and
enable proper execution
 The job of the parser is only to verify that the input program consists of tokens
arranged on syntactically valid combination
 In semantic analysis we check whether they form a sensible set of instructions in
the programming language
Semantic Analysis
Definition:
 Semantic Analysis is the third phase of the compiler which acts as
an interface between syntax analysis phase and code generation
phase
 It accepts the parse tree from the syntax analysis phase and adds the
semantic information to the parse tree and performs certain checks
based on this information
 It also helps constructing the symbol table with appropriate
information
Semantic Analysis
 The semantics of a language can be described very easily using two
notations namely:
 Syntax Directed Definition (SDD)
 Syntax Directed Translation (SDT)
Note: Consider the production E  E+T . To distinguish E on LHS of
the production and E on RHS of the production, we use E1 on RHS of
the production as shown below:
E  E1 + T
Syntax Directed Definition (SDD)
Definition:
 A Syntax Directed Definition (SDD) is a context free grammar
with attributes and semantic rules.
 The attributes are associated with grammar symbols whereas the
semantic rules are associated with productions.
 The semantic rules are used to compute the attribute values.
Example
A Simple Syntax Directed Definition ( SDD) for the production E  E1 + T can be written as shown below:
Types of attributes
 There are two types of attributes:
Synthesized Attributes
Inherited Attributes
Synthesized Attributes  These are those attributes which derive their
values from their children nodes i.e. value of synthesized attribute at node is
computed from the values of attributes at children nodes in parse tree.
Example: Let us assume an input string 4 * 5 + 6 for computing synthesized
attributes. The annotated parse tree for the input string is
Contd..
2. Inherited Attributes  These are the attributes which derive
their values from their parent or sibling nodes i.e. value of
inherited attributes are computed by value of parent or sibling
nodes.
Example: Let us assume an input string int a, c for computing inherited
attributes. The annotated parse tree for the input string is
Ad

Recommended

SyntaxDirectedTranslation in Compiler Design
SyntaxDirectedTranslation in Compiler Design
Ratnakar Mikkili
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
RMM CD LECTURE NOTES UNIT-3 ALL.pdf
RishikeshPathak10
Compiler design selective dissemination of information syntax direct translat...
Compiler design selective dissemination of information syntax direct translat...
ganeshjaggineni1927
Compiler Design UNIT III PPT (SDD, SDT).pdf
Compiler Design UNIT III PPT (SDD, SDT).pdf
Shiva350357
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.pptx
ZarfaMasood
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
Syntax Directed Definitions Synthesized Attributes and Inherited Attributes
GunjalSanjay
Chapter -4.pptx
Chapter -4.pptx
woldu2
Module 3 - Semantic Analysis(Compiler Design).pptx
Module 3 - Semantic Analysis(Compiler Design).pptx
muralidharanm2022
Semantics analysis
Semantics analysis
Bilalzafar22
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.ppt
FamiDan
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translation
Ajith kumar M P
Principles of Compiler Design and Implementation
Principles of Compiler Design and Implementation
faizr1254
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
Compiler Design_Syntax Directed Translation.pptx
Compiler Design_Syntax Directed Translation.pptx
RushaliDeshmukh2
Syntax directed translation
Syntax directed translation
Akshaya Arunan
Chapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptx
ArebuMaruf
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
Syntax Directed Definition and its applications
Syntax Directed Definition and its applications
ShivanandManjaragi2
Syntax Directed Definition and Translation
Syntax Directed Definition and Translation
ProfMonikaShah
Syntax_Directed_Definition_Professional.pptx
Syntax_Directed_Definition_Professional.pptx
sajiaph
lect-05.pdf
lect-05.pdf
KamranAli649587
chp2sds.pdfgh
chp2sds.pdfgh
KamranAli649587
Chapte - Syntax Directed Translation.ppt
Chapte - Syntax Directed Translation.ppt
PraveenaFppt
COMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed Translation
Jyothishmathi Institute of Technology and Science Karimnagar
Chapter 5 Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
12-Syntax Directed Definition Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition Evaluation Order-09-06-2023.ppt
venkatapranaykumarGa
syntax-directed-translation.ppt syntax-directed-translation.ppt
syntax-directed-translation.ppt syntax-directed-translation.ppt
dejusertse
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
Satluj House Semi Final Quiz Quencher 2025.pptx
Satluj House Semi Final Quiz Quencher 2025.pptx
148CDivyamDubey

More Related Content

Similar to unit 3 modules intermediate code generation (20)

Module 3 - Semantic Analysis(Compiler Design).pptx
Module 3 - Semantic Analysis(Compiler Design).pptx
muralidharanm2022
Semantics analysis
Semantics analysis
Bilalzafar22
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.ppt
FamiDan
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translation
Ajith kumar M P
Principles of Compiler Design and Implementation
Principles of Compiler Design and Implementation
faizr1254
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
Compiler Design_Syntax Directed Translation.pptx
Compiler Design_Syntax Directed Translation.pptx
RushaliDeshmukh2
Syntax directed translation
Syntax directed translation
Akshaya Arunan
Chapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptx
ArebuMaruf
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
Syntax Directed Definition and its applications
Syntax Directed Definition and its applications
ShivanandManjaragi2
Syntax Directed Definition and Translation
Syntax Directed Definition and Translation
ProfMonikaShah
Syntax_Directed_Definition_Professional.pptx
Syntax_Directed_Definition_Professional.pptx
sajiaph
lect-05.pdf
lect-05.pdf
KamranAli649587
chp2sds.pdfgh
chp2sds.pdfgh
KamranAli649587
Chapte - Syntax Directed Translation.ppt
Chapte - Syntax Directed Translation.ppt
PraveenaFppt
COMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Syntax Directed Translation
Jyothishmathi Institute of Technology and Science Karimnagar
Chapter 5 Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
12-Syntax Directed Definition Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition Evaluation Order-09-06-2023.ppt
venkatapranaykumarGa
syntax-directed-translation.ppt syntax-directed-translation.ppt
syntax-directed-translation.ppt syntax-directed-translation.ppt
dejusertse
Module 3 - Semantic Analysis(Compiler Design).pptx
Module 3 - Semantic Analysis(Compiler Design).pptx
muralidharanm2022
Semantics analysis
Semantics analysis
Bilalzafar22
Chapter 5 -Syntax Directed Translation - Copy.ppt
Chapter 5 -Syntax Directed Translation - Copy.ppt
FamiDan
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translation
Ajith kumar M P
Principles of Compiler Design and Implementation
Principles of Compiler Design and Implementation
faizr1254
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
Iffat Anjum
Compiler Design_Syntax Directed Translation.pptx
Compiler Design_Syntax Directed Translation.pptx
RushaliDeshmukh2
Syntax directed translation
Syntax directed translation
Akshaya Arunan
Chapter _4_Semantic Analysis .pptx
Chapter _4_Semantic Analysis .pptx
ArebuMaruf
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
Iffat Anjum
Syntax Directed Definition and its applications
Syntax Directed Definition and its applications
ShivanandManjaragi2
Syntax Directed Definition and Translation
Syntax Directed Definition and Translation
ProfMonikaShah
Syntax_Directed_Definition_Professional.pptx
Syntax_Directed_Definition_Professional.pptx
sajiaph
Chapte - Syntax Directed Translation.ppt
Chapte - Syntax Directed Translation.ppt
PraveenaFppt
12-Syntax Directed Definition Evaluation Order-09-06-2023.ppt
12-Syntax Directed Definition Evaluation Order-09-06-2023.ppt
venkatapranaykumarGa
syntax-directed-translation.ppt syntax-directed-translation.ppt
syntax-directed-translation.ppt syntax-directed-translation.ppt
dejusertse

Recently uploaded (20)

Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
Satluj House Semi Final Quiz Quencher 2025.pptx
Satluj House Semi Final Quiz Quencher 2025.pptx
148CDivyamDubey
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
LDMMIA Practitioner Level Orientation Updates
LDMMIA Practitioner Level Orientation Updates
LDM & Mia eStudios
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
Overview of Employee in Odoo 18 - Odoo 際際滷s
Overview of Employee in Odoo 18 - Odoo 際際滷s
Celine George
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
Health Care Planning and Organization of Health Care at Various Levels Unit...
Health Care Planning and Organization of Health Care at Various Levels Unit...
RAKESH SAJJAN
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
Satluj House Semi Final Quiz Quencher 2025.pptx
Satluj House Semi Final Quiz Quencher 2025.pptx
148CDivyamDubey
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
LDMMIA Practitioner Level Orientation Updates
LDMMIA Practitioner Level Orientation Updates
LDM & Mia eStudios
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
Overview of Employee in Odoo 18 - Odoo 際際滷s
Overview of Employee in Odoo 18 - Odoo 際際滷s
Celine George
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
Health Care Planning and Organization of Health Care at Various Levels Unit...
Health Care Planning and Organization of Health Care at Various Levels Unit...
RAKESH SAJJAN
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
Ad

unit 3 modules intermediate code generation

  • 1. UNIT-III Intermediate Code Generation: Syntax Directed Definitions, Evaluation Orders for Syntax Directed Definitions-Intermediate Languages: Syntax Tree, Three Address Code, Types and Declarations- Translation of Expressions, Type Checking
  • 2. Syntax-Directed Definition Inherited and Synthesized Attributes Evaluating an SDD at the nodes of a parse tree
  • 3. Semantic Analysis The third phase of the compiler called semantic analysis. The main goal of the semantic analysis is to check the correctness of program and enable proper execution The job of the parser is only to verify that the input program consists of tokens arranged on syntactically valid combination In semantic analysis we check whether they form a sensible set of instructions in the programming language
  • 4. Semantic Analysis Definition: Semantic Analysis is the third phase of the compiler which acts as an interface between syntax analysis phase and code generation phase It accepts the parse tree from the syntax analysis phase and adds the semantic information to the parse tree and performs certain checks based on this information It also helps constructing the symbol table with appropriate information
  • 5. Semantic Analysis The semantics of a language can be described very easily using two notations namely: Syntax Directed Definition (SDD) Syntax Directed Translation (SDT) Note: Consider the production E E+T . To distinguish E on LHS of the production and E on RHS of the production, we use E1 on RHS of the production as shown below: E E1 + T
  • 6. Syntax Directed Definition (SDD) Definition: A Syntax Directed Definition (SDD) is a context free grammar with attributes and semantic rules. The attributes are associated with grammar symbols whereas the semantic rules are associated with productions. The semantic rules are used to compute the attribute values.
  • 7. Example A Simple Syntax Directed Definition ( SDD) for the production E E1 + T can be written as shown below:
  • 8. Types of attributes There are two types of attributes: Synthesized Attributes Inherited Attributes Synthesized Attributes These are those attributes which derive their values from their children nodes i.e. value of synthesized attribute at node is computed from the values of attributes at children nodes in parse tree.
  • 9. Example: Let us assume an input string 4 * 5 + 6 for computing synthesized attributes. The annotated parse tree for the input string is
  • 10. Contd.. 2. Inherited Attributes These are the attributes which derive their values from their parent or sibling nodes i.e. value of inherited attributes are computed by value of parent or sibling nodes.
  • 11. Example: Let us assume an input string int a, c for computing inherited attributes. The annotated parse tree for the input string is