1. Place $ in follow(S)
2. If there is a production A
a B ß then everything in first( ß ) (except ε ) is in follow(B)
3. If there is a production A
a B
then everything in follow(A) is in follow(B)
4. If there is a production A
a B ß
and First( ß ) contains e
then everything in follow(A) is in follow(B)
Since follow sets are defined in terms of follow sets last two steps have to be repeated until follow sets converge
To compute FOLLOW ( A ) for all non-terminals A , apply the following rules until nothing can be added to any FOLLOW set:
1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input right endmarker.
2. If there is a production A
a Bß, then everything in FIRST(ß) except for e is placed in FOLLOW(B).
3. If there is a production A
a ß, or a production A
a Bß where FIRST(ß) contains e (i.e., ß
* e ), then everything in FOLLOW(A) is in FOLLOW(B).