Consider the following grammar S AB B BaAC c A Ca C b App

Consider the following grammar:

S AB

B BaAC | c

A Ca |

C b |

Apply left-recursion elimination to this grammar

Solution

We have left recursion in

B -> BaAC | c

This can be rewritten as:

B -> cB\'

B\' -> B\'aAC |

So the whole grammer wil be :

S -> AB

B -> cB\'

B\' -> B\'aAC |

A -> Ca |

C -> b |

Consider the following grammar: S AB B BaAC | c A Ca | C b | Apply left-recursion elimination to this grammarSolutionWe have left recursion in B -> BaAC | c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site