SlideShare una empresa de Scribd logo
1 de 34
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.

Más contenido relacionado

La actualidad más candente (20)

201505 CSE340 Lecture 06
201505 CSE340 Lecture 06201505 CSE340 Lecture 06
201505 CSE340 Lecture 06
 
201505 CSE340 Lecture 02
201505 CSE340 Lecture 02201505 CSE340 Lecture 02
201505 CSE340 Lecture 02
 
201506 CSE340 Lecture 15
201506 CSE340 Lecture 15201506 CSE340 Lecture 15
201506 CSE340 Lecture 15
 
201506 CSE340 Lecture 10
201506 CSE340 Lecture 10201506 CSE340 Lecture 10
201506 CSE340 Lecture 10
 
Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
 
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
 
Prefix Postfix
Prefix PostfixPrefix Postfix
Prefix Postfix
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Plsql programs
Plsql programsPlsql programs
Plsql programs
 
Bitwise Operators in C
Bitwise Operators in CBitwise Operators in C
Bitwise Operators in C
 
Pi Controller
Pi ControllerPi Controller
Pi Controller
 
Practical no 5
Practical no 5Practical no 5
Practical no 5
 
201506 CSE340 Lecture 11
201506 CSE340 Lecture 11201506 CSE340 Lecture 11
201506 CSE340 Lecture 11
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Few Operator used in c++
Few Operator used in c++Few Operator used in c++
Few Operator used in c++
 
Practical no 6
Practical no 6Practical no 6
Practical no 6
 
201506 CSE340 Lecture 09
201506 CSE340 Lecture 09201506 CSE340 Lecture 09
201506 CSE340 Lecture 09
 

Destacado

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 resumessfa_angeiologie
 
Laserendoveineux b anastasie 1 er partie
Laserendoveineux  b anastasie   1 er partieLaserendoveineux  b anastasie   1 er partie
Laserendoveineux b anastasie 1 er partiesfa_angeiologie
 
Social media voor journalisten
Social media voor journalistenSocial media voor journalisten
Social media voor journalistenBart Van Belle
 
Vol 02 chapter 8 2012
Vol 02 chapter 8 2012Vol 02 chapter 8 2012
Vol 02 chapter 8 2012dphil002
 
Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009etalcomendras
 
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 Enetalcomendras
 
Harris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsHarris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsIceMilk Aprons
 
Technologische trends voor journalistiek
Technologische trends voor journalistiekTechnologische trends voor journalistiek
Technologische trends voor journalistiekBart Van Belle
 
Tabagisme et thrombose habbal
Tabagisme et thrombose habbalTabagisme et thrombose habbal
Tabagisme et thrombose habbalsfa_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 #5SylShannon
 
漫谈php和java
漫谈php和java漫谈php和java
漫谈php和javasulong
 

Destacado (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
 
Laserendoveineux b anastasie 1 er partie
Laserendoveineux  b anastasie   1 er partieLaserendoveineux  b anastasie   1 er partie
Laserendoveineux b anastasie 1 er partie
 
Social media voor journalisten
Social media voor journalistenSocial media voor journalisten
Social media voor journalisten
 
Vol 02 chapter 8 2012
Vol 02 chapter 8 2012Vol 02 chapter 8 2012
Vol 02 chapter 8 2012
 
Thehub euromed
Thehub   euromedThehub   euromed
Thehub euromed
 
Eeuwigblijvenleren
EeuwigblijvenlerenEeuwigblijvenleren
Eeuwigblijvenleren
 
Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009Phenomenal Oct 22, 2009
Phenomenal Oct 22, 2009
 
201505 CSE340 Lecture 03
201505 CSE340 Lecture 03201505 CSE340 Lecture 03
201505 CSE340 Lecture 03
 
Cluster 15
Cluster 15Cluster 15
Cluster 15
 
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...
 
Paul Harris Fellow Clubs En
Paul Harris Fellow Clubs EnPaul Harris Fellow Clubs En
Paul Harris Fellow Clubs En
 
Harris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsHarris & Clark + IceMilk Aprons
Harris & Clark + IceMilk Aprons
 
Technologische trends voor journalistiek
Technologische trends voor journalistiekTechnologische trends voor journalistiek
Technologische trends voor journalistiek
 
Tabagisme et thrombose habbal
Tabagisme et thrombose habbalTabagisme et thrombose habbal
Tabagisme et thrombose habbal
 
Presentation
PresentationPresentation
Presentation
 
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...
 
Awesome Powerpoint Monday Morning #5
Awesome Powerpoint Monday Morning #5Awesome Powerpoint Monday Morning #5
Awesome Powerpoint Monday Morning #5
 
201101 mLearning
201101 mLearning201101 mLearning
201101 mLearning
 
漫谈php和java
漫谈php和java漫谈php和java
漫谈php和java
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 

Similar a 201506 CSE340 Lecture 21

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 ReviewerAndrey Karpov
 
Implementing qrcode
Implementing qrcodeImplementing qrcode
Implementing qrcodeBoshan Sun
 
Facility Location Problem
Facility Location ProblemFacility Location Problem
Facility Location ProblemEvren E
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016Jeff 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 RYanchang Zhao
 
Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mpMSc 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 codeWim 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 codeWim Godden
 

Similar a 201506 CSE340 Lecture 21 (14)

201506 CSE340 Lecture 12
201506 CSE340 Lecture 12201506 CSE340 Lecture 12
201506 CSE340 Lecture 12
 
201506 CSE340 Lecture 14
201506 CSE340 Lecture 14201506 CSE340 Lecture 14
201506 CSE340 Lecture 14
 
201506 CSE340 Lecture 17
201506 CSE340 Lecture 17201506 CSE340 Lecture 17
201506 CSE340 Lecture 17
 
201506 - CSE340 Lecture 08
201506 - CSE340 Lecture 08201506 - CSE340 Lecture 08
201506 - CSE340 Lecture 08
 
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
 
Implementing qrcode
Implementing qrcodeImplementing qrcode
Implementing qrcode
 
201707 CSE110 Lecture 04
201707 CSE110 Lecture 04   201707 CSE110 Lecture 04
201707 CSE110 Lecture 04
 
Facility Location Problem
Facility Location ProblemFacility Location Problem
Facility Location Problem
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016
 
Effective C#
Effective C#Effective C#
Effective C#
 
Regression and Classification with R
Regression and Classification with RRegression and Classification with R
Regression and Classification with R
 
Computer archi&mp
Computer archi&mpComputer archi&mp
Computer archi&mp
 
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
 
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
 

Más de Javier Gonzalez-Sanchez (20)

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

Último

What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 

Último (20)

What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 

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.