16,724 views
33 33 votes

Assume that the SLR parser for a grammar G has $n_1$ states and the LALR parser for G has $n_2$ states. The relationship between $n_1$ and $n_2$ is

  1. $n_1$ is necessarily less than $n_2$
  2. $n_1$ is necessarily equal to $n_2$
  3. $n_1$ is necessarily greater than $n_2$
  4. None of the above

4 Answers

Best answer
50 50 votes
no. of states in $\text{SLR}$ and $\text{LALR}$ are equal.

and no. of states in $\text{SLR}$ and $\text{LALR}$ are less than or equal to $\text{LR(1).}$

Correct Answer: $B$
• edited by
4 4 votes
In the LALR parser, we only consider the core part of LR(1) items while merging. And in the SLR parser, we only have the core part.
So in LR(1) parser, the increased number of states may appear due to differences in the lookaheads.
Once you ignore the lookaheads in LR(1), the SLR and LALR parsers look the same.
Answer:
Position:
Show:

Related questions

81 81 votes
11 answers 11 answers
39.5k
39.5k views
Kathleen asked Sep 16, 2014
39,548 views
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?Removing left recursion aloneFactoring the grammar aloneRemoving left recursion and factor...
61 61 votes
5 answers 5 answers
14.8k
14.8k views
Kathleen asked Sep 17, 2014
14,843 views
A program consists of two modules executed sequentially. Let $f_1(t)$ and $f_2(t)$ respectively denote the probability density functions of time taken to execute the two ...
50 50 votes
3 answers 3 answers
30.2k
30.2k views
Kathleen asked Sep 17, 2014
30,198 views
Consider the grammar shown below. $S \rightarrow C \ C$$C \rightarrow c \ C \mid d$This grammar isLL(1)SLR(1) but not LL(1)LALR(1) but not SLR(1)LR(I) but not LALR(1)
44 44 votes
4 answers 4 answers
20.7k
20.7k views
Kathleen asked Sep 17, 2014
20,711 views
Consider the grammar shown below$S \rightarrow i E t S S’ \mid a$$S’ \rightarrow e S \mid \epsilon$$E \rightarrow b$In the predictive parse table, $M,$ of this grammar, t...