Which one of the following kinds of derivation is used by LR parsers?
View worked solution
Answer: D
An LR parser is a bottom-up parser that parses the input from Left-to-right and produces a Rightmost derivation in reverse.
Explanation:
- Bottom-up Parsing: Bottom-up parsers start with the input string and attempt to rewrite (reduce) it back to the start symbol of the grammar.
- Derivation Relation: The sequence of reductions performed by a bottom-up parser corresponds exactly to a rightmost derivation traced in reverse order.
For example, if a rightmost derivation is: the LR parser will perform reductions in the exact reverse order:
Thus, LR parsers use Rightmost derivation in reverse.
Free practice · Your answers on this page are not saved.
