search
Log In
15 votes
2.5k views

Consider the following grammar:

$S\rightarrow FR$

$ R\rightarrow * S\mid \varepsilon $

$ F\rightarrow  id $

In the predictive parser table, M, of the grammar the entries M[S,id] and M[R,\$] respectively are

  1. $ \left \{ S\rightarrow FR \right \} $ and $ \left \{ R\rightarrow \varepsilon \right \} $
  2. $ \left \{ S\rightarrow FR \right \} $ and $ \left \{ \right \} $
  3. $ \left \{ S\rightarrow FR \right \} $ and $ \left \{ R\rightarrow {*}S\right \} $
  4. $ \left \{ F\rightarrow id \right \} $ and $ \left \{ R\rightarrow \varepsilon \right \} $
in Compiler Design
edited by
2.5k views

3 Answers

23 votes
 
Best answer

First $S = \{ id \}$
Follow $R = \{ \$ \}$

so $M[S,id] = S  \rightarrow FR$
     $M[S,\$] = R  \rightarrow \epsilon$

So ans is A


edited by
0
What is the Follow of S R F ?
Please explain how to find follow in this example
7
pls correct me  if wrong

        First              Follow

S       id                      \$

R      * , ε                   \$

F      id                     * $
1
yes your first and follows are correct.
4 votes

Answer:

0
First of S should be {id}

&

 ε     cant be written in follow whenever  ε      is seen here in FOLLOW(F) during the parsing process then will write as $ because then follow(f)=follow(s) here as  ε     reduces a step down when u draw parsing tree
0 votes
ans a)
18
Please try to include an explanation with your answer. Unless you provide an explanation, your answer is mostly useless.
Answer:

Related questions

23 votes
6 answers
1
3.9k views
Consider the following grammar $S \rightarrow S * E$ $S \rightarrow E$ $E \rightarrow F + E$ $E \rightarrow F$ $F \rightarrow id$ Consider the following LR(0) items corresponding to the grammar above $S \rightarrow S *.E$ $E \rightarrow F. + E$ ... of them will appear in the same set in the canonical sets-of-items for the grammar? i and ii ii and iii i and iii None of the above
asked Sep 16, 2014 in Compiler Design Rucha Shelke 3.9k views
13 votes
6 answers
2
1.7k views
The grammar $S\rightarrow AC\mid CB$ $C\rightarrow aCb\mid \epsilon$ $A\rightarrow aA\mid a$ $B\rightarrow Bb\mid b$ generates the language $ L=\left \{ a^{i}b^{j}\mid i\neq j \right \}$. In this grammar what is the length of the derivation (number of steps starting from $S$) to generate the string $a^{l}b^{m}$ with $l\neq m$ $\max (l,m) + 2$ $l + m + 2$ $l + m + 3$ $\max (l,m) + 3$
asked Nov 7, 2016 in Compiler Design jothee 1.7k views
31 votes
4 answers
3
4.1k views
Which one of the following grammars generates the language $ L=\left \{ a^{i}b^{j}\mid i\neq j \right \}$? $S\rightarrow AC\mid CB$ $C\rightarrow aCb\mid a\mid b$ $A\rightarrow aA\mid \varepsilon$ $B\rightarrow Bb\mid \varepsilon$ ... $S\rightarrow AC\mid CB$ $C\rightarrow aCb\mid \varepsilon$ $A\rightarrow aA\mid a$ $B\rightarrow Bb\mid b$
asked Sep 26, 2014 in Compiler Design Rucha Shelke 4.1k views
24 votes
3 answers
4
3.6k views
Consider the following translation scheme. $ S\rightarrow ER$ $ R\rightarrow ^{*}E\left \{ print('*'); \right \} R\mid \varepsilon $ $ E\rightarrow F+E\left \{ print('+'); \right \}\mid F $ $ F\rightarrow (S)\mid id \left \{ print(id.value); \right \} $ Here id is a token that represents an ... $2 * 3 + 4$', this translation scheme prints $2 * 3 + 4$ $2 * +3 \ 4$ $2 \ 3 * 4 +$ $2 \ 3 \ 4+*$
asked Sep 26, 2014 in Compiler Design Rucha Shelke 3.6k views
...