1,678 views
4 votes
4 votes

Which of the following sentences regarding Viable prefixes is/are CORRECT?

  1. Viable prefixes is the set of prefixes of right-sentential forms that can appear on the stack of a shift-reduce parser
  2. Viable prefixes is the set of prefixes of right-sentential forms that do not extend past the end of the right-most handle
  3. Viable prefixes can be recognized using a DFA
     
    1. Only (i)
    2. Only (ii)
    3. Only (i) and (ii)
    4. (i), (ii) and (iii)

2 Answers

Best answer
2 votes
2 votes

Answer is D.

I : Definition of viable prefix -

Viable prefixes are the prefixes of right sentential forms that do not extend beyond the end of its handle.

i.e. a viable prefix either has no handle or just one possible handle on the extreme RIGHT which can be reduced.

II :  Definition of viable prefix -

viable prefixes are the set of prefixes of right sentential forms that can appear on the stack of a shift­reduce parser

III : The set of all viable prefixes of the right sentential forms of a grammar is a REGULAR LANGUAGE. i.e., viable prefixes can be recognized by using a FINITE AUTOMATA.

So I, II & III are true.

References:

  1. https://gatecse.in/viable-prefixes-and-handle-in-lr-parsing/
  2. https://web.stanford.edu/class/archive/cs/cs143/cs143.1128/handouts/100%20Bottom-Up%20Parsing.pdf
selected by
1 votes
1 votes

A viable prefix is a legitimate prefix that could lead to a handle.

Since handle will always be found on top of the stack, all the viable prefixes of it can appear below it in the stack. If handle is not found yet, the stack would contain just viable prefixes.

I is true.


Viable prefix can't extend past the handle. That's why it's a prefix!

II is true.


The set of all viable prefixes of a language is a Regular Language, so it can be recognised by a DFA.

III is true.


Option D

Answer:

Related questions

4 votes
4 votes
2 answers
2
Arjun asked Jan 26, 2019
870 views
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 po...
6 votes
6 votes
2 answers
4
Arjun asked Jan 26, 2019
1,731 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...