**Handle:**

A substring α of the tree’s upper frontier that matches some production A → α where reducing α to A is one step in the reverse of a rightmost derivation. We call such a string a handle.

Formally,

a handle of a right-sentential form γ is a production A → β and a position in γ where β may be found and replaced by A to produce the previous right-sentential form in a rightmost derivation of γ i.e.,

if S ⇒∗_{ rm} αAw ⇒_{rm} αβw then A → β in the position following α is a handle of αβw

Because γ is a right-sentential form, the substring to the right of a handle contains only terminal symbols.

This all is the formal definition.

Informally you can understand handle like this:

for a given production, if a string is given to reduce, you start replacing the string with the right-hand side of production, the item that is removed or replaced is called handle. Reduce the given string until you get the start symbol.

example:

1. **S -> aABe**

** A-> Abc /b**

** B-> d**

The string is** abbcde** find the handles.

Solution:-

abbcde

aAbcde // after replacing the second 'b' with 'A' from left So b is one of handle

aAde // after replacing 'Abc' with A So Abc is the second handle.

aABe // after replacing 'd' with 'B' So, 'd' is third handle.

S // after replacing 'aABe' with 'S', So 'aABe' is fourth handle.

**2. E -> E+n / E * n / n**

find the handles for** n+n*n**

**Solution: **

n+n*n

E+n*n // replace first n with E so n is first handle.

E*n // replace E+n with E so E+n is the second handle.

E // replace E*n with E so E*n is third handle.

So handles are n, E+n , E*n

## Pages