SlideShare a Scribd company logo
PARSER & ITS TYPES
WEEK: 10
LECTURE: 1
Program: BS CS/SE 6th Semester
Course: CS345 COMPILER CONCEPTS
Parsing
• Syntax analyzers follow production rules defined by means of context-free grammar
• How the production rules are implemented results in two types of parsing techniques
Top-Down Parsing
• Parser starts constructing the parse tree from the start symbol
• Transform the start symbol to the input
Input : a + b * c
S → E
E → E + T
E → E * T
E → T
T → id
Input : a + b * c
S → E
→ E * T
→ E * T
→ E + T * T
→ E + T * id
→ E + id * id
→ T + id * id
→ id + id * id
Types of Top-Down Parsing
Cont……
• Recursive Descent Parsing
• Common form of top-down parsing
• Called recursive as it uses recursive procedures to process the input
• Suffers from backtracking.
• Backtracking
• If one derivation of a production fails, syntax analyzer restarts the process using different
rules of same production
• Input string may be processed more than once to determine the right production.
Backtracking Example
S → rXd
S → rZd
X → oa
X → ea
Z → ai
String = read
Predictive Parser
• Capability to predict which production is to be used to replace the input string
• Does not suffer from backtracking
• Components of Predictive Parser
• Uses a stack and a parsing table to parse the input and
generate a parse tree
• stack and the input contains an end symbol $ to denote that
stack is empty and the input is consumed
• parser refers to the parsing table to take any decision
on the input and stack element combination.

More Related Content

PPTX
Top Down Parsing, Predictive Parsing
PPTX
Top down parsing
PPTX
Syntactic Analysis in Compiler Construction
PPTX
3. Syntax Analyzer.pptx
PPTX
Syntax Analysis in Compiler Design
PPT
51114.-Compiler-Design-Syntax-Analysis-Top-down.ppt
PPT
51114.-Compiler-Design-Syntax-Analysis-Top-down.ppt
PPTX
Unitiv 111206005201-phpapp01
Top Down Parsing, Predictive Parsing
Top down parsing
Syntactic Analysis in Compiler Construction
3. Syntax Analyzer.pptx
Syntax Analysis in Compiler Design
51114.-Compiler-Design-Syntax-Analysis-Top-down.ppt
51114.-Compiler-Design-Syntax-Analysis-Top-down.ppt
Unitiv 111206005201-phpapp01

Similar to LECTURE-1 (1).pptx (20)

PPTX
Syntactic specification is concerned with the structure and organization of t...
PPT
Cd2 [autosaved]
PPTX
Syntax Analysis.pptx
PPTX
COMPILER DESIGN LECTURES -UNIT-2 ST.pptx
PDF
Syntax analysis
PDF
07 top-down-parsing
PPT
Ch2 (1).ppt
PDF
CS6660-COMPILER DESIGN-1368874055-CD NOTES-55-150.pdf
PPT
Parsing
PPTX
Top down parsing
PPTX
unit2_cdunit2_cdunit2_cdunit2_cdunit2_cd.pptx
PPTX
Chapter-3 compiler.pptx course materials
PPT
Top down parsing
PDF
CS17604_TOP Parser Compiler Design Techniques
PPT
Lecture 05 syntax analysis 2
PPTX
System Programming Unit IV
PPTX
non-predective parser
PPTX
module 2 introduction to syntax analysis
PDF
Assignment10
PPTX
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING & PREDICTIVE PARSING
Syntactic specification is concerned with the structure and organization of t...
Cd2 [autosaved]
Syntax Analysis.pptx
COMPILER DESIGN LECTURES -UNIT-2 ST.pptx
Syntax analysis
07 top-down-parsing
Ch2 (1).ppt
CS6660-COMPILER DESIGN-1368874055-CD NOTES-55-150.pdf
Parsing
Top down parsing
unit2_cdunit2_cdunit2_cdunit2_cdunit2_cd.pptx
Chapter-3 compiler.pptx course materials
Top down parsing
CS17604_TOP Parser Compiler Design Techniques
Lecture 05 syntax analysis 2
System Programming Unit IV
non-predective parser
module 2 introduction to syntax analysis
Assignment10
TOPDOWN-PREDICTIVE.pptx TOP-DOWN PARSING & PREDICTIVE PARSING
Ad

More from MRKUsafzai0607 (6)

PPTX
Introduction to Machine Learning by MARK
PPTX
Intermediate Code Generator for compiler design
PPTX
LECTURE-2 W12.pptx
PPTX
W16.pptx
PPTX
DBMS Intro.pptx
PPTX
LECTURE-2.pptx
Introduction to Machine Learning by MARK
Intermediate Code Generator for compiler design
LECTURE-2 W12.pptx
W16.pptx
DBMS Intro.pptx
LECTURE-2.pptx
Ad

Recently uploaded (20)

PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
DOCX
573137875-Attendance-Management-System-original
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
introduction to datamining and warehousing
PDF
Digital Logic Computer Design lecture notes
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPT
Project quality management in manufacturing
PPTX
UNIT 4 Total Quality Management .pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Well-logging-methods_new................
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT
Mechanical Engineering MATERIALS Selection
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
573137875-Attendance-Management-System-original
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
OOP with Java - Java Introduction (Basics)
Safety Seminar civil to be ensured for safe working.
Foundation to blockchain - A guide to Blockchain Tech
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Lecture Notes Electrical Wiring System Components
Automation-in-Manufacturing-Chapter-Introduction.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
introduction to datamining and warehousing
Digital Logic Computer Design lecture notes
R24 SURVEYING LAB MANUAL for civil enggi
Project quality management in manufacturing
UNIT 4 Total Quality Management .pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Well-logging-methods_new................
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Mechanical Engineering MATERIALS Selection

LECTURE-1 (1).pptx

  • 1. PARSER & ITS TYPES WEEK: 10 LECTURE: 1 Program: BS CS/SE 6th Semester Course: CS345 COMPILER CONCEPTS
  • 2. Parsing • Syntax analyzers follow production rules defined by means of context-free grammar • How the production rules are implemented results in two types of parsing techniques
  • 3. Top-Down Parsing • Parser starts constructing the parse tree from the start symbol • Transform the start symbol to the input Input : a + b * c S → E E → E + T E → E * T E → T T → id Input : a + b * c S → E → E * T → E * T → E + T * T → E + T * id → E + id * id → T + id * id → id + id * id
  • 5. Cont…… • Recursive Descent Parsing • Common form of top-down parsing • Called recursive as it uses recursive procedures to process the input • Suffers from backtracking. • Backtracking • If one derivation of a production fails, syntax analyzer restarts the process using different rules of same production • Input string may be processed more than once to determine the right production.
  • 6. Backtracking Example S → rXd S → rZd X → oa X → ea Z → ai String = read
  • 7. Predictive Parser • Capability to predict which production is to be used to replace the input string • Does not suffer from backtracking • Components of Predictive Parser • Uses a stack and a parsing table to parse the input and generate a parse tree • stack and the input contains an end symbol $ to denote that stack is empty and the input is consumed • parser refers to the parsing table to take any decision on the input and stack element combination.