Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
View worked solution
Answer: D
The correct option is D.
To understand why, we must consider the limitations of LL(1) grammars and the nature of arbitrary Context-Free Grammars (CFGs):
- Inherent Ambiguity: Some Context-Free Languages (CFLs) are inherently ambiguous (e.g., ). Since any LL(1) grammar must be unambiguous, it is impossible to convert a CFG representing an inherently ambiguous language into an LL(1) grammar by any means.
- Language Class Limitations: The class of LL(1) languages is a strict subset of deterministic Context-Free Languages (DCFLs), which in turn is a strict subset of all Context-Free Languages (CFLs). Therefore, an arbitrary CFG may generate a language that is simply not LL(1)-parsable.
- Heuristic Nature of Transformations: Eliminating left-recursion and performing left-factoring are useful heuristic techniques to resolve specific conflicts in a grammar, but they do not guarantee that the resulting grammar will satisfy the LL(1) conditions (i.e., having disjoint and sets for alternative productions).
Thus, no combination of these local transformations suffices to convert an arbitrary CFG into an LL(1) grammar.
Free practice · Your answers on this page are not saved.
