SlideShare a Scribd company logo
CSE340 - Principles of
Programming Languages
Lecture 08:
Syntactic Analysis II
Javier Gonzalez-Sanchez
javiergs@asu.edu
BYENG M1-38
Office Hours: By appointment
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 2
Outline
Language
Syntactic
Analysis
(Parser)
Grammar
(Rules)
Non-terminal
Terminal
Derivation
Parse
Tree
Tools
BNF
Syntax Diagrams
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 3
Grammar | Derivation
E à E OP E
E à integer
OP à + | - | * | /
E à ( E )
E
⇒  E OP E
⇒  integer OP E
⇒  integer * E
⇒  integer * (E)
⇒ integer * (E OP E)
⇒  integer * (integer OP E)
⇒  integer * (integer + E)
⇒  integer * (integer + integer)
5 * ( 7 + 20 )
Integer operator delimiter integer operator integer delimiter
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 4
5 * ( 7 + 20 )
Integer operator delimiter integer operator integer delimiter
Grammar | Derivation
E
⇒  E OP E
⇒  E OP (E)
⇒  E OP (E OP E)
⇒  E OP (E OP integer)
⇒  E OP (E + integer)
⇒  E OP (integer + integer)
⇒  E * (integer + integer)
⇒  integer * (integer + integer)
E à E OP E
E à integer
OP à + | - | * | /
E à ( E )
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 5
Parse Tree
§  A parse tree is a tree encoding the steps in a
derivation.
§  Internal nodes represent nonterminal symbols used
in the production.
§  Inorder walk of the leaves contains the generated
string.
§  Encodes what productions are used, not the order
in which those productions are applied.
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 6
Parse Tree
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 7
Parse Tree
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 8
Goal
Goal of syntax analysis:
§  Recover the structure described by a series of
tokens.
§  Recover a parse tree for the given input.
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 9
The problem
E à E OP E
E à integer
OP à + | - | * | /
E à ( E )
5 * 7 + 20
Integer operator integer operator integer
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 10
A serious problem
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 11
Ambiguity
•  A grammar is said to be ambiguous if there is at
least one string with two or more parse trees.
•  Note that ambiguity is a property of grammars, not
languages.
We will review this topic in the next lecture
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 12
Our Tools
Backus-Naur Form (BNF)
Extended Backus-Naur Form (EBNF)
Syntax Diagrams
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 13
BNF (Backus-Naur Form)
Formal, mathematical way to specify grammars
All the previous examples, where we use:
à or ::= is defined as
| or operator
<nonterminal> or use uppercases
terminal (lowercases)
* John Backus and Peter Naur
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 14
EBNF
Extended BNF include notation to indicate:
•  0 or more occurrences {…}
•  1 or more occurrences +
•  0 or 1 occurrences […]
•  Use of parentheses for grouping ( )
* Niklaus Wirth
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 15
Example
Grammar rule for calling a method:
§  draw(x, y, z);
§  print (a, b, c, d);
§  done();
§  foobar(one, two, three, four, five);
§  sqrt(x);
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 16
BNF vs EBNF
BNF
<call_method> à identifier(<identifiers>); | identifier();
<identifiers> à identifier | identifier,<identifiers>
EBNF
<call_method> à identifier ('('<identifiers>')' | '('')' ) ';'
<identifiers> à identifier | identifier,<identifiers>
EBNF
<call_method> à identifier'('[<identifiers>]')' ';'
<identifiers> à identifier | identifier,<identifiers>
EBNF
<call_method> à identifier'('[<identifiers>]')' ';'
<identifiers> à identifier { ,identifier }
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 17
Syntax Diagrams
Call_method
Identifiers
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 18
Is it BNF or EBNF?
BLOCK → STMT | { STMTS } | { }
STMTS → STMT | STMT STMTS
STMT → EXPR; |
if (EXPR) BLOCK |
while (EXPR) BLOCK |
BLOCK |
. . .
EXPR → EXPR + EXPR |
EXPR – EXPR |
EXPR * EXPR |
identifier |
integer |
...
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 19
Syntax Diagrams
BLOCK STMTS
STMT EXPR
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 20
Is it BNF or EBNF?
BLOCK → STMT | '{' { STMT } '}'
STMT → EXPR; |
if '(' EXPR ')' BLOCK |
while '(' EXPR ')' BLOCK |
BLOCK |
. . .
EXPR → EXPR '+' EXPR |
EXPR '–' EXPR |
EXPR '*' EXPR |
identifier |
integer |
...
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 21
Syntax Diagrams
BLOCK
STMT EXPR
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 22
Homework
Create a Parse Tree for the following expression.
Use the rules stated in the previous lecture
while ( 5 ) { if ( 6 ) { } }
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)

