Nikul Vyas
Nikul Vyas

Reputation: 363

How to make a parse tree from Follow() set in LL parsing?

I was given the question for test: Show the parse tree of a string proving that b is in the follow of T.

S=> ET
T=>bSc | d
E=>aTE| ε

I solved the First set :

First(S)=>First(E)=>{a} U First(T)=> {a,b,d}
First(T)=>{b,d}
First(E)=>{a,ε}

And the Follow set :

Follow(S)=>{$,c}
Follow(T)=>Follow(S) U First(E)=> {$,c} U First(E)=>{$,c,a}
Follow(E)=>First(T) U Follow(E)=>{b,d}

Where I am going wrong ?

Upvotes: 0

Views: 63

Answers (1)

rici
rici

Reputation: 241671

You wrote:

Follow(T) ⇒ Follow(S) ∪ First(E)

But ε is in First(E), so that should be:

Follow(T) ⇒ Follow(S) ∪ First(E) ∪ Follow(E)

Upvotes: 1

Related Questions