next up previous
Next: Exercise 9. Up: Final-2003 Previous: Exercise 7.

Exercise 8.

Some languages such as PL1 permit a list of names to be given a list of attributes. The grammar G below abstracts the problem.

D $\displaystyle \longmapsto$ namelist  attriblist$\displaystyle \bf ;$
namelist $\displaystyle \longmapsto$ $\displaystyle \bf id$, namelist
namelist $\displaystyle \longmapsto$ $\displaystyle \bf id$
attriblist $\displaystyle \longmapsto$ A  attriblist
attriblist $\displaystyle \longmapsto$ A
A $\displaystyle \longmapsto$ $\displaystyle \bf long$
A $\displaystyle \longmapsto$ $\displaystyle \bf double$
A $\displaystyle \longmapsto$ $\displaystyle \bf single$
A $\displaystyle \longmapsto$ $\displaystyle \bf integer$
A $\displaystyle \longmapsto$ $\displaystyle \bf float$
   

where D, namelist, attriblist and A are nonterminals and where id, long, double, single, integer, float and ; are terminals. As usual id is the identifier token. For instance each of the following lines is a declaration generated by G.
i, j single integer;
u, v, w double float;
Give a syntax-directed definition for declarations generated by G. Here are some hints.

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


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