SlideShare a Scribd company logo
CSE340 - Principles of
Programming Languages
Lecture 21:
Intermediate Code II
Javier Gonzalez-Sanchez
BYENG M1-38
Office Hours: By appointment
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 2
Review
a, int, global, 0
b, int, global, 0
@
LIT 5, 0
STO a, 0
LIT 9, 0
STO b, 0
LOD a, 0
LOD b, 0
LIT 3, 0
OPR 4, 0
OPR 2, 0
STO a, 0
LOD a, 0
OPR 21,0
LIT "hello", 0
OPR 21,0
OPR 1, 0
OPR 0,0
Virtual Machine
(interpreter)
{
int a;
int b;
a = 5;
b = 9;
a = a + b / 3;
print (a);
print ("hello");
}
Lexer
Parser
Semantic Analyzer Code Generation
8
hello
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 3
Review
{
int a;
int b;
boolean foo;
a = 10 + 20 + 30 + 40;
print (a);
foo = 340 > 126;
print (foo);
a = a / 2;
print ("total:" + a);
return;
}
Lexer
Parser
Semantic Analyzer Code Generation
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 4
Review
Virtual Machine
(interpreter)
100
true
total: 50
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 5
Assignment #4
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 6
Assignment #4
Lexer
Parser
Semantic Analyzer Code Generation
assignment #1
or
Lexer.jar
To show
proficiency
building a
descendent
parser
Programming
workshops
Do not required.
Bonus points include
Semantic Analysis from
assignment #3
Following
lectures
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 7
Assignment #4 | Grammar
<PROGRAM> à '{' <BODY> '}’
<BODY> à {<PRINT>';'|<ASSIGNMENT>';'|<VARIABLE>';’|
<WHILE>|<IF>|<SWITCH>|<RETURN>';'}
<ASSIGNMENT> à identifier '=' <EXPRESSION>
<VARIABLE> à ('int'|'float'|'boolean'|'char’|'string'|'void')identifier
<WHILE> à 'while' '(' <EXPRESSION> ')' <PROGRAM>
<IF> à 'if' '(' <EXPRESSION> ')' <PROGRAM> ['else' <PROGRAM>]
<RETURN> à 'return'
<PRINT> à ’print’ ‘(‘ <EXPRESSION> ‘)’
<EXPRESSION> à <X> {'|' <X>}
<X> à <Y> {'&' <Y>}
<Y> à ['!'] <R>
<R> à <E> {('>'|'<'|'=='|'!=') <E>}
<E> à <A> {(’+'|'-’) <A>}
<A> à <B> {('*'|'/') <B>}
<B> à ['-'] <C>
<C> à integer | octal | hexadecimal | binary | true | false |
string | char | float | identifier|'(' <EXPRESSION> ')'
<SWITCH> à 'switch' '(' id ')' '{' <CASES> [<DEFAULT>] '}'
<CASES> à ('case' (integer|octal|hexadecimal|binary) ':' <PROGRAM>)+
<DEFAULT> à 'default' ':' <PROGRAM>
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 8
Assignment #4 | Compiler
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 9
Assignment #4 | Compiler
Bonus Points
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 10
Assignment #4 | VM
Use it to test your compiler.
No changes required
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 11
Assignment #4 | Code
Add this lines to your Parser.run()
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 12
Assignment #4 | Code
The CodeGenerator.java file
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 13
Assignment #4 | Grading
•  Bonus A
Implement SWITCH statement: (a) parser; and (b)
code generation.
•  Bonus B
Integration: (a) graphical user interface including
token table, parse tree, and symbol table; (b)
syntactic errors handling and recovery; and (c)
semantic analysis.
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 14
Assignment #4 | Grading
assignment bonus
0–100% 0–10%
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 15
Implementing
Intermediate Code Generation
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 16
Code Generation
*	
1	
 2	
*	
4	
 5	
+	
3	
>	
1 * 2 > 3 + 4 * 5 LIT 1, 0
LIT 2, 0
OPR 4, 0
LIT 3, 0
LIT 4, 0
LIT 5, 0
OPR 4, 0
OPR 2, 0
OPR 11, 0
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 17
Code
PROGRAM
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 18
Code
BODY
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 19
Code
PRINT
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 20
Code
ASSIGNMENT
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 21
Code
VARIABLE
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 22
Code
WHILE
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 23
Code
IF
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 24
Code
RETURN
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 25
Code
EXPRESSION
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 26
Code
X
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 27
Code
Y
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 28
Code
R
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 29
Code
E
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 30
Code
A
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 31
Code
B
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 32
Code
C
Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 33
Homework
Assignment #4
(LIT, LOD, STO, OPR)
CSE340 - Principles of Programming Languages
Javier Gonzalez-Sanchez
javiergs@asu.edu
Summer 2015
Disclaimer. These slides can only be used as study material for the class CSE340 at ASU. They cannot be distributed or used for another purpose.

More Related Content

What's hot (20)

201505 CSE340 Lecture 06
201505 CSE340 Lecture 06201505 CSE340 Lecture 06
201505 CSE340 Lecture 06
Javier Gonzalez-Sanchez
 
201505 CSE340 Lecture 02
201505 CSE340 Lecture 02201505 CSE340 Lecture 02
201505 CSE340 Lecture 02
Javier Gonzalez-Sanchez
 
201506 CSE340 Lecture 15
201506 CSE340 Lecture 15201506 CSE340 Lecture 15
201506 CSE340 Lecture 15
Javier Gonzalez-Sanchez
 
201506 CSE340 Lecture 10
201506 CSE340 Lecture 10201506 CSE340 Lecture 10
201506 CSE340 Lecture 10
Javier Gonzalez-Sanchez
 
Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
Vikas Dongre
 
Arithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded CArithmetic and Logic instructions in Embedded C
Arithmetic and Logic instructions in Embedded C
Vikas Dongre
 
Prefix Postfix
Prefix PostfixPrefix Postfix
Prefix Postfix
Kulachi Hansraj Model School Ashok Vihar
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
Md Masudur Rahman
 
Plsql programs
Plsql programsPlsql programs
Plsql programs
Knowledge Center Computer
 
Bitwise Operators in C
Bitwise Operators in CBitwise Operators in C
Bitwise Operators in C
yndaravind
 
Pi Controller
Pi ControllerPi Controller
Pi Controller
Assignmentpedia
 
Practical no 5
Practical no 5Practical no 5
Practical no 5
Kshitija Dalvi
 
201506 CSE340 Lecture 11
201506 CSE340 Lecture 11201506 CSE340 Lecture 11
201506 CSE340 Lecture 11
Javier Gonzalez-Sanchez
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
eShikshak
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
mohdshanu
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
emailharmeet
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
AMIT GODRE
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
sunny khan
 
Practical no 6
Practical no 6Practical no 6
Practical no 6
Kshitija Dalvi
 
201506 CSE340 Lecture 09
201506 CSE340 Lecture 09201506 CSE340 Lecture 09
201506 CSE340 Lecture 09
Javier Gonzalez-Sanchez
 

Viewers also liked (20)

Angeiologie 4 2013 - 1-2014 livre des resumes
Angeiologie 4 2013 - 1-2014 livre des resumesAngeiologie 4 2013 - 1-2014 livre des resumes
Angeiologie 4 2013 - 1-2014 livre des resumes
sfa_angeiologie
 
Laserendoveineux b anastasie 1 er partie
Laserendoveineux  b anastasie   1 er partieLaserendoveineux  b anastasie   1 er partie
Laserendoveineux b anastasie 1 er partie
sfa_angeiologie
 
Social media voor journalisten
Social media voor journalistenSocial media voor journalisten
Social media voor journalisten
Bart Van Belle
 
Vol 02 chapter 8 2012
Vol 02 chapter 8 2012Vol 02 chapter 8 2012
Vol 02 chapter 8 2012
dphil002
 
Thehub euromed
Thehub   euromedThehub   euromed
Thehub euromed
The Hub Milan
 
Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009
etalcomendras
 
201505 CSE340 Lecture 03
201505 CSE340 Lecture 03201505 CSE340 Lecture 03
201505 CSE340 Lecture 03
Javier Gonzalez-Sanchez
 
Cluster 15
Cluster 15Cluster 15
Cluster 15
etalcomendras
 
201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...
201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...
201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...
Javier Gonzalez-Sanchez
 
Paul Harris Fellow Clubs En
Paul Harris Fellow Clubs EnPaul Harris Fellow Clubs En
Paul Harris Fellow Clubs En
etalcomendras
 
Harris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsHarris & Clark + IceMilk Aprons
Harris & Clark + IceMilk Aprons
IceMilk Aprons
 
Technologische trends voor journalistiek
Technologische trends voor journalistiekTechnologische trends voor journalistiek
Technologische trends voor journalistiek
Bart Van Belle
 
Tabagisme et thrombose habbal
Tabagisme et thrombose habbalTabagisme et thrombose habbal
Tabagisme et thrombose habbal
sfa_angeiologie
 
Presentation
PresentationPresentation
Presentation
Emily Reyes
 
Developing distributed analysis pipelines with shared community resources usi...
Developing distributed analysis pipelines with shared community resources usi...Developing distributed analysis pipelines with shared community resources usi...
Developing distributed analysis pipelines with shared community resources usi...
Brad Chapman
 
Awesome Powerpoint Monday Morning #5
Awesome Powerpoint Monday Morning #5Awesome Powerpoint Monday Morning #5
Awesome Powerpoint Monday Morning #5
SylShannon
 
201101 mLearning
201101 mLearning201101 mLearning
201101 mLearning
Javier Gonzalez-Sanchez
 
漫谈php和java
漫谈php和java漫谈php和java
漫谈php和java
sulong
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
dphil002
 
Angeiologie 4 2013 - 1-2014 livre des resumes
Angeiologie 4 2013 - 1-2014 livre des resumesAngeiologie 4 2013 - 1-2014 livre des resumes
Angeiologie 4 2013 - 1-2014 livre des resumes
sfa_angeiologie
 
Laserendoveineux b anastasie 1 er partie
Laserendoveineux  b anastasie   1 er partieLaserendoveineux  b anastasie   1 er partie
Laserendoveineux b anastasie 1 er partie
sfa_angeiologie
 
Social media voor journalisten
Social media voor journalistenSocial media voor journalisten
Social media voor journalisten
Bart Van Belle
 
Vol 02 chapter 8 2012
Vol 02 chapter 8 2012Vol 02 chapter 8 2012
Vol 02 chapter 8 2012
dphil002
 
Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009
etalcomendras
 
201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...
201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...
201404 Multimodal Detection of Affective States: A Roadmap Through Diverse Te...
Javier Gonzalez-Sanchez
 
Paul Harris Fellow Clubs En
Paul Harris Fellow Clubs EnPaul Harris Fellow Clubs En
Paul Harris Fellow Clubs En
etalcomendras
 
Harris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsHarris & Clark + IceMilk Aprons
Harris & Clark + IceMilk Aprons
IceMilk Aprons
 
Technologische trends voor journalistiek
Technologische trends voor journalistiekTechnologische trends voor journalistiek
Technologische trends voor journalistiek
Bart Van Belle
 
Tabagisme et thrombose habbal
Tabagisme et thrombose habbalTabagisme et thrombose habbal
Tabagisme et thrombose habbal
sfa_angeiologie
 
Developing distributed analysis pipelines with shared community resources usi...
Developing distributed analysis pipelines with shared community resources usi...Developing distributed analysis pipelines with shared community resources usi...
Developing distributed analysis pipelines with shared community resources usi...
Brad Chapman
 
Awesome Powerpoint Monday Morning #5
Awesome Powerpoint Monday Morning #5Awesome Powerpoint Monday Morning #5
Awesome Powerpoint Monday Morning #5
SylShannon
 
漫谈php和java
漫谈php和java漫谈php和java
漫谈php和java
sulong
 

Similar to 201506 CSE340 Lecture 21 (16)

201506 CSE340 Lecture 12
201506 CSE340 Lecture 12201506 CSE340 Lecture 12
201506 CSE340 Lecture 12
Javier Gonzalez-Sanchez
 
201506 CSE340 Lecture 14
201506 CSE340 Lecture 14201506 CSE340 Lecture 14
201506 CSE340 Lecture 14
Javier Gonzalez-Sanchez
 
201506 CSE340 Lecture 17
201506 CSE340 Lecture 17201506 CSE340 Lecture 17
201506 CSE340 Lecture 17
Javier Gonzalez-Sanchez
 
201506 - CSE340 Lecture 08
201506 - CSE340 Lecture 08201506 - CSE340 Lecture 08
201506 - CSE340 Lecture 08
Javier Gonzalez-Sanchez
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
Implementing qrcode
Implementing qrcodeImplementing qrcode
Implementing qrcode
Boshan Sun
 
201801 CSE240 Lecture 07
201801 CSE240 Lecture 07201801 CSE240 Lecture 07
201801 CSE240 Lecture 07
Javier Gonzalez-Sanchez
 
201707 CSE110 Lecture 04
201707 CSE110 Lecture 04   201707 CSE110 Lecture 04
201707 CSE110 Lecture 04
Javier Gonzalez-Sanchez
 
Facility Location Problem
Facility Location ProblemFacility Location Problem
Facility Location Problem
Evren E
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016
Jeff Chu
 
Effective C#
Effective C#Effective C#
Effective C#
lantoli
 
Regression and Classification with R
Regression and Classification with RRegression and Classification with R
Regression and Classification with R
Yanchang Zhao
 
Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mp
MSc CST
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...
C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...
C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...
mkesgoggo
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
Implementing qrcode
Implementing qrcodeImplementing qrcode
Implementing qrcode
Boshan Sun
 
Facility Location Problem
Facility Location ProblemFacility Location Problem
Facility Location Problem
Evren E
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016
Jeff Chu
 
Effective C#
Effective C#Effective C#
Effective C#
lantoli
 
Regression and Classification with R
Regression and Classification with RRegression and Classification with R
Regression and Classification with R
Yanchang Zhao
 
Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mp
MSc CST
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...
C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...
C++ Programming From Problem Analysis to Program Design 7th Edition Malik Tes...
mkesgoggo
 

More from Javier Gonzalez-Sanchez (20)

201804 SER332 Lecture 01
201804 SER332 Lecture 01201804 SER332 Lecture 01
201804 SER332 Lecture 01
Javier Gonzalez-Sanchez
 
201801 SER332 Lecture 03
201801 SER332 Lecture 03201801 SER332 Lecture 03
201801 SER332 Lecture 03
Javier Gonzalez-Sanchez
 
201801 SER332 Lecture 04
201801 SER332 Lecture 04201801 SER332 Lecture 04
201801 SER332 Lecture 04
Javier Gonzalez-Sanchez
 
201801 SER332 Lecture 02
201801 SER332 Lecture 02201801 SER332 Lecture 02
201801 SER332 Lecture 02
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 26
201801 CSE240 Lecture 26201801 CSE240 Lecture 26
201801 CSE240 Lecture 26
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 25
201801 CSE240 Lecture 25201801 CSE240 Lecture 25
201801 CSE240 Lecture 25
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 24
201801 CSE240 Lecture 24201801 CSE240 Lecture 24
201801 CSE240 Lecture 24
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 23
201801 CSE240 Lecture 23201801 CSE240 Lecture 23
201801 CSE240 Lecture 23
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 22
201801 CSE240 Lecture 22201801 CSE240 Lecture 22
201801 CSE240 Lecture 22
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 21
201801 CSE240 Lecture 21201801 CSE240 Lecture 21
201801 CSE240 Lecture 21
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 20
201801 CSE240 Lecture 20201801 CSE240 Lecture 20
201801 CSE240 Lecture 20
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 19
201801 CSE240 Lecture 19201801 CSE240 Lecture 19
201801 CSE240 Lecture 19
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 18
201801 CSE240 Lecture 18201801 CSE240 Lecture 18
201801 CSE240 Lecture 18
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 16
201801 CSE240 Lecture 16201801 CSE240 Lecture 16
201801 CSE240 Lecture 16
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 15
201801 CSE240 Lecture 15201801 CSE240 Lecture 15
201801 CSE240 Lecture 15
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 13
201801 CSE240 Lecture 13201801 CSE240 Lecture 13
201801 CSE240 Lecture 13
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
Javier Gonzalez-Sanchez
 
201801 CSE240 Lecture 11
201801 CSE240 Lecture 11201801 CSE240 Lecture 11
201801 CSE240 Lecture 11
Javier Gonzalez-Sanchez
 

Recently uploaded (20)

Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
The Elixir Developer - All Things Open
The Elixir Developer - All Things OpenThe Elixir Developer - All Things Open
The Elixir Developer - All Things Open
Carlo Gilmar Padilla Santana
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint PresentationFrom Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
From Vibe Coding to Vibe Testing - Complete PowerPoint Presentation
Shay Ginsbourg
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 

201506 CSE340 Lecture 21

  • 1. CSE340 - Principles of Programming Languages Lecture 21: Intermediate Code II Javier Gonzalez-Sanchez BYENG M1-38 Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 2 Review a, int, global, 0 b, int, global, 0 @ LIT 5, 0 STO a, 0 LIT 9, 0 STO b, 0 LOD a, 0 LOD b, 0 LIT 3, 0 OPR 4, 0 OPR 2, 0 STO a, 0 LOD a, 0 OPR 21,0 LIT "hello", 0 OPR 21,0 OPR 1, 0 OPR 0,0 Virtual Machine (interpreter) { int a; int b; a = 5; b = 9; a = a + b / 3; print (a); print ("hello"); } Lexer Parser Semantic Analyzer Code Generation 8 hello
  • 3. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 3 Review { int a; int b; boolean foo; a = 10 + 20 + 30 + 40; print (a); foo = 340 > 126; print (foo); a = a / 2; print ("total:" + a); return; } Lexer Parser Semantic Analyzer Code Generation
  • 4. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 4 Review Virtual Machine (interpreter) 100 true total: 50
  • 5. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 5 Assignment #4
  • 6. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 6 Assignment #4 Lexer Parser Semantic Analyzer Code Generation assignment #1 or Lexer.jar To show proficiency building a descendent parser Programming workshops Do not required. Bonus points include Semantic Analysis from assignment #3 Following lectures
  • 7. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 7 Assignment #4 | Grammar <PROGRAM> à '{' <BODY> '}’ <BODY> à {<PRINT>';'|<ASSIGNMENT>';'|<VARIABLE>';’| <WHILE>|<IF>|<SWITCH>|<RETURN>';'} <ASSIGNMENT> à identifier '=' <EXPRESSION> <VARIABLE> à ('int'|'float'|'boolean'|'char’|'string'|'void')identifier <WHILE> à 'while' '(' <EXPRESSION> ')' <PROGRAM> <IF> à 'if' '(' <EXPRESSION> ')' <PROGRAM> ['else' <PROGRAM>] <RETURN> à 'return' <PRINT> à ’print’ ‘(‘ <EXPRESSION> ‘)’ <EXPRESSION> à <X> {'|' <X>} <X> à <Y> {'&' <Y>} <Y> à ['!'] <R> <R> à <E> {('>'|'<'|'=='|'!=') <E>} <E> à <A> {(’+'|'-’) <A>} <A> à <B> {('*'|'/') <B>} <B> à ['-'] <C> <C> à integer | octal | hexadecimal | binary | true | false | string | char | float | identifier|'(' <EXPRESSION> ')' <SWITCH> à 'switch' '(' id ')' '{' <CASES> [<DEFAULT>] '}' <CASES> à ('case' (integer|octal|hexadecimal|binary) ':' <PROGRAM>)+ <DEFAULT> à 'default' ':' <PROGRAM>
  • 8. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 8 Assignment #4 | Compiler
  • 9. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 9 Assignment #4 | Compiler Bonus Points
  • 10. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 10 Assignment #4 | VM Use it to test your compiler. No changes required
  • 11. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 11 Assignment #4 | Code Add this lines to your Parser.run()
  • 12. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 12 Assignment #4 | Code The CodeGenerator.java file
  • 13. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 13 Assignment #4 | Grading •  Bonus A Implement SWITCH statement: (a) parser; and (b) code generation. •  Bonus B Integration: (a) graphical user interface including token table, parse tree, and symbol table; (b) syntactic errors handling and recovery; and (c) semantic analysis.
  • 14. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 14 Assignment #4 | Grading assignment bonus 0–100% 0–10%
  • 15. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 15 Implementing Intermediate Code Generation
  • 16. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 16 Code Generation * 1 2 * 4 5 + 3 > 1 * 2 > 3 + 4 * 5 LIT 1, 0 LIT 2, 0 OPR 4, 0 LIT 3, 0 LIT 4, 0 LIT 5, 0 OPR 4, 0 OPR 2, 0 OPR 11, 0
  • 17. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 17 Code PROGRAM
  • 18. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 18 Code BODY
  • 19. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 19 Code PRINT
  • 20. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 20 Code ASSIGNMENT
  • 21. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 21 Code VARIABLE
  • 22. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 22 Code WHILE
  • 23. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 23 Code IF
  • 24. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 24 Code RETURN
  • 25. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 25 Code EXPRESSION
  • 26. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 26 Code X
  • 27. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 27 Code Y
  • 28. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 28 Code R
  • 29. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 29 Code E
  • 30. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 30 Code A
  • 31. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 31 Code B
  • 32. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 32 Code C
  • 33. Javier Gonzalez-Sanchez | CSE340 | Summer2015 | 33 Homework Assignment #4 (LIT, LOD, STO, OPR)
  • 34. CSE340 - Principles of Programming Languages Javier Gonzalez-Sanchez javiergs@asu.edu Summer 2015 Disclaimer. These slides can only be used as study material for the class CSE340 at ASU. They cannot be distributed or used for another purpose.
  翻译: