SlideShare a Scribd company logo
1 of 17
 Parsing is a process that constructs a syntactic
structure (i.e. parse tree) from the stream of
tokens.
 Breaks the data into smaller units for easy
translation
 Used to determine if input data may be derived
from the start symbol of the grammer
 Identifies lexical units in a source statement
 Classifies units into different classes e.g. id’s,
constants, reserved ids etc and enters them into
different tables
 Token contains Class code and number in class
Syntax :Code #no eg : id#10
Example
Statement a := b + I;
a := b + I ;
id#2 op#5 id#3 op#3 id#1 op#10
 Determines the statement class such as
assignment statement, if stmt etc.
 Eg: a,b : real ; and a:=b +I ;
 Determines the meaning of the expression
 Results in addition of information such as type,
length
 Determines the meaning of subtree
Stmt a:= b + I ; proceeds as
1. Type is added to tree
2. Rules of assignment indicate expression on
RHS should be evaluated first
3. Rules of addition indicate I should be converted
before addition
 A context-free grammar (CFG) G is a quadruple
(N, Σ, P, S) where
 N: a set of non-terminal symbols
 Σ: a set of terminals ( N ∩ Σ = Ǿ)
 P: a set of rules (P: N → (N U Σ)*)
 S: a start symbol.
N = {Q, F,}
Σ = {0, 1}
P = {Q → 11Q, Q→ 00F,
F → 11F, F→ ε }
S = q
to generate 110011
Q →11Q →1100F →110011F →110011ε
 They provide a precise mathematical definition
that clearly rules out certain types of language.
 The formal definition means that context free
grammars are computationally TRACTABLE--it is
possible to write a computer program which
determines whether sentences are
grammatical or not.
 They provide a convenient visual notation for
the structure of sentences (the tree).
 Goal of parser : build a derivation
 Top-down parser : build a derivation by working from
the start symbol towards the input.
 Builds parse tree from root to leaves
 Builds leftmost derivation
 Bottom-up parser : build a derivation by working
from the input back toward the start symbol
 Builds parse tree from leaves to root
 Builds reverse rightmost derivation
 Consider the grammar:
S → c A d
A → ab | a
The input string is “cad”
Given the grammar :
E → TE’
E’ → +TE’ | λ
T → FT’
T’ → *FT’ | λ
F → (E) | id
The input: id + id * id
STACK INPUT BUFFER ACTION
$ num1+num2*num3$ shift
$num1 +num2*num3$ reduc
$F +num2*num3$ reduc
$T +num2*num3$ reduc
$E +num2*num3$ shift
$E+ num2*num3$ shift
$E+num2 *num3$ reduc
$E+F *num3$ reduc
$E+T *num3$ shift
E+T* num3$ shift
E+T*num3 $ reduc
E+T*F $ reduc
E+T $ reduc
E $ accept
E -> E+T
| T
| E-T
T -> T*F
| F
| T/F
F -> (E)
| id
| -E
num
Parsing 17
 A parse tree is created from
root to leaves
 The traversal of parse trees
is a preorder traversal
 Tracing leftmost derivation
 Two types:
 Backtracking parser
 Predictive parser
 A parse tree is created from
leaves to root
 The traversal of parse trees
is a reversal of post order
traversal
 Tracing rightmost derivation
 More powerful than top-
down parsing
 LR parserBacktracking: Try different
structures and backtrack if it
does not matched the input Predictive: Guess the
structure of the parse tree
from the next input

More Related Content

What's hot

What's hot (20)

Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 
Parsing
ParsingParsing
Parsing
 
A simple approach of lexical analyzers
A simple approach of lexical analyzersA simple approach of lexical analyzers
A simple approach of lexical analyzers
 
02. chapter 3 lexical analysis
02. chapter 3   lexical analysis02. chapter 3   lexical analysis
02. chapter 3 lexical analysis
 
Syntax analyzer
Syntax analyzerSyntax analyzer
Syntax analyzer
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
 
Lexical
LexicalLexical
Lexical
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
 
Compiler lec 8
Compiler lec 8Compiler lec 8
Compiler lec 8
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Types of Parser
Types of ParserTypes of Parser
Types of Parser
 
