I was trying to solve a question for practice, but I met a problem when I tried to compare the sample answer with mine. Here is the grammar before conversion:
E-> S*
S-> SD
S-> D
D-> [D]
D-> x
The start symbol is E
and the other non-terminal symbols are S
and D
.
My answer here is :
E-> S*
S-> DS'
S'-> DS'
S'->
D-> [D]
D-> x
In the sample answer, they don't have S-> DS'
, and E becomes E-> DS'*
. Due to the methods used in the book for removing left recursions,
A -> Aa
A -> b
=> A -> bA'
A' -> aA'
A' ->
there should be a S-> DS'
. I'm now getting confused about this, and maybe I just did not understand this method. Could anyone give me any hints about this? And also could you please tell me the meaning of the star symbol *
here? Thanks a lot!