RTUComputer ScienceYr 2024 · Sem 52024

Q4Compiler Design

Question

2 marks

Define Handle.

Answer

A Handle is a substring of the current right-sentential form that matches the RHS of some production and whose reduction to the LHS is a step in the reverse rightmost derivation.

In bottom-up parsing, a handle of a right-sentential form γ is a production A → β and a position in γ where β appears such that: (1) S ⟹*rm αAw and (2) αAw ⟹rm αβw = γ. That is, reducing β to A at that position is a step in the rightmost derivation of γ from the start symbol S.

In shift-reduce parsing, the handle is the string on top of the stack that should be reduced next. Identifying the correct handle at each step is the fundamental problem in bottom-up parsing. LR parsers (SLR, LALR, CLR) use a finite automaton to efficiently locate handles. A right-sentential form may have at most one handle, which uniquely determines the next reduction step.

Back to Paper