0 ratings0% found this document useful (0 votes) 21 views10 pagesTD Predictive Parser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
OG
Predictive Parser in Compiler Design
3 tanushree7252
Read Discuss
In this, we will cover the overview of Predictive Parser and mainly focus on the role of
Predictive Parser. And will also cover the algorithm for the implementation of the Predictive
parser algorithm and finally will discuss an example by implementing the algorithm for
precedence parsing. Let's discuss it one by one.
\
se racng en Bacracting
ae
i
Job Fair For Students TrendingNow DSA Data Structures Algorithms Interview Preparation Data Scien
Preaictive Parser :
A predictive parser is a recursive descent parser with no backtracking or backup. It is a top-
down parser that does not require backtracking. At each step, the choice of the rule to be
expanded is made upon the next terminal symbol.
Consider
A> aL [Ar]... [an
If the non-terminal is to be further expanded to ‘A’, the rule is selected based on the current
We use cookies to ensure you have the best browsing experience on our website. By using our site, Got It!
you acknowledge that you have read and understood aur Cookie Polley & Privacy PolicyPredictive Parser Algorithm :
1. Make a transition diagram(DFA/NFA) for every rule of grammar.
2. Optimize the DFA by reducing the number of states, yielding the final transition diagram.
3. Simulate the string on the transition diagram to parse a string.
4, If the transition diagram reaches an accept state after the input is consumed, it is parsed.
Consider the following grammar —
E-DE4T|T
T->T#F|F
F->(E) Lid
After removing left recursion, left factoring
ETT!
TiooatT' |e
T->eT"
THoseT fe
F->(E) Lid
‘STEP 1:
Make a transition diagram(DFA/NFA) for every rule of grammar.
© E>TT
We use cookies to ensure you have the best browsing experience on our website. By using our site,
you acknowledge that you have read and understood aur Cookie Polley & Privacy PolicyStart I
+ T4TTe
* T-5FT”
We use cookies to ensure you have the best browsing experience on our website. By using our ste,
you acknowledge that you have read and understood our Cookie Poley & Privacy Policy° TFT
* FS(Ellid
ookes to ent
fe you have the best browsing experience on our webs!
By using our ste,
you acknowledge that you have read and understood our Cookie Polley & Privacy Policyia
STEP
Optimize the DFA by decreases the number of states, yielding the final transi
© TsTT le
Optimized
We use cookies to ensure you have the best browsing experience on our website. By using our sk,
you acknowledge that you have read and understood our Cookie Polley & Privacy PolicyYeilds
Accordingly, we optimize the other structures to produce the following DFA
+
Start
-
Final
We use cookies to ensure you have the best browsing experience on our website. By using our ste,
you acknowledge that you have read and understood our Cookie Poley & Privacy PolicySTEP 3:
Simulation on the input string,
Steps involved in the simulation procedure are:
1. Start from the starting state.
2. If a terminal arrives consume it, move to the next state
3. If a non-terminal arrive go to the state of the DFA of the non-terminal and return on
reached up to the final state.
4, Return to actual DFA and Keep doing parsing.
5. If one completes reading the input string completely, you reach a final state, and the
string is successfully parsed.
Last Updated : 18 Mar, 2021 B
Similar Reads
1. _ Difference between Recursive Predictive Descent Parser and Non-Recursive Predictive Descent
Parser
2. Compiler Design SLR(1} Parser Using Python
3. Incremental Compiler in Compiler Design
4. Shift Reduce Parser in Compiler
5. Difference between Native compiler and Cross compiler
We use cookies to ensure you have the best browsing experience on our website. By using our sie,
you acknowledge that you have read and understood our Cookie Polley & Privacy Policy7. Error Recovery in Predictive Parsing
8. Why FIRST and FOLLOW in Compiler Design?
9. Compiler Design | Syntax Directed Definition
10. Loop Optimization in Compiler Design
Previous Next
Article Contributed By :
tanushree7252
@tanushree7252
Vote for difficulty
Current difficulty : Medium
Easy Normal Medium == Hard Expert
Article Tags: Compiler Design, GATE CS
—___
=<
oS GeeksforGeeks
‘A-143, Sth Floor, Sovereign Corporate Tower,
Sector-136, Noida, Uttar Pradesh - 201305
feedback@[Link]
Company Explore
se cookies to ensure you have the best browsing experience on our website. By using our ste,
you acknowledge that you have read and understood our Cookie Polley & Privacy PolicyCareers
in Media
Contact Us
Terms and Conditions
Privacy Policy
Copyright Policy
Third-Party Copyright Notices
Advertise with us
Languages
Python
Java
cH
GoLang
sql
R Language
Android Tutorial
Algorithms
Sorting
Searching
Greedy
Dynamic Programming
Pattern Searching
Recursion
Backtracking
Data Science & ML
Data Science With Python
Data Science For Beginner
Machine Learning Tutorial
Maths For Machine Learning
Pandas Tutorial
GfG Weekly #100
POTD: Revamped
Python Backend LE
Android App Development
DevOps LIVE
DSA in JavaScript
Data Structures
Array
String
Linked List
Stack
Queue
Tree
Graph
Web Development
HTML
css
JavaScript
Bootstrap
Reacts
AngulardS
Nodes
Interview Corner
Company Preparation
Preparation for SDE
Company Interview Corner
Experienced Interview
Internship Interview
We use cookies to ensure you have the best browsing experience on our website. By using our ste,
you acknowledge thal you have read and understood our Cookie Poley & Privacy Policyyou acknowledge th
Python
Python Tutorial
Python Programming Examples
Django Tutorial
Python Projects
Python Tkinter
Opencv Python Tutorial
UPSC/SSC/BANKING
[Link] Syllabus
81 PO Syllabus
BPS PO syllabus
UPSC Ethics Notes
UPSC Economics Notes
UPSC History Notes.
@geeksforgeeks , Some right
GfG School
CBSE Notes for Class 8
CBSE Notes for Class 9
CBSE Notes for Class 10
CBSE Notes for Class 11
CBSE Notes for Class 12
English Grammar
Write & Earn
Write an Article
Improve an Article
Pick Topics to Write
Write Interview Experience
Internships
Video internship
We use cookies to ensure you have the best browsing experience on our website. By using our ste,
you have read and understood our Cookie Polcy & Privacy Policy