🎴 Flashcard Mode
Online Test 1 - Compiler | Computer Science(CS)
Card1 / 18
Mastered0
Review0
QuestionClick to flip
Remove the left recursion from the following grammar.
$E \rightarrow Ea|Eb|a|b$
AnswerClick to flip back
A
$E \rightarrow aE'|bE';E'\rightarrow aE'|bE'|\epsilon$
💡 Explanation:
To remove left recursion from E → Ea|Eb|a|b: The left-recursive productions are E → Ea and E → Eb. The new non-terminal E' handles the recursion. Original productions become E → aE'|bE'. The E' productions are E' → aE'|bE'|ε. This eliminates immediate left recursion.