SlideShare a Scribd company logo
CSE 420
Intermediate Code Generation
Lecture 13
Conversions between primitive typesConversions between primitive types
in Javain Java
Introducing type conversions intoIntroducing type conversions into
expression evaluationexpression evaluation
Abstract syntax tree for theAbstract syntax tree for the
function definitionfunction definition
fun length(x) =
if null(x) then 0 else length(tl(x)+1)
This is a polymorphic function in ML language
Control FlowControl Flow
Boolean expressions are often used to:
• Alter the flow of control.
• Compute logical values.
Short-Circuit Code


Flow-of-Control StatementsFlow-of-Control Statements
Syntax-directed definitionSyntax-directed definition
Generating three-address code forGenerating three-address code for
booleansbooleans
translation of a simple if-statementtranslation of a simple if-statement
•
•
BackpatchingBackpatching
• Previous codes for Boolean expressions insert symbolic
labels for jumps
• It therefore needs a separate pass to set them to
appropriate addresses
• We can use a technique named backpatching to avoid
this
• We assume we save instructions into an array and labels
will be indices in the array
• For non-terminal B we use two attributes B.truelist and
B.falselist together with following functions:
▫ makelist(i): create a new list containing only I, an index into the
array of instructions
▫ Merge(p1,p2): concatenates the lists pointed by p1 and p2 and
returns a pointer to the concatenated list
▫ Backpatch(p,i): inserts i as the target label for each of the
instruction on the list pointed to by p
Backpatching for Boolean ExpressionsBackpatching for Boolean Expressions
•
•
Backpatching for Boolean ExpressionsBackpatching for Boolean Expressions
• Annotated parse tree for x < 100 || x > 200 && x ! = y
Flow-of-Control StatementsFlow-of-Control Statements
Translation of a switch-statementTranslation of a switch-statement
Any Question?

More Related Content

PPTX
Lexical analyzer
kiran acharya
 
PPT
02. chapter 3 lexical analysis
raosir123
 
PPT
Chapter Three(1)
bolovv
 
PDF
Lexical
baran19901990
 
PPTX
Lexical analysis-using-lex
Dattatray Gandhmal
 
PPTX
Lecture 02 lexical analysis
Iffat Anjum
 
PPTX
Language for specifying lexical Analyzer
Archana Gopinath
 
PDF
Lexical Analysis - Compiler design
Aman Sharma
 
Lexical analyzer
kiran acharya
 
02. chapter 3 lexical analysis
raosir123
 
Chapter Three(1)
bolovv
 
Lexical
baran19901990
 
Lexical analysis-using-lex
Dattatray Gandhmal
 
Lecture 02 lexical analysis
Iffat Anjum
 
Language for specifying lexical Analyzer
Archana Gopinath
 
Lexical Analysis - Compiler design
Aman Sharma
 

What's hot (20)

PPTX
A simple approach of lexical analyzers
Archana Gopinath
 
PDF
Syntax analysis
Akshaya Arunan
 
PDF
Compiler lec 8
Ramadan Babers, PhD
 
PPT
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
PDF
Intermediate code generation
Akshaya Arunan
 
PPTX
Intermediate code- generation
rawan_z
 
PDF
Syntax directed translation
Akshaya Arunan
 
PPTX
A Role of Lexical Analyzer
Archana Gopinath
 
PPTX
3. Lexical analysis
Saeed Parsa
 
PPTX
Lecture 11 semantic analysis 2
Iffat Anjum
 
PPTX
Compiler design and lexical analyser
abhishek gupta
 
PPTX
Lexical Analyzer Implementation
Akhil Kaushik
 
PPTX
Back patching
santhiya thavanthi
 
PPTX
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Saikrishna Tanguturu
 
PPTX
Lexical analyzer
Princess Doll
 
PDF
Lecture3 lexical analysis
Mahesh Kumar Chelimilla
 
PPTX
Intermediate code generation1
Shashwat Shriparv
 
PPT
Lex and Yacc ppt
pssraikar
 
PPT
Chapter Eight(2)
bolovv
 
PPTX
Lexical analyzer generator lex
Anusuya123
 
A simple approach of lexical analyzers
Archana Gopinath
 
Syntax analysis
Akshaya Arunan
 
Compiler lec 8
Ramadan Babers, PhD
 
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
Intermediate code generation
Akshaya Arunan
 
Intermediate code- generation
rawan_z
 
Syntax directed translation
Akshaya Arunan
 
A Role of Lexical Analyzer
Archana Gopinath
 
3. Lexical analysis
Saeed Parsa
 
Lecture 11 semantic analysis 2
Iffat Anjum
 
Compiler design and lexical analyser
abhishek gupta
 
Lexical Analyzer Implementation
Akhil Kaushik
 
Back patching
santhiya thavanthi
 
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Saikrishna Tanguturu
 
