• retagged by
17,822 views

2 Answers

30 30 votes

if β | γ is a state of bottom-up parser then β is a viable prefix.
Here β is in stack and γ is yet to be read.
It means, whatever you can see in stack is viable prefix.

What is stack in parsing and how it work ? – check this video for in-depth understanding of stack working in parsing.
Consider this grammar-

S→ aaA | b
A→ b

when u start parsing for "aab" [obviously it belongs to given grammar] u will encounter the following steps

| aab $ (Initially stack is empty)
a | ab $
aa|b $
aab| $
aaA| $
S| $

here viable prefixes are - {eps,a,aa,aab,aaA,S}

I just showed viable prefixes for given string, if we collect all viable prefixes for all strings possible in the grammar then this set is ALWAYS a regular set.
And in usual practice when u draw DFA for bottom-up parser, that DFA is for this regular set (set of all viable prefixes.)

• edited by
1 1 vote
Position:
Show:

Related questions

1 1 vote
0 0 answers
647
647 views
Ayush Upadhyaya asked Dec 12, 2018
647 views
I have one doubt regarding getting viable prefixes for a grammar. Suppose I am given a grammar G which is told to be LR(0).I have observed, if I draw LR(0) DFA for it, an...
2 2 votes
1 1 answer
4.1k
4.1k views
KISHALAY DAS asked Nov 12, 2016
4,133 views
Consider the augmented grammar :\[\begin{array}{l}\mathrm{S}^{\prime} \rightarrow \mathrm{S} \\\mathrm{~S} \rightarrow \mathrm{aSa}|\mathrm{bSb}| \mathrm{aSb}|\mathrm{ab}...
4 4 votes
2 2 answers
2.5k
2.5k views
Anusha Motamarri asked Sep 30, 2016
2,467 views
i think "(E+F*" is viable prefix but "E+F*" is not viable prefix. correct?
4 4 votes
3 3 answers
4.6k
4.6k views
Suvam Chatterjee asked Jul 18, 2015
4,603 views
Linked Answer Questions: Q. 80 to Q. 81 .Consider the following grammar production\[\begin{array}{l}\mathrm{S} \rightarrow \mathrm{BB} \\\mathrm{~B} \rightarrow \mathrm{a...