in Compiler Design retagged by
736 views
4 votes
4 votes

Consider the following grammar given below.
$$
\begin{aligned}
& A \rightarrow B+A \\
& A \rightarrow B \\
& B \rightarrow C B \\
& B \rightarrow C \\
& C \rightarrow D^* \\
& C \rightarrow D \\
& D \rightarrow(A) \\
& D \rightarrow a \mid b
\end{aligned}
$$
What will be the content of the stack of SLR parser immediately after shifting the last character of the string: $a^* b($

  1. $\operatorname{CC}($
  2. $\mathrm{BC}($
  3. $\mathrm{CB}$
  4. $\mathrm{BB}$
in Compiler Design retagged by
736 views

1 comment

$ \large{\colorbox{yellow}{Detailed video solution of this question with direct time stamp}}$
All India Mock Test 2 - Solutions Part 2

0
0

1 Answer

2 votes
2 votes

If there were options like CB( , CA( Then can they be considered correct answers?

3 Comments

Can you explain how you got CC(
1
1
CC (  => D*D(  => a*b(

N.B=>[ direct reductions from CC(  , other  strings are not giving that parser for supporting statements of SLR parsing]
1
1

@Sachin Mittal 1 Sir , @GO Classes , @GO Classes Support , can you please just clarify if in option CD( was given then will be correct answer or not ? if not then please explain why . 

 

 

@squirrel69 a*b( is given string now first a will be put in stack 

a|*b(  -→ we have to reduce a using it’s handle

D|*b(  --→ from production D→ a|b

D*|b(  -→ add one more character on a stack

C|b(  → from C→ D* production

Cb |( → added one more character on top of stack

CD |( → from D→a|b

CC|( → from C→ D production

CC( | → last character is insert and hence after it’s insertion the stack content will be CC( 

hope this will help you 

 

5
5