Compiler Design Left factoring

Enter Name of Correspondence Set, Page Number, Question Number, Your Name and Roll Number for Query!

Moderator: CS Moderators Team

Compiler Design Left factoring

Postby arnab77 » Fri Nov 29, 2013 10:51 pm

Consider the grammar over symbols a and b:

rexpr -> rexpr + rterm | rterm
rterm -> rterm rfactor | rfactor
rfactor -> rfactor* | rprimary
rprimary -> a|b


1. Left factor the grammar
2. Eleminate left recursion
3. Is resulting grammar suitable for top-down parsing?

Please solve the question. Thanks
User avatar
arnab77
 
Posts: 4
Joined: Wed Jul 17, 2013 8:17 pm
Currently what are you doing?: Am Studying
My College/Company:: Techno India College
Roll Number: 27420081
Packages: Classroom Coaching (CL)
City: Kolkata

Re: Compiler Design Left factoring

Postby sameer2009 » Wed Dec 04, 2013 10:59 am

eliminating left recursion
rexpr -> rexpr + rterm | rterm

rexpr -> rtermA
A -> +rtermA | e

===================================================
eliminating left recursion
rterm -> rterm rfactor | rfactor

rterm -> rfactorB
B -> rfactorB | e

===================================================
rfactor -> rfactor* | rprimary ...can be written as

C -> rfactorC | e
rfactor -> rprimary

===================================================
rprimary -> a|b
===================================================
Using production in blue, parsing table can be constructed and no entries in table are having multiple values, so LL(1)
Check this out!!! Free Android App for Computer Science and Engineering Exam.
Download .apk file @ tinyurl.com/csexamapp
See How To Use @ tinyurl.com/csexamapplication
sameer2009
Gatementor Guru
Gatementor Guru
 
Posts: 1433
Joined: Tue Sep 09, 2008 5:29 pm
My College/Company:: lt
Roll Number: 99999

Re: Compiler Design Left factoring

Postby arnab77 » Thu Dec 05, 2013 9:52 am

Thanks
User avatar
arnab77
 
Posts: 4
Joined: Wed Jul 17, 2013 8:17 pm
Currently what are you doing?: Am Studying
My College/Company:: Techno India College
Roll Number: 27420081
Packages: Classroom Coaching (CL)
City: Kolkata


Return to CS Question

Who is online

Users browsing this forum: No registered users and 6 guests
cron