The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
125 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 (2.8k points)
edited by | 125 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 (903 points)

Related questions

+1 vote
1 answer
7
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,092 questions
55,239 answers
190,758 comments
85,996 users