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!

sid99,
your question is and grammar is confusing.
What is this grammar trying to describe?

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?

(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.

np I figured it out before hand but thanks!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.