• edited by
7,483 views
32 32 votes

Consider the following grammar with terminal alphabet $\Sigma =\{a,(,),+,* \}$ and start symbol $E$. The production rules of the grammar are:

  • $ E \rightarrow aA$
  • $ E \rightarrow (E)$
  • $A \rightarrow +E$
  • $A \rightarrow *E$
  • $A \rightarrow \epsilon $
  1. Compute the FIRST and FOLLOW sets for $E$ and $A$.
  2. Complete the LL(1) parse table for the grammar.

2 Answers

Best answer
51 51 votes

First $(E) = \{ a,( \}$

First $(A) = \{ +,*, \epsilon \}$

Follow $(E) =$ Follow $(A) =$ $\{$ $\$$ $,) \}$

LL(1) Parsing Table:

$$\begin{array}{|c|c|c|c|c|c|c|} \hline \textbf{} & \textbf{a} & \textbf{(} & \textbf{)} & \textbf{+} & \bf{*} & \textbf{\$} \\\hline \text{E} & \text{E} \rightarrow \text{aA} & \text{E} \rightarrow \text{(E)} & \text{} & \text{} & \text{} & \text{} \\\hline \text{A} & \text{}& \text{} & \text{A} \rightarrow \epsilon & \text{A} \rightarrow \text{+E} & \text{A} \rightarrow *\text{E} & \text{A} \rightarrow \epsilon \\\hline \end{array}$$

• edited by
2 2 votes
First(E) = a,(   and   First(A) = +,*,epsilon

Follow(E)= ),\$    and  Follow(A) = ),\$
Position:
Show:

Related questions

14 14 votes
2 answers 2 answers
3.4k
3.4k views
Kathleen asked Sep 14, 2014
3,396 views
The syntax of the repeat-until statement is given by the following grammar$S \rightarrow\text{ repeat }S_1\text{ until }E$where E stands for expressions, $S$ and $S_1$ st...
48 48 votes
6 answers 6 answers
27.2k
27.2k views
Kathleen asked Sep 14, 2014
27,208 views
Which of the following statements is false?An unambiguous grammar has same leftmost and rightmost derivationAn LL(1) parser is a top-down parserLALR is more powerful than...
26 26 votes
3 answers 3 answers
6.0k
6.0k views
Kathleen asked Sep 14, 2014
5,981 views
Remove left-recursion from the following grammar: $S \rightarrow Sa \mid Sb \mid a \mid b$Consider the following grammar: $S \rightarrow aSbS\mid bSaS \mid \...
13 13 votes
4 answers 4 answers
4.3k
4.3k views
go_editor asked Feb 8, 2018
4,327 views
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.Write an SQL query to list the regno of examinees who have a s...