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
PPT
02. chapter 3 lexical analysis
PPT
Chapter Three(1)
PDF
Lexical
PPTX
Lexical analysis-using-lex
PPTX
Lecture 02 lexical analysis
PPTX
Language for specifying lexical Analyzer
PDF
Lexical Analysis - Compiler design
Lexical analyzer
02. chapter 3 lexical analysis
Chapter Three(1)
Lexical
Lexical analysis-using-lex
Lecture 02 lexical analysis
Language for specifying lexical Analyzer
Lexical Analysis - Compiler design

What's hot (20)

PPTX
A simple approach of lexical analyzers
PDF
Syntax analysis
PDF
Compiler lec 8
PPT
Compier Design_Unit I_SRM.ppt
PDF
Intermediate code generation
PPTX
Intermediate code- generation
PDF
Syntax directed translation
PPTX
A Role of Lexical Analyzer
PPTX
3. Lexical analysis
PPTX
Lecture 11 semantic analysis 2
PPTX
Compiler design and lexical analyser
PPTX
Lexical Analyzer Implementation
PPTX
Back patching
PPTX
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
PPTX
Lexical analyzer
PDF
Lecture3 lexical analysis
PPTX
Intermediate code generation1
PPT
Lex and Yacc ppt
PPT
Chapter Eight(2)
PPTX
Lexical analyzer generator lex
A simple approach of lexical analyzers
Syntax analysis
Compiler lec 8
Compier Design_Unit I_SRM.ppt
Intermediate code generation
Intermediate code- generation
Syntax directed translation
A Role of Lexical Analyzer
3. Lexical analysis
Lecture 11 semantic analysis 2
Compiler design and lexical analyser
Lexical Analyzer Implementation
Back patching
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Lexical analyzer
Lecture3 lexical analysis
Intermediate code generation1
Lex and Yacc ppt
Chapter Eight(2)
Lexical analyzer generator lex
Ad

Viewers also liked (13)

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

Similar to Lecture 13 intermediate code generation 2.pptx (20)

PPTX
Chapter 3.pptx
PPTX
C_plus_plus
PPTX
Python Programming Basics for begginners
PPTX
LLDB Beyond po
PDF
Implicit conversion and parameters
PPTX
Compiler design Project
PDF
Cpprm
PPT
From UML/OCL to natural language (using SBVR as pivot)
PDF
chapter-1-review-of-python-basics-copy.pdf
PPT
CSharp_02_LanguageOverview_andintroduction
PDF
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
PPTX
C#-LINQ-and-Lambda-Expression
PPTX
Machine_Learning_JNTUH_R18_UNIT5_CONCEPTS.pptx
PPTX
PM1
PPT
Material 3 (4).ppt this ppt is about the
PPTX
Automata compiler design ppt for btech students
PPTX
Python programming –part 3
PPTX
Learn more about the concepts Functions of Python
PPTX
Programming in C.pptx
Chapter 3.pptx
C_plus_plus
Python Programming Basics for begginners
LLDB Beyond po
Implicit conversion and parameters
Compiler design Project
Cpprm
From UML/OCL to natural language (using SBVR as pivot)
chapter-1-review-of-python-basics-copy.pdf
CSharp_02_LanguageOverview_andintroduction
The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse
C#-LINQ-and-Lambda-Expression
Machine_Learning_JNTUH_R18_UNIT5_CONCEPTS.pptx
PM1
Material 3 (4).ppt this ppt is about the
Automata compiler design ppt for btech students
Python programming –part 3
Learn more about the concepts Functions of Python
Programming in C.pptx

More from Iffat Anjum (15)

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

Recently uploaded (20)

PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
Computer Architecture Input Output Memory.pptx
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
Trump Administration's workforce development strategy
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
20th Century Theater, Methods, History.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Empowerment Technology for Senior High School Guide
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
advance database management system book.pdf
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
TNA_Presentation-1-Final(SAVE)) (1).pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Computer Architecture Input Output Memory.pptx
Unit 4 Computer Architecture Multicore Processor.pptx
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Share_Module_2_Power_conflict_and_negotiation.pptx
Trump Administration's workforce development strategy
Weekly quiz Compilation Jan -July 25.pdf
20th Century Theater, Methods, History.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Empowerment Technology for Senior High School Guide
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Introduction to pro and eukaryotes and differences.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
advance database management system book.pdf
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf

Lecture 13 intermediate code generation 2.pptx