in Compiler Design retagged by
456 views
2 votes
2 votes

Consider the following grammar:
$$
\begin{aligned}
& S \rightarrow a S^{\prime} \\
& S^{\prime} \rightarrow b S^{\prime} \mid \epsilon
\end{aligned}
$$
Which of the following is/are CORRECT right sentential form of the given grammar?

  1. $a b S^{\prime}$
  2. $bS'$
  3. $a S^{\prime} b$
  4. $bbS$
in Compiler Design retagged by
456 views

1 Answer

3 votes
3 votes

To keep in mind, Ques is asking right sentential form, not viable prefix.

Just expand S and check if it can be derived or not

       A . S→ aS’ → abS’

  1. S → aS’ → a | abS’  So bS’ cant be derived
  2. S → aS’ → abS’ | a So aS’b cant be derived
  3. bbS can’t be derives

3 Comments

@GO Classes why can't b be the answer??

like in this S → aS’ → abS’ → abbS’

0
0
What you are saying is a viable prefix not a sentential  form.

sentential form is a complete state while viable prefix are the prefix of the sentential form
4
4
Even bS' is not a viable prefix.

The derivation that he is given is

S → aS’ → abS’ → abbS’

For 2 nd step bS' is handle so the possible viable prefixes are : a , ab , abS' and not bS'

For 3rd step bS' is handle so the possible viable prefixes are : a , ab ,abb, abbS'.
0
0
Answer:

Related questions