Topic: Compiler Design / Parsing
Eliminating immediate left recursion from $A \rightarrow A\alpha \mid \beta$ yields
- A. $A \rightarrow a A'$
- B. $A \rightarrow \beta \alpha^*$
- C. $A \rightarrow \beta A', A' \rightarrow \alpha A' \mid \epsilon$
- D. $A \rightarrow \alpha \mid \beta$
Answer: C. $A \rightarrow \beta A', A' \rightarrow \alpha A' \mid \epsilon$
Explanation: Immediate left recursion of the form $A \rightarrow A\alpha \mid \beta$ can be eliminated by introducing a new non-terminal (e.g., $A'$). The equivalent right-recursive productions are $A \rightarrow \beta A'$ and $A' \rightarrow \alpha A' \mid \epsilon$. This preserves the language (which is $\beta\alpha^*$) while allowing top-down parsers to process it without entering an infinite loop.