Fundamentals of Computing and C Programming - Part 3
Fundamentals of Computing and C Programming - Part 3Fundamentals of Computing and C Programming - Part 3
Fundamentals of Computing and C Programming - Part 3
 
Assignment12
Assignment12Assignment12
Assignment12
 
Assignment8
Assignment8Assignment8
Assignment8
 
Cse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingCse115 lecture04introtoc programming
Cse115 lecture04introtoc programming
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Cse115 lecture08repetitionstructures part02
Cse115 lecture08repetitionstructures part02Cse115 lecture08repetitionstructures part02
Cse115 lecture08repetitionstructures part02
 
201801 CSE240 Lecture 07
201801 CSE240 Lecture 07201801 CSE240 Lecture 07
201801 CSE240 Lecture 07
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
answer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcdanswer-model-qp-15-pcd13pcd
answer-model-qp-15-pcd13pcd
 
Compiler unit 5
Compiler  unit 5Compiler  unit 5
Compiler unit 5
 
Booth algorithm
Booth algorithmBooth algorithm
Booth algorithm
 
Assignment10
Assignment10Assignment10
Assignment10
 
A Graph-based Cross-lingual Projection Approach for Spoken Language Understan...
A Graph-based Cross-lingual Projection Approach for Spoken Language Understan...A Graph-based Cross-lingual Projection Approach for Spoken Language Understan...
A Graph-based Cross-lingual Projection Approach for Spoken Language Understan...
 
C Token’s
C Token’sC Token’s
C Token’s
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolving
 
Cse115 lecture02overviewofprogramming
Cse115 lecture02overviewofprogrammingCse115 lecture02overviewofprogramming
Cse115 lecture02overviewofprogramming
 
Lecture5 syntax analysis_1
Lecture5 syntax analysis_1Lecture5 syntax analysis_1
Lecture5 syntax analysis_1
 
Mycasestudy
MycasestudyMycasestudy
Mycasestudy
 
Assignment7
Assignment7Assignment7
Assignment7
 
Assignment6
Assignment6Assignment6
Assignment6
 

Viewers also liked

Meta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student VersionMeta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student VersionKelly Bauer
 
Amazon resource for bioinformatics
Amazon resource for bioinformaticsAmazon resource for bioinformatics
Amazon resource for bioinformaticsBrad Chapman
 
Accomplishment, Aspirations & Challenges: Boston
Accomplishment, Aspirations & Challenges: BostonAccomplishment, Aspirations & Challenges: Boston
Accomplishment, Aspirations & Challenges: BostonThe Hub Milan
 
RCMSL Phenomenal Aug 28, 2009
RCMSL Phenomenal Aug 28, 2009RCMSL Phenomenal Aug 28, 2009
RCMSL Phenomenal Aug 28, 2009etalcomendras
 
링크의 경제학(요약)
링크의 경제학(요약)링크의 경제학(요약)
링크의 경제학(요약)guest29fabfa
 
Master Teset Specification SRCP
Master Teset Specification SRCPMaster Teset Specification SRCP
Master Teset Specification SRCPAnkit Singh
 
Phenomenal Oct 1, 2009
Phenomenal Oct 1, 2009Phenomenal Oct 1, 2009
Phenomenal Oct 1, 2009etalcomendras
 
Chapter 12
Chapter 12Chapter 12
Chapter 12dphil002
 
Harris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsHarris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsIceMilk Aprons
 
Itf ipp ch04_2012_final
Itf ipp ch04_2012_finalItf ipp ch04_2012_final
Itf ipp ch04_2012_finaldphil002
 
Twitter voor journalisten
Twitter voor journalistenTwitter voor journalisten
Twitter voor journalistenBart Van Belle
 
Deutsche Telekom BarCamp 03, 25 June 2009
Deutsche Telekom BarCamp 03, 25 June 2009Deutsche Telekom BarCamp 03, 25 June 2009
Deutsche Telekom BarCamp 03, 25 June 2009Jackson Bond
 
Tracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature DependenciesTracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature Dependencieslienhard
 

Viewers also liked (20)

Meta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student VersionMeta Languages Bnf Ebnf Student Version
Meta Languages Bnf Ebnf Student Version
 
Yacc lex
Yacc lexYacc lex
Yacc lex
 
Yacc
YaccYacc
Yacc
 
Amazon resource for bioinformatics
Amazon resource for bioinformaticsAmazon resource for bioinformatics
Amazon resource for bioinformatics
 
Accomplishment, Aspirations & Challenges: Boston
Accomplishment, Aspirations & Challenges: BostonAccomplishment, Aspirations & Challenges: Boston
Accomplishment, Aspirations & Challenges: Boston
 
Thehub euromed
Thehub   euromedThehub   euromed
Thehub euromed
 
