Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. Which of the following suffices to convert an arbitrary CFG to an LL (1) grammar?
    1. Removing left recursion alone
    2. Factoring the grammar alone
    3. Removing left recursion and factoring the grammar
    4. None of the above
Correct Option: D

Removing left recursion and factoring the grammar do not suffice to convert an arbitrary CFG to LL(1) grammar because: We have following these steps to convert an arbitrary CFG to LL(1) grammar: 1. Remove ambiguity (by taking care of precedence and associatively) 2. Remove Left Recursion (This will come when you remove ambiguity) 3. Make grammar deterministic by Left factoring (In case occur) To convert CFG to LL(1), which is top down parser. If the grammar is ambiguous, is left recursive and has left factoring, then, it is not a LL(1). For LL(1) all the three should be removed.



Your comments will be displayed only after manual approval.