SlideShare a Scribd company logo
Recursive Descent Parsing
Parsing
– The process to determine whether the start symbol
can derive the program.
• If successful, the program is a valid program.
• If failed, the program is invalid.
– Two approaches in general.
• Expanding from the start symbol to the whole
program (top down)
• Reduction from the whole program to start
symbol (bottom up).
Parsing methods
– Top-down parsing
• build the parse tree from root to leave (using
leftmost derivation, why?).
• Recursive descent, and LL parser
– Bottom-up parsing
• build the parse tree from leaves to root.
• Operator precedence parsing, LR (SLR,
canonical LR, LALR).
Recursive Descent Parsing
• Recursive descent parsing is a top-down method of
syntax analysis in which a set recursive procedures to
process the input is executed.
• A procedure is associated with each nonterminal of a
grammar.
• Top-down parsing can be viewed as an attempt to find
a leftmost derivation for an input string.
• Equivalently, it attempts to construct a parse tree for
the input starting from the root and creating the nodes
of the parse tree in preorder.
• Recursive descent parsing involves backtracking.
Example (backtracking)
• Consider the grammar
S → cAd
A→ab|a
and the input string w = cad
• To construct a parse tree for this string using top-
down approach, initially create a tree consisting of a
single node labeled S.
RECURSIVE DESCENT PARSING
Procedure S
procedure S()
begin
if input symbol = ‘c’ then
begin
ADVANCE( );
if A( ) then
if input symbol = ‘d’ then
begin ADSVANCE( ); return true
end
end;
return false
end
Procedure A
procedure A( )
begin
isave := input-pointer;
if input symbol = ‘a’ then
begin
ADVANCE( );
if input symbol = ‘b’ then
begin ADVANCE( ); return true end
end
input-pointer := isave;
/* failure to find ab */
if input symbol = ‘a’ then
begin ADVANCE( ); return true end
else return false
end
RECURSIVE DESCENT PARSING
Ad

More Related Content

What's hot (20)

Recursive Descent Parsing
Recursive Descent Parsing  Recursive Descent Parsing
Recursive Descent Parsing
Md Tajul Islam
 
Types of Parser
Types of ParserTypes of Parser
Types of Parser
SomnathMore3
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
LakshmiSamivel
 
COMPILER DESIGN
COMPILER DESIGNCOMPILER DESIGN
COMPILER DESIGN
Vetukurivenkatashiva
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
Radhakrishnan Chinnusamy
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
sanchi29
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
ASHOK KUMAR REDDY
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
Akhil Kaushik
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
Akshaya Arunan
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
kunj desai
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
Apriori algorithm
Apriori algorithmApriori algorithm
Apriori algorithm
Gaurav Aggarwal
 
Operator precedance parsing
Operator precedance parsingOperator precedance parsing
Operator precedance parsing
sanchi29
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Recursive Descent Parsing
Recursive Descent Parsing  Recursive Descent Parsing
Recursive Descent Parsing
Md Tajul Islam
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
sanchi29
 
Lexical Analysis - Compiler Design
Lexical Analysis - Compiler DesignLexical Analysis - Compiler Design
Lexical Analysis - Compiler Design
Akhil Kaushik
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
kunj desai
 
Operator precedance parsing
Operator precedance parsingOperator precedance parsing
Operator precedance parsing
sanchi29
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 

Similar to RECURSIVE DESCENT PARSING (20)

Parsing (Automata)
Parsing (Automata)Parsing (Automata)
Parsing (Automata)
ROOP SAGAR
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptx
Yusra11491
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
kartikaVashisht
 
Predictive parser
Predictive parserPredictive parser
Predictive parser
Jothi Lakshmi
 
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING & PREDICTIVE PARSING
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING &  PREDICTIVE PARSINGTOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING &  PREDICTIVE PARSING
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING & PREDICTIVE PARSING
SVENISHA
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
انااااااااااااا
اناااااااااااااانااااااااااااا
انااااااااااااا
rawan_z
 
module 2 introduction to syntax analysis
module 2  introduction to syntax analysismodule 2  introduction to syntax analysis
module 2 introduction to syntax analysis
ElakkiaU
 
Parsing
ParsingParsing
Parsing
Dayananda Sagar University
 
compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
RijuMandal11
 
Lecture 24Recursive decent parsing and back tracking.pptx
Lecture 24Recursive decent parsing and back tracking.pptxLecture 24Recursive decent parsing and back tracking.pptx
Lecture 24Recursive decent parsing and back tracking.pptx
LaibaFaisal3
 
Syntactic specification is concerned with the structure and organization of t...
Syntactic specification is concerned with the structure and organization of t...Syntactic specification is concerned with the structure and organization of t...
Syntactic specification is concerned with the structure and organization of t...
vijaya603274
 
Compiler Design in Computer Applications
Compiler Design in Computer ApplicationsCompiler Design in Computer Applications
Compiler Design in Computer Applications
Mohit422982
 
1 compiler outline
1 compiler outline1 compiler outline
1 compiler outline
ASHOK KUMAR REDDY
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
Jabs6
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
Tanzeela_Hussain
 
Parsing (Automata)
Parsing (Automata)Parsing (Automata)
Parsing (Automata)
ROOP SAGAR
 
Lecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptxLecture 12 Bottom-UP Parsing.pptx
Lecture 12 Bottom-UP Parsing.pptx
Yusra11491
 
Syntactic analysis in NLP
Syntactic analysis in NLPSyntactic analysis in NLP
Syntactic analysis in NLP
kartikaVashisht
 
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING & PREDICTIVE PARSING
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING &  PREDICTIVE PARSINGTOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING &  PREDICTIVE PARSING
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING & PREDICTIVE PARSING
SVENISHA
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
Apoorv Diwan
 
انااااااااااااا
اناااااااااااااانااااااااااااا
انااااااااااااا
rawan_z
 
module 2 introduction to syntax analysis
module 2  introduction to syntax analysismodule 2  introduction to syntax analysis
module 2 introduction to syntax analysis
ElakkiaU
 
compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
RijuMandal11
 
Lecture 24Recursive decent parsing and back tracking.pptx
Lecture 24Recursive decent parsing and back tracking.pptxLecture 24Recursive decent parsing and back tracking.pptx
Lecture 24Recursive decent parsing and back tracking.pptx
LaibaFaisal3
 
Syntactic specification is concerned with the structure and organization of t...
Syntactic specification is concerned with the structure and organization of t...Syntactic specification is concerned with the structure and organization of t...
Syntactic specification is concerned with the structure and organization of t...
vijaya603274
 
Compiler Design in Computer Applications
Compiler Design in Computer ApplicationsCompiler Design in Computer Applications
Compiler Design in Computer Applications
Mohit422982
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
Jabs6
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Compier Design_Unit I.ppt
Compier Design_Unit I.pptCompier Design_Unit I.ppt
Compier Design_Unit I.ppt
sivaganesh293
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
Tanzeela_Hussain
 
Ad

More from Jothi Lakshmi (8)

Yoga for beauty
Yoga for beautyYoga for beauty
Yoga for beauty
Jothi Lakshmi
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
Jothi Lakshmi
 
IPV6 ADDRESS
IPV6 ADDRESSIPV6 ADDRESS
IPV6 ADDRESS
Jothi Lakshmi
 
SOA
SOASOA
SOA
Jothi Lakshmi
 
Soa business centric and soap basic
Soa business centric and soap basicSoa business centric and soap basic
Soa business centric and soap basic
Jothi Lakshmi
 
frame relay
frame relayframe relay
frame relay
Jothi Lakshmi
 
external sorting
external sortingexternal sorting
external sorting
Jothi Lakshmi
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
Jothi Lakshmi
 
Ad

Recently uploaded (20)

P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Operations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdfOperations Management (Dr. Abdulfatah Salem).pdf
Operations Management (Dr. Abdulfatah Salem).pdf
Arab Academy for Science, Technology and Maritime Transport
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Odoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo SlidesOdoo Inventory Rules and Routes v17 - Odoo Slides
Odoo Inventory Rules and Routes v17 - Odoo Slides
Celine George
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 

RECURSIVE DESCENT PARSING

  • 2. Parsing – The process to determine whether the start symbol can derive the program. • If successful, the program is a valid program. • If failed, the program is invalid. – Two approaches in general. • Expanding from the start symbol to the whole program (top down) • Reduction from the whole program to start symbol (bottom up).
  • 3. Parsing methods – Top-down parsing • build the parse tree from root to leave (using leftmost derivation, why?). • Recursive descent, and LL parser – Bottom-up parsing • build the parse tree from leaves to root. • Operator precedence parsing, LR (SLR, canonical LR, LALR).
  • 4. Recursive Descent Parsing • Recursive descent parsing is a top-down method of syntax analysis in which a set recursive procedures to process the input is executed. • A procedure is associated with each nonterminal of a grammar. • Top-down parsing can be viewed as an attempt to find a leftmost derivation for an input string. • Equivalently, it attempts to construct a parse tree for the input starting from the root and creating the nodes of the parse tree in preorder. • Recursive descent parsing involves backtracking.
  • 5. Example (backtracking) • Consider the grammar S → cAd A→ab|a and the input string w = cad • To construct a parse tree for this string using top- down approach, initially create a tree consisting of a single node labeled S.
  • 7. Procedure S procedure S() begin if input symbol = ‘c’ then begin ADVANCE( ); if A( ) then if input symbol = ‘d’ then begin ADSVANCE( ); return true end end; return false end
  • 8. Procedure A procedure A( ) begin isave := input-pointer; if input symbol = ‘a’ then begin ADVANCE( ); if input symbol = ‘b’ then begin ADVANCE( ); return true end end input-pointer := isave; /* failure to find ab */ if input symbol = ‘a’ then begin ADVANCE( ); return true end else return false end