0

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!

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by sid99
0

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

0

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?

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.