Parsing & Syntax Analysis

Answer & solution
Official answer: D
Method: distinguish the left-to-right scan of the input from the order of grammar productions reconstructed by reductions.
1. LR parsing is bottom-up. A reduction replaces a handle, a right-hand side of a production, by its left-hand-side nonterminal.
2. This operation undoes a production application rather than applying it from the start symbol outward. Therefore the derivation is reconstructed in reverse.
3. The handles reduced by an LR parser are exactly those obtained by reversing a rightmost derivation. For example, with S → AB, A → a, B → b, a rightmost derivation is S ⇒ AB ⇒ Ab ⇒ ab. Reversing it gives ab ⇒ Ab ⇒ AB ⇒ S, the bottom-up reduction sequence.
4. In the name LR, L denotes scanning input left-to-right and R denotes reconstructing a rightmost derivation. The L does not mean leftmost derivation.
Result: D, a rightmost derivation in reverse.