Alternative version of algorithm (using above rules):
-- initialize:
for each terminal symbol t, FIRST[t] ← {t}
for each nonterminal symbol X, FIRST[X] ← FOLLOW[X] ← {}
repeat
for each prodution X → γ
if γ is nullable, nullable[X] ← true
until nullable is not changed by the inner for loop
-- compute FIRST, FOLLOW:
repeat
for each prodution X → γ
for each symbol Y in γ and strings α, β where X → α Y β
if α is nullable, FIRST[X] ← FIRST[X] ∪ FIRST[Y]
if Y is a nonterminal, then
if β is nullable, FOLLOW[Y] ← FOLLOW[Y] ∪ FOLLOW[X]
if β = β1β2 where β1 is nullable, FOLLOW[Y] ← FOLLOW[Y] ∪ FIRST(β2)
until FIRST and FOLLOW do not change throughout an iteration