in Compiler Design edited by
596 views
2 votes
2 votes

in Compiler Design edited by
596 views

3 Comments

option d is correct
0
0
Answer is option D.

First remove left recursion of B and D. and then calculate.
0
0
option D
0
0

3 Answers

2 votes
2 votes
Best answer

hope this helps 

selected by
1 vote
1 vote
From the first production: A -> BCD : Follow(B) = First(C) = {y,m}                                                        -----(1)

From the second production: B -> w / Bx : Follow(B) = {x}                                                                   ------(2)

From the third production: C -> yCz / m : B is not present here, so it is not of any concern here.        -----(3)

And the last production: D -> DB / a : Follow(B) = Follow(D) = First(B) and Follow(A). = {w,\$}

Hence, from 1, 2, 3 and 4
Follow(B) =  {y,m,x,w,\$}
0 votes
0 votes
$follow(B)=first(C)\cup first(x)\cup follow(D)$

$follow(B)=(y,m)\cup (x)\cup first(B)\cup first(A)$

$follow(B)=(y,m,x,w,\$)$

Option (D) is correct here.