in Compiler Design retagged by
1,277 views
0 votes
0 votes

To avoid left recursion can we do like this. I think this is incorrect way to do

in Compiler Design retagged by
1.3k views

1 Answer

0 votes
0 votes
If the grammar is of the form A ->  A alpha / beta;

then it is causing left recursion . To remove the left recursion do the steps as follows.

A ->beta A';

A' -> alpha A';

A' -> epsilon;

example:  E -> E+T/T

                T -> T*F/F

                F -> id

first two stmts contains left recusion so remove it

here A=E; alpha=+T and beta=T so,

E -> TE'

E' ->+TE'/epsilon

T -> FT'

T -> *FT'/epsilon

1 comment

Yes you are correct! But I am asking as in book  they are mentioning, just reverse the production. is it right or wrong because to remove ambiguity it is incorrect way to do.
0
0