Implementation of lexical analyser
Implementation of lexical analyserImplementation of lexical analyser
Implementation of lexical analyser
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Lecture3 lexical analysis
Lecture3 lexical analysisLecture3 lexical analysis
Lecture3 lexical analysis
 
Lecture4 lexical analysis2
Lecture4 lexical analysis2Lecture4 lexical analysis2
Lecture4 lexical analysis2
 

Viewers also liked

Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3Iffat Anjum
 
Syntax of filipino as lingua franca part1
Syntax of filipino as lingua franca part1Syntax of filipino as lingua franca part1
Syntax of filipino as lingua franca part1JESSIE GRACE RUBRICO
 
OMD chapter 2 Class modelling
 OMD  chapter 2 Class modelling OMD  chapter 2 Class modelling
OMD chapter 2 Class modellingjayashri kolekar
 
Bakus naur form
Bakus naur formBakus naur form
Bakus naur formgrahamwell
 
Natural language processing with python and amharic syntax parse tree by dani...
Natural language processing with python and amharic syntax parse tree by dani...Natural language processing with python and amharic syntax parse tree by dani...
Natural language processing with python and amharic syntax parse tree by dani...Daniel Adenew
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Iffat Anjum
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design IntroductionRicha Sharma
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logicJanet Stemwedel
 
Advanced behavioral modeling chapter 4 of omd
Advanced behavioral modeling chapter 4 of omdAdvanced behavioral modeling chapter 4 of omd
Advanced behavioral modeling chapter 4 of omdjayashri kolekar
 
Architectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdArchitectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdjayashri kolekar
 
Summary - Transformational-Generative Theory
Summary - Transformational-Generative TheorySummary - Transformational-Generative Theory
Summary - Transformational-Generative TheoryMarielis VI
 

Viewers also liked (20)

Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3Lecture 06 syntax analysis 3
Lecture 06 syntax analysis 3
 
Lexical 2
Lexical 2Lexical 2
Lexical 2
 
Compilers
CompilersCompilers
Compilers
 
Assembler1
Assembler1Assembler1
Assembler1
 
Macro
MacroMacro
Macro
 
Loader
LoaderLoader
Loader
 
Lesson2
Lesson2Lesson2
Lesson2
 
Syntax of filipino as lingua franca part1
Syntax of filipino as lingua franca part1Syntax of filipino as lingua franca part1
Syntax of filipino as lingua franca part1
 
OMD chapter 2 Class modelling
 OMD  chapter 2 Class modelling OMD  chapter 2 Class modelling
OMD chapter 2 Class modelling
 
Bakus naur form
Bakus naur formBakus naur form
Bakus naur form
 
Natural language processing with python and amharic syntax parse tree by dani...
Natural language processing with python and amharic syntax parse tree by dani...Natural language processing with python and amharic syntax parse tree by dani...
Natural language processing with python and amharic syntax parse tree by dani...
 
Su 2012 ss syntax(1)
Su 2012 ss syntax(1)Su 2012 ss syntax(1)
Su 2012 ss syntax(1)
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2
 
Compiler Design Introduction
Compiler Design IntroductionCompiler Design Introduction
Compiler Design Introduction
 
System programming
System programmingSystem programming
System programming
 
Parsing
ParsingParsing
Parsing
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
 
Advanced behavioral modeling chapter 4 of omd
Advanced behavioral modeling chapter 4 of omdAdvanced behavioral modeling chapter 4 of omd
Advanced behavioral modeling chapter 4 of omd
 
Architectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omdArchitectural modeling chapter 5 of omd
Architectural modeling chapter 5 of omd
 
Summary - Transformational-Generative Theory
Summary - Transformational-Generative TheorySummary - Transformational-Generative Theory
Summary - Transformational-Generative Theory
 

Similar to Parsing (20)

Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
 
CC Week 11.ppt
CC Week 11.pptCC Week 11.ppt
CC Week 11.ppt
 
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
 
Compiler notes--unit-iii
Compiler notes--unit-iiiCompiler notes--unit-iii
Compiler notes--unit-iii
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
Semantics analysis
Semantics analysisSemantics analysis
Semantics analysis
 
Syntaxdirected
SyntaxdirectedSyntaxdirected
Syntaxdirected
 
