next up previous
Next: Exercise 3. Up: Quiz2 Previous: Exercise 1.

Exercise 2.

Consider the following syntax-directed definition for the point size and height of boxes containing mathematical formulas.
Production Semantic Rule
S $ \longmapsto$ B B.ps := 10
  S.ht := B.ht
B $ \longmapsto$ B1 B2 B1.ps := B.ps
  B2.ps := B.ps
  B.ht := max( B1.ht, B2.ht)
B $ \longmapsto$ B1 $ \bf sub$ B2 B1.ps := B.ps
  B2.ps := shrink(B.ps)
  B.ht := disp( B1.ht, B2.ht)
B $ \longmapsto$ $ \bf text$ B.ht := $ \bf text$.h×B.ps
Write a translation scheme for this syntax-directed definition.

Answer 2  
\fbox{
\begin{minipage}{13 cm}
\begin{center}
\begin{tabular}{\vert llll\vert} \...
...t}.h \times B.ps$\ $\}$\ \\ \hline
\end{tabular}\end{center}\par
\end{minipage}}


next up previous
Next: Exercise 3. Up: Quiz2 Previous: Exercise 1.
Marc Moreno Maza
2004-12-02