COMPUTER SCIENCE AND ENGINEERING
COMPILER DESIGN
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Left Recursion (LR)
|
|
Left Factoring (LF)
|
|
Both LR and LF
|
|
only LR
|
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: -In short, top-down parsers usually try to guess what to do from limited information about the string. Because of this, they get confused by left recursion because they can’t always accurately predict which productions to use.
Detailed explanation-3: -Drawback of Top-Down Parsing The reason that top-down parsing follow the left-most derivation for an input string and not the right-most derivation is that the input string is scanned by the parser from left to right, one symbol/token at a time.
Detailed explanation-4: -Detailed Solution. The correct answer is option 4. Concept: Option 1: Top-down parsers are equipped to handle left recursive grammar.