Consider the following grammar: P → xQRS Q → yz |z R → w | ε S → y What is FOLLOW(Q)?
Consider the following grammar: P → xQRS Q → yz |z R → w | ε S → y What is FOLLOW(Q)? Correct Answer {w, y}
Concept:
Follow(X) is the set of terminals that can appear immediately to the right of non-terminal X in some sentential form. Rules for finding the follow (X) are given here as:
1) Follow (S) = {$}, where S is the start symbol.
2) If A → bBC is the production, where b, B and C are grammar symbols, then Follow (B) is first (C).
3) If A → bB is production then follow (B) is follow (A).
4) If A → bBC is production and first(c) contains ε, then follow (B) contains {first (C) - ε} U follow (A).
Explanation:
Follow (Q) = First (RS) = {w, ε} = {w}, First (S) = {w, y}
Diagram:
মোঃ আরিফুল ইসলাম
Feb 20, 2025