COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
|
|
|
|
Either A or B
|
|
None of the above
|
Detailed explanation-1: -Left factoring transforms the grammar to make it useful for top-down parsers. In this technique, we make one production for each common prefixes and the rest of the derivation is added by new productions. Example. The above productions can be written as A => A’ A’=> | | …
Detailed explanation-2: -Left recursion and left factoring removal technique. Left Recursion. The production is left-recursive if the leftmost symbol on the right side is the same as the non-terminal on the left side. For example, expr → expr + term.
Detailed explanation-3: -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.
Detailed explanation-4: -Left factoring is removing the common left factor that appears in two productions of the same non-terminal. It is done to avoid back-tracing by the parser.