Compiler Design (2170701)

BE | Semester-7   Winter-2018 | 15/11/2018

Q2) (a)

Define the following terms and give suitable example for it.
1.) Handle   2.) Handle Pruning   3.) Left Factoring

Handle :

  • A “handle” of a string is a substring of a string that matche the right side of a production, and whose reduction to the non terminal of the production is one step along reverse of rightmost derivation

Handle pruning :
  • The process of discovering a handle and reducing it to the appropriate Left Hand side non terminal is known as handle pruning.
Right sentential form Handle Reducing production
id1+id2*id3 id1 E --> id
E+id2*id3 id2 E --> id
E+E*id3 id3 E --> id
E+E*E E*E E --> E*E
E + E E + E E --> E + E
E

Left Factoring
  • Left Factoring is a grammar transformation technique. It consists in "factoring out" prefixes which are common to two or more productions. For example, going from: A ? a ß | a ?