For example,
Let the Grammar be:
S->Sa|B
Thus, S->Sa->Saa->...->Saa...aaa->Baa...aaa
What's wrong with this?
Why is right recursion a solution to the problem?
S->BS'
S->aS'|e
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityFor example,
Let the Grammar be:
S->Sa|B
Thus, S->Sa->Saa->...->Saa...aaa->Baa...aaa
What's wrong with this?
Why is right recursion a solution to the problem?
S->BS'
S->aS'|e
I am assuming that you are talking about context free grammars.
There is no difference between the two grammars. They are a different representation of the same set.
What do you mean by a problem?
Left recursion is a problem for LL(k) parsers, but they can handle right recursion. LL(k) parsers are preferred because of they use less stack space and they tend to be faster (not always though).