• edited by
2,497 views
10 10 votes

Consider the canonical $L R(0)$ parsing of the grammar below using terminals $\{a, b, c\}$ and non-terminals $\{A, B, C, S\}$ with $S$ as the start symbol.

\[
\begin{array}{l}
S \rightarrow A C B \\
A \rightarrow a A \mid \epsilon \\
C \rightarrow c C \mid \epsilon \\
B \rightarrow b B \mid b
\end{array}
\]
Which one of the following options gives the number of shift-reduce conflicts that will occur in the $L R(0)$ ACTION table?

  1. $2$
  2. $3$
  3. $4$
  4. $5$

5 Answers

14 14 votes

....

3 3 votes

Ans (D) 

One item in the state has already completed its production (Reduce), while another item in the same state 

still wants to read more input (Shift). Therefore the parser doesn't know whether to Reduce or Shift.

This means Shift-Reduce conflict

 

Ex :

A → .         Finished
A → .aA    Still working              

It is shift reduce conflict.

 

 

Hence, Total SR conflicts = 5

0 0 votes

Answer: (D)

A shift-reduce conflict occurs when there is a complete item \((A \rightarrow \alpha \bullet)\) in a state and that state also has a transition on some terminal symbol.

Thus, there are total 5 shift-reduce conflicts.

• edited by
Answer:
Position:
Show:

Related questions

11 11 votes
8 8 answers
2.0k
2.0k views
gatecse asked Feb 23
2,021 views
Consider the control flow graph given below.Which one of the following options is the set of live variables at the exit point of each basic block?$\mathrm{B} 1:\{\mathrm{...
10 10 votes
3 3 answers
1.7k
1.7k views
gatecse asked Feb 23
1,682 views
Which of the following grammars is/are ambiguous?$S \rightarrow a S b \mid \epsilon$$E \rightarrow E+E|E * E| i d$$S \rightarrow a S|S a| \epsilon$$S \rightarrow a S \mid...
8 8 votes
6 6 answers
2.5k
2.5k views
gatecse asked Feb 23
2,513 views
A lexical analyzer uses the following token definitions${letter → [A-Za-z]}$${digit → [0-9]}$${id → letter (letter | digit)^*}$${number → digit}$ ${ }^{+}$${ws → (blank |...
26 26 votes
6 6 answers
10.9k
10.9k views
Arjun asked Feb 27, 2025
10,931 views
​​Given a Context-Free Grammar $\text{G}$ as follows:\[\begin{array}{l}S \rightarrow A a|b A c| d c \mid b d a \\A \rightarrow d\end{array}\]Which ONE of the following st...