KANSAS CITY INVESTMENT PROPERTIES
KANSAS CITY INVESTMENT PROPERTIESKANSAS CITY INVESTMENT PROPERTIES
KANSAS CITY INVESTMENT PROPERTIES
 
201506 CSE340 Lecture 23
201506 CSE340 Lecture 23201506 CSE340 Lecture 23
201506 CSE340 Lecture 23
 
RCMSL Phenomenal Aug 28, 2009
RCMSL Phenomenal Aug 28, 2009RCMSL Phenomenal Aug 28, 2009
RCMSL Phenomenal Aug 28, 2009
 
링크의 경제학(요약)
링크의 경제학(요약)링크의 경제학(요약)
링크의 경제학(요약)
 
Monaco 020909
Monaco 020909Monaco 020909
Monaco 020909
 
Master Teset Specification SRCP
Master Teset Specification SRCPMaster Teset Specification SRCP
Master Teset Specification SRCP
 
Phenomenal Oct 1, 2009
Phenomenal Oct 1, 2009Phenomenal Oct 1, 2009
Phenomenal Oct 1, 2009
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Harris & Clark + IceMilk Aprons
Harris & Clark + IceMilk ApronsHarris & Clark + IceMilk Aprons
Harris & Clark + IceMilk Aprons
 
Itf ipp ch04_2012_final
Itf ipp ch04_2012_finalItf ipp ch04_2012_final
Itf ipp ch04_2012_final
 
Twitter voor journalisten
Twitter voor journalistenTwitter voor journalisten
Twitter voor journalisten
 
Deutsche Telekom BarCamp 03, 25 June 2009
Deutsche Telekom BarCamp 03, 25 June 2009Deutsche Telekom BarCamp 03, 25 June 2009
Deutsche Telekom BarCamp 03, 25 June 2009
 
Tracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature DependenciesTracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature Dependencies
 
Thomasville
ThomasvilleThomasville
Thomasville
 

Similar to 201506 - CSE340 Lecture 08 (19)

201506 CSE340 Lecture 07
201506 CSE340 Lecture 07201506 CSE340 Lecture 07
201506 CSE340 Lecture 07
 
201506 CSE340 Lecture 09
201506 CSE340 Lecture 09201506 CSE340 Lecture 09
201506 CSE340 Lecture 09
 
201506 CSE340 Lecture 18
201506 CSE340 Lecture 18201506 CSE340 Lecture 18
201506 CSE340 Lecture 18
 
201506 CSE340 Lecture 11
201506 CSE340 Lecture 11201506 CSE340 Lecture 11
201506 CSE340 Lecture 11
 
201707 CSE110 Lecture 04
201707 CSE110 Lecture 04   201707 CSE110 Lecture 04
201707 CSE110 Lecture 04
 
201506 CSE340 Lecture 14
201506 CSE340 Lecture 14201506 CSE340 Lecture 14
201506 CSE340 Lecture 14
 
201506 CSE340 Lecture 21
201506 CSE340 Lecture 21201506 CSE340 Lecture 21
201506 CSE340 Lecture 21
 
201506 CSE340 Lecture 10
201506 CSE340 Lecture 10201506 CSE340 Lecture 10
201506 CSE340 Lecture 10
 
201506 CSE340 Lecture 20
201506 CSE340 Lecture 20 201506 CSE340 Lecture 20
201506 CSE340 Lecture 20
 
201506 CSE340 Lecture 13
201506 CSE340 Lecture 13201506 CSE340 Lecture 13
201506 CSE340 Lecture 13
 
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 12
201506 CSE340 Lecture 12201506 CSE340 Lecture 12
201506 CSE340 Lecture 12
 
201505 CSE340 Lecture 05
201505 CSE340 Lecture 05201505 CSE340 Lecture 05
201505 CSE340 Lecture 05
 
201506 CSE340 Lecture 17
201506 CSE340 Lecture 17201506 CSE340 Lecture 17
201506 CSE340 Lecture 17
 
201707 CSE110 Lecture 03
201707 CSE110 Lecture 03  201707 CSE110 Lecture 03
201707 CSE110 Lecture 03
 
201707 CSE110 Lecture 08
201707 CSE110 Lecture 08  201707 CSE110 Lecture 08
201707 CSE110 Lecture 08
 
Microprocessor Based Design and operations
Microprocessor Based Design and operationsMicroprocessor Based Design and operations
Microprocessor Based Design and operations
 
201707 CSE110 Lecture 15
201707 CSE110 Lecture 15   201707 CSE110 Lecture 15
201707 CSE110 Lecture 15
 

More from 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
 

Recently uploaded

A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisNeo4j
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownloadvrstrong314
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfOrtus Solutions, Corp
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockSkilrock Technologies
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessWSO2
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILNatan Silnitsky
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1KnowledgeSeed
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 

