Home » Compiler Design » Compiler design miscellaneous » Question

Compiler design miscellaneous

  1. Which of the following describes a handle (as applicable to LR-parsing) appropriately?
    1. It is the position in a sentential form where, the next shift or reduce operation will occur
    2. It is non-terminal whose production will be used for reduction in the next step
    3. It is a production that may be used for reduction in a future step along with a position in the sentential form where, the next shift or reduce operation will occur
    4. It is a production p that may be used for reduction in a future step along with a position in the sentential form where, the right hand side of the production may be found.
Correct Option: D

It is a production p that may be used for reduction in afuture step along with a position in the sentential form where, the right hand side of the production may befound. A “handle” of a string is a substring that matches the RHS of a production and whose reduction to the nonterminal (on the LHS of the production) represents one step along the reverse of a rightmost derivation toward reducing to the start symbol. If S → * αAw → * αbw, then A → β in the position following a is a handle of αβw. In such a case, it is suffice to say that the substring β is a handle of αβw, if the position of β and the corresponding production are clear. Consider the following grammar: E → E + E | E * E | (E) | id and a right-most derivation is as follows: E → E + E → E + E * E → E + E * id3 → E + id2 * id3 → id1 + id2 * id3



Your comments will be displayed only after manual approval.