0
$\begingroup$

While removing null production from cfg as below,

   S->ABC
   A->aA|^
   B->bB|^
   C->aaC|^

now as shown above we know that A,B and C all are nullable that makes S also nullable. like I'd do as below:

   S->ABC|AB|AC|BC|A|B|C|^
   A->aA|a
   B->bB|b
   C->aaC|aa

The question is how do I remove null from S? I tried searching but I everything getting mixed up....

Like one solution was defining new rule. I can't find the link now but it told to do something like below We have only one null production left...

S->^

to remove null from the method was

S->T
T->^

but the problem is S now become nullable production and there in still null production in the grammar i-e T->^

Another solution was to make new rule (as below) such that at least starting symbol is not null production but from my understanding its still nullable... There still exists a null in the grammar.

S1->S
S->^

Thankyou in Advance

$\endgroup$
4
  • $\begingroup$ Well, what is stopping you from removing the null production of $S$ ? $\endgroup$
    – Rinkesh P
    May 14 at 14:28
  • $\begingroup$ We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. We prefer questions about a specific conceptual issue you're uncertain about. As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. $\endgroup$
    – D.W.
    May 15 at 6:57
  • $\begingroup$ @RinkeshP I don't know how to do that.... If I introduce another grammar production rule like T->^ (let's take only null production from the above grammar) S->T T->^ This is still nullable production... Is there any other method I don't know of ? I'd like to know more about how am I to remove null production completely Thankyou! $\endgroup$
    – Zoha Javed
    May 15 at 15:39
  • $\begingroup$ @D.W. oh Thankyou for guiding me correctly, I realized I didn't ask clearly what I wanted to know about . I'm going to edit it correct way! Thanks once again $\endgroup$
    – Zoha Javed
    May 15 at 15:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.