简体   繁体   中英

Confusion in finding follow of Gammar

I have confusion in finding follow of Grammar

S->(L)|a
L->L,S|S

Follow(L)={$,} or Follow(L)= {$}
Which one is right and why?

Both are incorrect.

FOLLOW(A) of non-terminal A is the set of terminal symbols 
that can follow in the derivation sequence

FOLLOW(L), check where it appears in the right hand side of productions. It is there in

             S->(L)  

when this production is considered for derivation, what follows L is ).

            L->L,S

similarly, when this production is considered for derivation, what follows L is,.

           FOLLOW(L) = {),,}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM