COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
E
|
|
E
|
|
E
|
|
E
|
Detailed explanation-1: -A Grammar G (V, T, P, S) is left recursive if it has a production in the form. A → A |. Left Recursion can be eliminated by introducing new non-terminal A such that. This type of recursion is also called Immediate Left Recursion.
Detailed explanation-2: -Left recursion is eliminated by converting the grammar into a right recursive grammar.
Detailed explanation-3: -If you have left-recursion, then the parser goes into an infinite recursion. However, in right-recursion, the parser can see the prefix of the string that it has so far. Thus, it can check whether the derivation went “too far".
Detailed explanation-4: -A grammar in the form G = (V, T, S, P) is said to be in left recursive form if it has the production rules of the form A → A |. In the production rule above, the variable in the left side occurs at the first position on the right side production, due to which the left recursion occurs.