How to remove a circular dependency in a FOLLOW set

Consider a short gram chart

S -> Bc | DB
B -> ab | cS
D -> d | epsilon

FIRST Set -

FIRST(S) ={a,c,d}
FIRST(B) = { a,c }
FIRST(D)= { d, epsilon }

in him

Follow(S)={ Follow(B) }

and

Follow(B) ={ c , Follow(S) }

my question is how to solve this circular dependence?

+5
source share
1 answer

This circular dependence should not begin with this. this is the algorithm to search for "follow":

Initialize all of the following groups to {}, except for S, which is init, to {$}.
Although there are changes, for each A∈V do:
  For each Y → αAβ do:
    follow (A) = follow (A) ∪ first (β)
    If β ⇒ * ε, then also: follow (A) = follow (A) ∪ follow (Y)

, :
(S) = {, $}
(B) = {, $}
(D) = {, }

+3

All Articles