in Compiler Design retagged by
3,104 views
0 votes
0 votes
Find first and follow of the given grammar?

S->AB

A->BS/a/€

B->AS/b
in Compiler Design retagged by
3.1k views

1 comment

first (S) = {a,b}

first(A) ={a,b,ϵ}

first(B) ={a,b}

follow(S) ={$,a,b}

follow(A)={a,b}

follow (B)= {$,a,b}

1
1

1 Answer

0 votes
0 votes

Check this

4 Comments

You should not remove Left recursion. First and follow operations are defined for any CFG grammar.. You must be confusing them with $LL(1)$ grammar.

Even if the question were for checking $LL(1)$ or not...We shuold not remove left recursion or etc... Just give answer according to the given grammar.
0
0

thanks @ Deepakk Poonia (Dee)  sir, I understood your point. For this question first and follow for given productions came similar after removing left recursion so i got confused but now it is clear that first and follow for the grammar of other examples will be different before and after removing left recursion. So, i should answer according to question shouldn't try to modify it. thanks for pointing out :)

1
1
Could you give some example in which Before and  After removal of Left recursion, first or follow or both becomes different for symbols(variables) in the Original grammar.. ?

As per the definition of First and Follow, It doesn't seem obvious.
0
0
check for this example

E ->E +T/T

T->T*F/F

F->(E)/id
0
0