For a context free grammar, FOLLOW(A) is the set of terminals that can appear immediately to the right of non-terminal in some "sentential" form. We define two sets LFOLLOW(A) and RFOLLOW(A) by replacing the word "sentential" by "left sentential" and "right most sentential" respectively in the definition of FOLLOW (A).
View worked solution
Answer: A;B
To understand the relationship between , , and , let us analyze how terminals can appear to the right of a non-terminal under different derivations.
1. vs (May be different):
Consider the grammar:
- All sentential forms: . Here, appears immediately to the right of in the sentential form . Thus, .
- Left-sentential forms: In a leftmost derivation, we must expand the leftmost non-terminal first: . The only left-sentential forms are and . In none of these does a terminal appear immediately to the right of . Thus, .
Since in this case, Option A is correct.
2. vs (Always the same):
In any derivation where a terminal appears immediately to the right of (i.e., ), the symbols to the right of must eventually derive terminals. In a rightmost derivation, all non-terminals to the right of are expanded to terminals before itself is expanded. Thus, any sentential form of the type can always be reached via a rightmost derivation. Therefore, always holds, making Option B correct.
Free practice · Your answers on this page are not saved.
