716 views

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.
edited | 716 views

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

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

Follow $(E) =$ Follow $(A) =$ $\{$ $\$$,) \} LL(1) Parsing Table :  a ( ) + * \$$$EE \rightarrow aAE \rightarrow (E)AA \rightarrow \epsilonA \rightarrow +EA \rightarrow *EA \rightarrow \epsilon$$$\begin{array}{|l|l|l|l|l|l|l|} \hline \textbf{} & \textbf{a} & \textbf{(} & \textbf{)} & \textbf{+} & \textbf{*} & \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}$$ answered by Active (3k points) edited +1 Hello @aditya i have just structured your parsing table +1 vote First(E) = a,( and First(A) = +,*,epsilon Follow(E)= ),\$    and  Follow(A) = ),\\$

1
2