Syntaxdirected
SyntaxdirectedSyntaxdirected
Syntaxdirected
 
Syntaxdirected (1)
Syntaxdirected (1)Syntaxdirected (1)
Syntaxdirected (1)
 
5_IntermediateCodeGeneration.ppt
5_IntermediateCodeGeneration.ppt5_IntermediateCodeGeneration.ppt
5_IntermediateCodeGeneration.ppt
 
Antlr V3
Antlr V3Antlr V3
Antlr V3
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT IIC PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
C PROGRAMMING BASICS- COMPUTER PROGRAMMING UNIT II
 
Chapter Eight(2)
Chapter Eight(2)Chapter Eight(2)
Chapter Eight(2)
 
Tut1
Tut1Tut1
Tut1
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
C++
C++C++
C++
 

Recently uploaded

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Parsing

  • 1.
  • 2.  Parsing is a process that constructs a syntactic structure (i.e. parse tree) from the stream of tokens.  Breaks the data into smaller units for easy translation  Used to determine if input data may be derived from the start symbol of the grammer
  • 3.
  • 4.  Identifies lexical units in a source statement  Classifies units into different classes e.g. id’s, constants, reserved ids etc and enters them into different tables  Token contains Class code and number in class Syntax :Code #no eg : id#10 Example Statement a := b + I; a := b + I ; id#2 op#5 id#3 op#3 id#1 op#10
  • 5.  Determines the statement class such as assignment statement, if stmt etc.  Eg: a,b : real ; and a:=b +I ;
  • 6.  Determines the meaning of the expression  Results in addition of information such as type, length  Determines the meaning of subtree
  • 7. Stmt a:= b + I ; proceeds as 1. Type is added to tree 2. Rules of assignment indicate expression on RHS should be evaluated first 3. Rules of addition indicate I should be converted before addition
  • 8.  A context-free grammar (CFG) G is a quadruple (N, Σ, P, S) where  N: a set of non-terminal symbols  Σ: a set of terminals ( N ∩ Σ = Ǿ)  P: a set of rules (P: N → (N U Σ)*)  S: a start symbol.
  • 9. N = {Q, F,} Σ = {0, 1} P = {Q → 11Q, Q→ 00F, F → 11F, F→ ε } S = q to generate 110011 Q →11Q →1100F →110011F →110011ε
  • 10.  They provide a precise mathematical definition that clearly rules out certain types of language.  The formal definition means that context free grammars are computationally TRACTABLE--it is possible to write a computer program which determines whether sentences are grammatical or not.  They provide a convenient visual notation for the structure of sentences (the tree).
  • 11.
  • 12.  Goal of parser : build a derivation  Top-down parser : build a derivation by working from the start symbol towards the input.  Builds parse tree from root to leaves  Builds leftmost derivation  Bottom-up parser : build a derivation by working from the input back toward the start symbol  Builds parse tree from leaves to root  Builds reverse rightmost derivation
  • 13.  Consider the grammar: S → c A d A → ab | a The input string is “cad”
  • 14. Given the grammar : E → TE’ E’ → +TE’ | λ T → FT’ T’ → *FT’ | λ F → (E) | id The input: id + id * id
  • 15.
  • 16. STACK INPUT BUFFER ACTION $ num1+num2*num3$ shift $num1 +num2*num3$ reduc $F +num2*num3$ reduc $T +num2*num3$ reduc $E +num2*num3$ shift $E+ num2*num3$ shift $E+num2 *num3$ reduc $E+F *num3$ reduc $E+T *num3$ shift E+T* num3$ shift E+T*num3 $ reduc E+T*F $ reduc E+T $ reduc E $ accept E -> E+T | T | E-T T -> T*F | F | T/F F -> (E) | id | -E num
  • 17. Parsing 17  A parse tree is created from root to leaves  The traversal of parse trees is a preorder traversal  Tracing leftmost derivation  Two types:  Backtracking parser  Predictive parser  A parse tree is created from leaves to root  The traversal of parse trees is a reversal of post order traversal  Tracing rightmost derivation  More powerful than top- down parsing  LR parserBacktracking: Try different structures and backtrack if it does not matched the input Predictive: Guess the structure of the parse tree from the next input