26,978 views
67 votes
67 votes

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

10 Answers

0 votes
0 votes
S->Sa/a  here to convert into LL(1) need to be remove left recursive

for this S->ab/a here to convert LL(1) remove left factoring

then if i take a grammer which not having both left recursive and left factoring for example S->AB/a ;A->a,B->epsilon  then but still not parse by LL(1) bcz it is ambiguous so for that we have to be fulfill all three condition then we can convert into LL(1) surely  so D
0 votes
0 votes

A grammar can be LL(1) if it is unambiguous, not left recursive and deterministic.

Options A and B remove left recursion and non-deteminism, but none of them disambiguates the grammar.

 

So, Option D

Answer:

Related questions

26 votes
26 votes
4 answers
1
40 votes
40 votes
3 answers
2
Kathleen asked Sep 17, 2014
19,883 views
Consider the grammar shown below. $S \rightarrow C \ C$$C \rightarrow c \ C \mid d$This grammar isLL(1)SLR(1) but not LL(1)LALR(1) but not SLR(1)LR(I) but not LALR(1)