• edited by
29,678 views
50 50 votes

Consider the grammar shown below. 

  • $S \rightarrow C \ C$
  • $C \rightarrow c \ C \mid d$

This grammar is

  1. LL(1)
  2. SLR(1) but not LL(1)
  3. LALR(1) but not SLR(1)
  4. LR(I) but not LALR(1)

3 Answers

Best answer
100 100 votes

ans is A

$First(S)=First(C)=\{c,d\}$

There are no multiple entries in single row of parsing table hence grammar is LL1

Note : If we have $A \rightarrow B\mid C,$ for grammar to be LL(1) first(B) intersection First(C) should be null otherwise grammar is not LL1. If First(B) contains $\epsilon$ then Follow(A) intersection First(C) should be null. Using this we can say grammar is LL(1) or not without constructing parsing table.

An $\epsilon$ free LL(1) grammar is also SLR(1) and hence LALR(1) and LR(1) too.

• edited by
7 7 votes

Answer is A 

3 3 votes

Ambiguous?

I think nope.

 

Left Recursive?

No.

 

Non-deterministic?

No.

 

For any $A\rightarrow \alpha \beta$ do the Firsts of $\alpha$ and  $\beta$ clash?

No.

 

So, this is LL(1).

 

Does it have $\epsilon$?

No.

Hence, this is SLR(1) and everything above it.

 

Option A

Answer:
Position:
Show:

Related questions

43 43 votes
4 answers 4 answers
20.3k
20.3k views
Kathleen asked Sep 17, 2014
20,347 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...
61 61 votes
5 answers 5 answers
14.5k
14.5k views
Kathleen asked Sep 17, 2014
14,535 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 ...
51 51 votes
5 answers 5 answers
19.6k
19.6k views
Kathleen asked Sep 17, 2014
19,554 views
Consider the translation scheme shown below.$S \rightarrow T\;R$$R \rightarrow + T \{\text{print}(‘+’);\} R\mid \varepsilon$$T \rightarrow$ num $\{\text{print}$(num.val)...
32 32 votes
4 answers 4 answers
16.5k
16.5k views
Kathleen asked Sep 16, 2014
16,506 views
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$n_1$ is necessarily le...