in Compiler Design retagged by
386 views
0 votes
0 votes

S → aA / CB

A → BaA / epsilon

B → bB / Abc / epsilon

C → B

what is follow of C , FOLLOW(C)?

I think answer is FOLLOW (C) = First(B) = { b, first (A),   (dollar for  epsilon) } = {b, a, $}

Am i right?  

Because i found some where FOLLOW(C) = FOLLOW(B) .  Is this statement correct?   (But I think this is wrong)

PLZ confirm the solution of above doubt………………..!!!!!!!!!!!

in Compiler Design retagged by
386 views

1 comment

Follow (C) is whatever follows C on the RHS of any of the productions. So you are right
0
0

2 Answers

0 votes
0 votes
FOLLOW(C) will be terminals that can come just after C.

Here FOLLOW(C) = { FIRST(B), FOLLOW(S) }

I wrote FOLLOW(S) because B can be epsilon, thus making S ->aA / C, thus FOLLOW(S) is included in FOLLOW(C)

FIRST (B) will give you {b, FIRST(A)}.. and FIRST(A) is also b,

therefore FOLLOW(C)= {b,$}
0 votes
0 votes
Your answer absolutely right .

look at the production rule S---->CB ,

here FOLLOW(C)=FIRST(B) ,but epsilon is also list of FIRST(B) and when we put epsilon in place of B

rule become just like this S---->C and this gives $ for the FOLLOW(C).

beacuse FOLLOW(C)=FOLLOW(S) & FOLLOW(S)= $