edited by
5,192 views
1 votes
1 votes
How to find FIrst and Follow in following case?
S -> aAbB | bAaB | epsilon
A -> S
B -> S

I am little confused because of the production A->S, does it say that Follow(A) is subset of Follow(S) or Follow(S) is subset of Follow(A) or both are equal?
edited by

7 Answers

0 votes
0 votes
First(S)={a,b,epsilon}

First(A)={a,b,epsilon}

First(B)={a,b,epsilon}

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

Follow(A)={a,b}

Follow(B)={$,a,b}
0 votes
0 votes
  a b $
S S-->aAbB S-->bAaB S--e
A

A-->S

A--->e

A--->S

A--->e

 
B B-->S B-->S B---e
0 votes
0 votes

Posting the answer late, but i think it will help others who will land up to this question. 

               a                b           $
  S

S → aAbB

S → ε

S → bAaB

S → ε

S → ε
  A A → S A → S  
  B B → S B → S B → S

 

Thus, from the above table entries we can see that their are two entires where we have multiple productions. Hence 2 is the answer.

Related questions

1 votes
1 votes
1 answer
1
Mk Utkarsh asked Feb 1, 2018
2,632 views
Find First and Follow of the given grammar$S \rightarrow aSa | bSb|A$$A \rightarrow aBb$$B \rightarrow aB|bB|\epsilon$
0 votes
0 votes
1 answer
2
Subhrangsu asked Apr 15, 2022
2,022 views
Compute FIRST and FOLLOW sets:S→ aAC | bBA→ Abc| Abd | eB→ f | gC→ h | i
1 votes
1 votes
0 answers
3
aditi19 asked May 12, 2019
1,648 views
why do first sets can have epsilon symbol but follow sets don’t?P.S: I’ve a silly doubt :P
0 votes
0 votes
1 answer
4
saumya mishra asked Jun 3, 2018
3,111 views
Find first and follow of the given grammar?S->ABA->BS/a/€B->AS/b