retagged by
909 views

2 Answers

1 votes
1 votes

Viable Prefixes: the prefixes of right sentential forms that can appear on the stack of a shift-reduce parser are called viable prefixes.
OR
A viable prefix is a prefix of a right-sentential form that does not continue past the right end of the rightmost handle of that sentential form. 
Consider the following grammar:
E → E + E
E → E * E
E → ( E )
E → id
String: id+id*id

E --> E+E --> E+E*E --> E+ E * id --> E+id * id --> id+id *id
 

Viable Prefix = {eps, E, E+, E+E, E+E*, E+E*E, E+E*id, E+id,id }

Not all prefixes of right-sentential forms can appear on the stack, however, since the parser must not shift past the handle 


Handle:- 
the handle always appears at the top of the stack just before it is identified as the handle. handle will always be reduced to the LHS part of a production.

In our example, handles will be = id, E+E, E*E

0 votes
0 votes

Handle - Substring which has beeng matched with the right side of production & ready to replced from left side of production. 

Viable Prefixes - Set of all the prefixes of handles which are not handle.

Related questions

3 votes
3 votes
1 answer
1
0 votes
0 votes
1 answer
2
1 votes
1 votes
1 answer
3
kirtikanwar asked Jan 4, 2017
1,004 views
consider the following grammar productionS->XXX->0X|1In the canonical LR method if [X->0•X,0] is an item then which of the following is the viable prefix of the item?a)...
11 votes
11 votes
2 answers
4