-1
$\begingroup$

Hi I am trying to solve a LL(1) form question for first n follow rule The question is

A::=BC|C
B::=Bd|ef
C::=gh|j

What I have done to eliminate left recursion

A::=CA’
A’::=CB’
A’::=ϵ
B::=efB’
B::=dB’
B’::=ϵ
C::=gh
C::= j

Is it correct?

Thanks guys, it has been solved.

$\endgroup$

closed as unclear what you're asking by D.W., FrankW, vonbrand, Juho, Artem Kaznatcheev Mar 27 '14 at 7:54

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ This question appears to be unsuited for this site because questions of the form: "This is the exercise problem, this is my solution. Please grade!" are not interesting for anyone but you. Please see this related meta discussion. If you want to ask a specific question about a specific part of your attempt, please edit the question accordingly and it may be reopened. Otherwise, you might want to visit Computer Science Chat and get some feedback there. $\endgroup$ – Raphael Mar 27 '14 at 8:38
0
$\begingroup$

The only left-recursive rule is the one for $B$. The nonterminal $A$ produces no problems, $\operatorname{first}(B) = \{ e \}$ while $\operatorname{first}(C) = \{ g, j \}$. So you need to eliminate left recursion for $B$:

\begin{align} B &::= e f B' \\ B' &::= d B' \mid \epsilon \end{align}

$\endgroup$
  • $\begingroup$ So the question is right then what would be first(A)?? It would be first(B)+first(C) ?? $\endgroup$ – Kunj Mar 13 '14 at 19:18
  • $\begingroup$ $\operatorname{first}(A) = \operatorname{first}(BC) \cup \operatorname{first}(C) = \operatorname{first}(B) \cup \operatorname{first}(C) = \{d, e, g, h \}$ $\endgroup$ – vonbrand Mar 13 '14 at 19:23
  • $\begingroup$ confused. as first(B)={e} while first(C)={g,j} then where does {d,h} comes from $\endgroup$ – Kunj Mar 13 '14 at 19:33
  • $\begingroup$ Messed up, sorry (can't edit a comment and see the question) $\endgroup$ – vonbrand Mar 13 '14 at 19:42
  • $\begingroup$ so it should be First(A) = {e,g,j} right? $\endgroup$ – Kunj Mar 13 '14 at 19:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.