Recently uploaded (20)

A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 

201506 - CSE340 Lecture 08

  • 1. CSE340 - Principles of Programming Languages Lecture 08: Syntactic Analysis II Javier Gonzalez-Sanchez javiergs@asu.edu BYENG M1-38 Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 2 Outline Language Syntactic Analysis (Parser) Grammar (Rules) Non-terminal Terminal Derivation Parse Tree Tools BNF Syntax Diagrams
  • 3. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 3 Grammar | Derivation E à E OP E E à integer OP à + | - | * | / E à ( E ) E ⇒  E OP E ⇒  integer OP E ⇒  integer * E ⇒  integer * (E) ⇒ integer * (E OP E) ⇒  integer * (integer OP E) ⇒  integer * (integer + E) ⇒  integer * (integer + integer) 5 * ( 7 + 20 ) Integer operator delimiter integer operator integer delimiter
  • 4. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 4 5 * ( 7 + 20 ) Integer operator delimiter integer operator integer delimiter Grammar | Derivation E ⇒  E OP E ⇒  E OP (E) ⇒  E OP (E OP E) ⇒  E OP (E OP integer) ⇒  E OP (E + integer) ⇒  E OP (integer + integer) ⇒  E * (integer + integer) ⇒  integer * (integer + integer) E à E OP E E à integer OP à + | - | * | / E à ( E )
  • 5. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 5 Parse Tree §  A parse tree is a tree encoding the steps in a derivation. §  Internal nodes represent nonterminal symbols used in the production. §  Inorder walk of the leaves contains the generated string. §  Encodes what productions are used, not the order in which those productions are applied.
  • 6. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 6 Parse Tree
  • 7. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 7 Parse Tree
  • 8. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 8 Goal Goal of syntax analysis: §  Recover the structure described by a series of tokens. §  Recover a parse tree for the given input.
  • 9. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 9 The problem E à E OP E E à integer OP à + | - | * | / E à ( E ) 5 * 7 + 20 Integer operator integer operator integer
  • 10. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 10 A serious problem
  • 11. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 11 Ambiguity •  A grammar is said to be ambiguous if there is at least one string with two or more parse trees. •  Note that ambiguity is a property of grammars, not languages. We will review this topic in the next lecture
  • 12. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 12 Our Tools Backus-Naur Form (BNF) Extended Backus-Naur Form (EBNF) Syntax Diagrams
  • 13. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 13 BNF (Backus-Naur Form) Formal, mathematical way to specify grammars All the previous examples, where we use: à or ::= is defined as | or operator <nonterminal> or use uppercases terminal (lowercases) * John Backus and Peter Naur
  • 14. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 14 EBNF Extended BNF include notation to indicate: •  0 or more occurrences {…} •  1 or more occurrences + •  0 or 1 occurrences […] •  Use of parentheses for grouping ( ) * Niklaus Wirth
  • 15. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 15 Example Grammar rule for calling a method: §  draw(x, y, z); §  print (a, b, c, d); §  done(); §  foobar(one, two, three, four, five); §  sqrt(x);
  • 16. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 16 BNF vs EBNF BNF <call_method> à identifier(<identifiers>); | identifier(); <identifiers> à identifier | identifier,<identifiers> EBNF <call_method> à identifier ('('<identifiers>')' | '('')' ) ';' <identifiers> à identifier | identifier,<identifiers> EBNF <call_method> à identifier'('[<identifiers>]')' ';' <identifiers> à identifier | identifier,<identifiers> EBNF <call_method> à identifier'('[<identifiers>]')' ';' <identifiers> à identifier { ,identifier }
  • 17. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 17 Syntax Diagrams Call_method Identifiers
  • 18. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 18 Is it BNF or EBNF? BLOCK → STMT | { STMTS } | { } STMTS → STMT | STMT STMTS STMT → EXPR; | if (EXPR) BLOCK | while (EXPR) BLOCK | BLOCK | . . . EXPR → EXPR + EXPR | EXPR – EXPR | EXPR * EXPR | identifier | integer | ...
  • 19. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 19 Syntax Diagrams BLOCK STMTS STMT EXPR
  • 20. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 20 Is it BNF or EBNF? BLOCK → STMT | '{' { STMT } '}' STMT → EXPR; | if '(' EXPR ')' BLOCK | while '(' EXPR ')' BLOCK | BLOCK | . . . EXPR → EXPR '+' EXPR | EXPR '–' EXPR | EXPR '*' EXPR | identifier | integer | ...
  • 21. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 21 Syntax Diagrams BLOCK STMT EXPR
  • 22. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 22 Homework Create a Parse Tree for the following expression. Use the rules stated in the previous lecture while ( 5 ) { if ( 6 ) { } }
  • 23. 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.