The Gateway to Computer Science Excellence
0 votes
179 views

Consider the following grammar:

S-->XX

X-->b

X-->aX

Which of the following can be the viable prefixes?

  1. baab
  2. aab
  3. aaabab
  4. bbbaX
in Compiler Design by Active (3.4k points)
edited by | 179 views
0
B?
0
Yes. How? I know how to recognize viable prefixes when a string to be parsed is given, but here no string is given??
+1

1. baab 

b will be pushed and before pushing next letter b will be reduced to X, so baab as viable prefix is not possible

with similar reason 3 and 4 are not viable prefixes,

but aab is 

.aab

a.ab  (a is pushed,no handle found)

aa.b (a is pushed and viable prefix is aa still no handle found)

aab. (b is pushed and handle found and will be reduced in next step but aab is a valid viable prefix)

For practice you can refer this one

1 Answer

0 votes
viable prefixes which  is collection of symbol on top of the stack which prefixes is not replaced by any production  of the cfg.
by Junior (909 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,497 answers
195,490 comments
100,818 users