835 views
4 votes
4 votes

Suppose we have a rightmost derivation which proceeds as follows:
$\begin{array}{ccc}S &\rightarrow & Aabw \\ & \rightarrow &ABw \end{array}$
Which of the following is a possible handle for it?

  1. $\begin{array}{ccc} A &\rightarrow & ab \end{array}$
  2. $\begin{array}{ccc} A &\rightarrow & a \end{array}$
  3. $\begin{array}{ccc} S &\rightarrow & A \end{array}$
  4. $\begin{array}{ccc} B &\rightarrow & ab \end{array}$

2 Answers

Best answer
6 votes
6 votes
Ans is D .

Handle is part of the string in sentential form that will be reduced to non-terminal i.e left hand side of a production

In the above derivation, sentential form Aabw is reduced to ABw so has to be a production with B --> ab and that is the handle at this point of derivation.
selected by
0 votes
0 votes

A handle is a reduction that would allow future reductions to reach back to the start symbol. We only want to reduce at handles in Bottom Up Parsing.

Here, $B\rightarrow ab$ is a handle. Because by doing so, we reach $Aabw$, through which we finally reach S.

Option D

Answer:

Related questions

6 votes
6 votes
2 answers
4
Arjun asked Jan 26, 2019
1,693 views
If we merge states in LR(1) parser to form a LALR(1) parser, we may introduceshift-reduce conflictreduce-reduce conflictno extra conflictboth shift-reduce as well as redu...