Handles
A “handle” of a string is a substring that matches the RHS of a production and whose reduction to the non-terminal (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 →* αβw, then A → β in the position following α 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
The id’s are subscripted for notational convenience.
Note that the reduction is in the opposite direction from id1 + id2 * id3 back to E, where the handle at every step is underlined.
Comments
Post a Comment