COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Bottom-up
|
|
Top-down
|
|
Both the options
|
|
None of the mentioned
|
Detailed explanation-1: -A top-down parser cannot handle left recursive productions. To understand why not, let’s take a very simple left-recursive grammar. There is only one token, a, and only one nonterminal, S. So the parsing table has just one entry.
Detailed explanation-2: -Left recursion often poses problems for parsers, either because it leads them into infinite recursion (as in the case of most top-down parsers) or because they expect rules in a normal form that forbids it (as in the case of many bottom-up parsers, including the CYK algorithm).
Detailed explanation-3: -Recursive descent is a top-down parsing technique that constructs the parse tree from the top and the input is read from left to right. It uses procedures for every terminal and non-terminal entity. This parsing technique recursively parses the input to make a parse tree, which may or may not require back-tracking.
Detailed explanation-4: -Bottom up parsers can handle either left-recursive or right-recursive grammars. A bottom-up parser repeatedly finds a handle A→ in current right-sentential form and replaces with A. If G is unambiguous, then every right-sentential form has a unique handle.
Detailed explanation-5: -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.