Lexical analyzer
Princess Doll
 
Lecture3 lexical analysis
Mahesh Kumar Chelimilla
 
Intermediate code generation1
Shashwat Shriparv
 
Lex and Yacc ppt
pssraikar
 
Chapter Eight(2)
bolovv
 
Lexical analyzer generator lex
Anusuya123
 
Ad

Viewers also liked (13)

PPTX
Cognitive radio network_MS_defense_presentation
Iffat Anjum
 
PPTX
Lecture 15 run timeenvironment_2
Iffat Anjum
 
PPTX
Distributed contention based mac protocol for cognitive radio
Iffat Anjum
 
PPTX
Lecture 07 08 syntax analysis-4
Iffat Anjum
 
PPT
Lecture 03 lexical analysis
Iffat Anjum
 
PPTX
Lecture 14 run time environment
Iffat Anjum
 
PPT
Lecture 06 syntax analysis 3
Iffat Anjum
 
PPTX
Lecture 12 intermediate code generation
Iffat Anjum
 
PPT
Lecture 05 syntax analysis 2
Iffat Anjum
 
PPTX
Fog computing ( foggy cloud)
Iffat Anjum
 
PPT
Lecture 16 17 code-generation
Iffat Anjum
 
PPT
Compiler Design - Introduction to Compiler
Iffat Anjum
 
PDF
Lecture 01 introduction to compiler
Iffat Anjum
 
Cognitive radio network_MS_defense_presentation
Iffat Anjum
 
Lecture 15 run timeenvironment_2
Iffat Anjum
 
Distributed contention based mac protocol for cognitive radio
Iffat Anjum
 
Lecture 07 08 syntax analysis-4
Iffat Anjum
 
Lecture 03 lexical analysis
Iffat Anjum
 
Lecture 14 run time environment
Iffat Anjum
 
Lecture 06 syntax analysis 3
Iffat Anjum
 
Lecture 12 intermediate code generation
Iffat Anjum
 
Lecture 05 syntax analysis 2
Iffat Anjum
 
Fog computing ( foggy cloud)
Iffat Anjum
 
Lecture 16 17 code-generation
Iffat Anjum
 
Compiler Design - Introduction to Compiler
Iffat Anjum
 
Lecture 01 introduction to compiler
Iffat Anjum
 
Ad

More from Iffat Anjum (15)

PPTX
Lecture 09 syntax analysis 05
Iffat Anjum
 
PPTX
Lecture 10 semantic analysis 01
Iffat Anjum
 
PPT
Lecture 04 syntax analysis
Iffat Anjum
 
PPT
On qo s provisioning in context aware wireless sensor networks for healthcare
Iffat Anjum
 
PPT
Data link control
Iffat Anjum
 
PPT
Pnp mac preemptive slot allocation and non preemptive transmission for provid...
Iffat Anjum
 
PPT
Qo s based mac protocol for medical wireless body area sensor networks
Iffat Anjum
 
PPT
A reinforcement learning based routing protocol with qo s support for biomedi...
Iffat Anjum
 
PPT
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
Iffat Anjum
 
PPTX
Quality of service aware mac protocol for body sensor networks
Iffat Anjum
 
PPT
Library system
Iffat Anjum
 
PPTX
Multicastingand multicast routing protocols
Iffat Anjum
 
PPT
Fpga(field programmable gate array)
Iffat Anjum
 
PPTX
Multicastingand multicast routing protocols
Iffat Anjum
 
PPT
Motorola microprocessor
Iffat Anjum
 
Lecture 09 syntax analysis 05
Iffat Anjum
 
Lecture 10 semantic analysis 01
Iffat Anjum
 
Lecture 04 syntax analysis
Iffat Anjum
 
On qo s provisioning in context aware wireless sensor networks for healthcare
Iffat Anjum
 
Data link control
Iffat Anjum
 
Pnp mac preemptive slot allocation and non preemptive transmission for provid...
Iffat Anjum
 
Qo s based mac protocol for medical wireless body area sensor networks
Iffat Anjum
 
A reinforcement learning based routing protocol with qo s support for biomedi...
Iffat Anjum
 
Data centric multiobjective qo s-aware routing protocol (dm-qos) for body are...
Iffat Anjum
 
Quality of service aware mac protocol for body sensor networks
Iffat Anjum
 
Library system
Iffat Anjum
 
Multicastingand multicast routing protocols
Iffat Anjum
 
Fpga(field programmable gate array)
Iffat Anjum
 
Multicastingand multicast routing protocols
Iffat Anjum
 
Motorola microprocessor
Iffat Anjum
 

Recently uploaded (20)

PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Basics and rules of probability with real-life uses
ravatkaran694
 
CDH. pptx
AneetaSharma15
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 

Lecture 13 intermediate code generation 2.pptx