edited by
1 flag 9,068 views
38 38 votes

For the grammar below, a partial $LL(1)$ parsing table is also presented along with the grammar. Entries that need to be filled are indicated as $E1, E2,$ and $E3$. $\varepsilon$ is the empty string, \$ indicates end of input, and, $\mid$ separates alternate right hand sides of productions.

  • $ S\rightarrow a A b B \mid b A a B \mid \varepsilon $
  • $ A\rightarrow S $
  • $ B\rightarrow S $

$$\begin{array}{|l|l|l|l|}\hline \text{}  &  {\textbf{a}} & \textbf{b}  &  \textbf{\$} \\\hline  \text{$S$} & \text{E1} &  \text{E2}  &  \text{$S\rightarrow \varepsilon $} \\\hline  \text{$A$} & \text{$A\rightarrow S$} &  \text{$A\rightarrow S$}  &  \text{error} \\\hline  \text{$B$} & \text{$B\rightarrow S$} & \text{$B\rightarrow S$}  &  \text{$E3$} \\\hline \end{array}$$

The FIRST and FOLLOW sets for the non-terminals $A$ and $B$ are

  1. $ \text{FIRST}(A) = \{a, b, \varepsilon\} =\text{FIRST}(B) $
    $ \text{FOLLOW}(A) = \{a, b\} $
    $ \text{FOLLOW}(B) = \{a, b, \$\} $
     
  2. $ \text{FIRST}(A) = \{a, b, \$\} $
    $ \text{FIRST}(B) = \{a, b, \varepsilon\} $
    $ \text{FOLLOW}(A) = \{a, b\} $
    $ \text{FOLLOW}(B) = \{\$\} $
     
  3. $ \text{FIRST}(A) = \{a, b, \varepsilon\} =\text{FIRST}(B) $
    $ \text{FOLLOW}(A) =\{a, b\} $
    $ \text{FOLLOW}(B) = \varnothing $
     
  4. $ \text{FIRST}(A) = \{a, b\} = \text{FIRST}(B) $
    $ \text{FOLLOW}(A) = \{a, b\} $
    $ \text{FOLLOW}(B) =\{a, b\} $
  • 🚩 Edit necessary | 👮 Diju1234 | 💬 “Latex Edit needed.”

3 Answers

Best answer
40 40 votes
  • $\text{First}(S) = \text{First}(A) = \text{First}(B) = \{a,b,\epsilon\}$
  • $\text{Follow}(A) = \{a,b\}$
  • $\text{Follow}(B) = \text{Follow}(S) = \{a,b,\$\}$

So, the answer to question 52 is option A.

edited by
13 13 votes
Q 52 : ans is A.

first we can easly find.

follow of A = {a,b}, all symbols appeared after A in RHS

follow of B = {a,b,\$}, as B is at the end in RHS, follow(B) = follow (S) and S is also at the end in RHS so follow(S) = follow(A) = {a,b} and S is start symbol, so its follow contains \$ also.

hence, follow(B) = {a,b,\$}

Q 53.

ans is C.
Answer:
Position:
Show:

Related questions

53 53 votes
6 answers 6 answers
25.8k
25.8k views
go_editor asked Apr 21, 2016
25,805 views
For the grammar below, a partial $LL(1)$ parsing table is also presented along with the grammar. Entries that need to be filled are indicated as $E1, E2,$ and $E3$. $\var...
50 50 votes
2 answers 2 answers
13.3k
13.3k views
Kathleen asked Sep 13, 2014
13,337 views
For a context free grammar, FOLLOW(A) is the set of terminals that can appear immediately to the right of non-terminal $A$ in some "sentential" form. We define two sets L...
52 52 votes
5 answers 5 answers
20.0k
20.0k views
gatecse asked Sep 26, 2014
20,007 views
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.Program main; Var ... Procedure A1; Var ....
21 21 votes
4 4 answers
6.8k
6.8k views
Arjun asked Feb 27, 2025
6,755 views
Which of the following statement(s) is/are TRUE while computing $\operatorname{First}$ and $\operatorname{Follow}$ during top down parsing by a compiler?For a production ...