User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Computer Science and Software Design section within the Software Development category of DaniWeb, a massive community of 374,148 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,461 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Computer Science and Software Design advertiser:
Views: 482 | Replies: 4
Reply
Join Date: May 2008
Posts: 5
Reputation: sid99 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sid99 sid99 is offline Offline
Newbie Poster

Eliminating left recursion on this grammer?

  #1  
May 13th, 2008
I'm very new to this topic so not so good. I'm trying to right this to be right recursive:

Question (1)

A ---> A + B
A ---> C
B ---> B + C
B ---> C
C ---> (A)
C ---> integer

Would it be something like this:

A ---> BA'
A' ---> +BA'
A ---> C

B ---> CB'
B' ---> +CB'
B ---> C

C ---> (A)
C ---> integer


Question (2)

S ---> (L) | a
L ---> L, S | S

This one I really don't have a clue on. I'm assuming that it is the same as writing:

S ---> (L)
s ---> a
L ---> L, S (dont know what the comma means, normally its a terminal symbol)
L ---> S

If someone can please give me a model answer which I can then follow and analyse to get a better understanding. Thanks!
Last edited by sid99 : May 13th, 2008 at 12:10 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Posts: 1
Reputation: knoPeace is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
knoPeace knoPeace is offline Offline
Newbie Poster

Re: Eliminating left recursion on this grammer?

  #2  
May 17th, 2008
sid99,
your question is and grammar is confusing.
What is this grammar trying to describe?
Reply With Quote  
Join Date: May 2008
Posts: 5
Reputation: sid99 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sid99 sid99 is offline Offline
Newbie Poster

Re: Eliminating left recursion on this grammer?

  #3  
May 18th, 2008
Sorry for the confusion. The language is Java. The grammer is to be used in a recursive-decent parser. The grammer has to be re-written to be right recursive. Can anyone help on this topic?
Reply With Quote  
Join Date: Apr 2008
Posts: 14
Reputation: Abzero is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
Abzero Abzero is offline Offline
Newbie Poster

Re: Eliminating left recursion on this grammer?

  #4  
May 26th, 2008
(Ok late; so I doubt this will get looked at!)

Question (1)

A ---> A + B
A ---> C
B ---> B + C
B ---> C
C ---> (A)
C ---> integer

This I think is right:

A --> CA'
A' --> null
A' --> +BA'

B --> CB'
B' --> +CB'

C --> (A)
C --> int


Question (2)

S ---> (L) | a
L ---> L, S | S

-
S --> (L)
S --> a

L --> SL'
L' --> null
L' --> ,SL'


I think that these grammar's match; but its late and I haven't fully checked them.
Reply With Quote  
Join Date: May 2008
Posts: 5
Reputation: sid99 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sid99 sid99 is offline Offline
Newbie Poster

Re: Eliminating left recursion on this grammer?

  #5  
May 27th, 2008
np I figured it out before hand but thanks!!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Computer Science and Software Design Marketplace
Thread Tools Display Modes

Other Threads in the Computer Science and Software Design Forum

All times are GMT -4. The time now is 3:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC