next up previous
Next: Exercise 5. Up: Final-2003 Previous: Exercise 3.

Exercise 4.

Consider the following grammar G with terminals a, b, e, i, t and nonterminals S, S', E.
S $ \longmapsto$ i E t S S'  |  a
S' $ \longmapsto$ e S  |  $ \varepsilon$
E $ \longmapsto$ b
We recall the rules for the computation of the FOLLOW set of each nonterminal.

if A $\displaystyle \longmapsto$ $\displaystyle \alpha$B$\displaystyle \beta$ then $\displaystyle \mbox{{\sc FOLLOW}($B$)}$ : = $\displaystyle \mbox{{\sc FIRST}(${\beta}$)}$ $\displaystyle \setminus$ {$\displaystyle \varepsilon$$\displaystyle \cup$  $\displaystyle \mbox{{\sc FOLLOW}($B$)}$
if A $\displaystyle \longmapsto$ $\displaystyle \alpha$B then $\displaystyle \mbox{{\sc FOLLOW}($B$)}$ : = $\displaystyle \mbox{{\sc FOLLOW}($B$)}$  $\displaystyle \cup$  $\displaystyle \mbox{{\sc FOLLOW}($A$)}$
if $\displaystyle \left\{\vphantom{ \begin{array}{l} A \longmapsto {\alpha} B {\beta} \\  {\beta} \stackrel{\ast}{\Longrightarrow} {\varepsilon} \end{array} }\right.$$\displaystyle \begin{array}{l} A \longmapsto {\alpha} B {\beta} \\  {\beta} \stackrel{\ast}{\Longrightarrow} {\varepsilon} \end{array}$ then $\displaystyle \mbox{{\sc FOLLOW}($B$)}$ : = $\displaystyle \mbox{{\sc FOLLOW}($B$)}$  $\displaystyle \cup$  $\displaystyle \mbox{{\sc FOLLOW}($A$)}$
   

Give the parsing table (for the non-recursive implementation of predictive parsing)

Answer 4  
\fbox{
\begin{minipage}{12 cm}
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \...
...\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\mbox{ } \\
\end{minipage}}


next up previous
Next: Exercise 5. Up: Final-2003 Previous: Exercise 3.
Marc Moreno Maza
2004-12-02