Redirected
retagged by
1,001 views
0 votes
0 votes

Consider the following CFG, with S as start symbol:
S -> aA l CB
A -> BaA I e
B-> bB l Abc l e
C -> B
 

(HERE ‘e’ IS EPSILON OR NULL PRODUCTION)

  1. FIRST(B)?
  1. FOLLOW(C)?
retagged by

2 Answers

2 votes
2 votes
  First Follows
S    {a,b,epsilon} {$}
A   {epsilon,b} {$,b}
B  {epsilon,b} {a,$}
C  {epsilon ,b} {b,$}

 

Follow of C is what comes after c. So we can see from S -> CB that follow of C= first of B but as B contains epsilon also so follow of C also contains follow of S.

 

edited by
0 votes
0 votes
First (B) = Fi(bB) U Fi(Abc) U Fi(ϵ)   // here U is union and Fi is First

= {(b), Fi(A) U (ϵ)}  

// now Fi(A)= {Fi(BaA) U ϵ}  --------> put B= bB and ϵ , with ϵ you’ll get Fi(aA) = (a)

// So, Fi(A)= {a, b, ϵ}

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

Follow(C)= First(B) = {a, b, ϵ}    

 in  S ->  CB   put B= ϵ then we will consider Fo(S) which is $

so,
Follow(C)=  {a, b, dollar symbol}
edited by

Related questions

2 votes
2 votes
1 answer
3
5 votes
5 votes
1 answer
4
GO Classes asked Jan 21
605 views
Consider the following grammar-$$\begin{aligned}& S \rightarrow b T \\& T \rightarrow A b \mid B a \\& A \rightarrow a S \mid C B \\& B \rightarrow b D \\& C \rightarrow ...