Questions: Shift-Reduce Bottom-Up Parsing

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A grammar rule is left-recursive: Expr → Expr + Term. Which parser type handles this correctly, and why?

ATop-down (LL) parsers, because they predict rules before consuming input
BBoth equally well, since left recursion is handled by all modern parsers
CBottom-up (LR/shift-reduce) parsers, because they accumulate tokens and defer reduction decisions
DNeither; left-recursive grammars must always be refactored before parsing
Question 2 Multiple Choice

During shift-reduce parsing of the expression '3 * 5 + 2', the parser has Expr on the stack and '+' as the next token. What should it do?

AImmediately reduce Expr to a higher-level nonterminal
BShift '+' onto the stack, because reducing now would discard context needed for precedence
CReport a shift-reduce conflict and halt
DBacktrack to try a different reduction sequence
Question 3 True / False

Shift-reduce parsers discover the rightmost derivation of an input, but in reverse order.

TTrue
FFalse
Question 4 True / False

A shift-reduce parser can backtrack when it makes a wrong shift or reduce decision.

TTrue
FFalse
Question 5 Short Answer

Explain why bottom-up (shift-reduce) parsing is described as 'more powerful' than top-down (LL) parsing.

Think about your answer, then reveal below.