The grammar is
View worked solution
Answer: C
To determine the classification of the grammar , we can analyze its LL(1) and LR(1) properties.
1. Checking for LL(1)
A grammar is LL(1) if, for every non-terminal with multiple productions :
- The sets of all alternatives are pairwise disjoint.
- If any production can derive the empty string , its set must be disjoint from the set of .
Let's find the sets for the three alternatives of :
Since the sets , , and are pairwise disjoint, and there are no -productions, there are no FIRST/FIRST or FIRST/FOLLOW conflicts. Therefore, the grammar is LL(1).
2. Checking for LR(1)
A fundamental theorem in compiler design states that every LL(1) grammar is also an LR(1) grammar (i.e., ). Since the grammar is LL(1), it is guaranteed to be LR(1).
Thus, the grammar is both LL(1) and LR(1).
Free practice · Your answers on this page are not saved.
