--- a/handouts/ho07.tex Tue Nov 13 08:16:48 2018 +0000
+++ b/handouts/ho07.tex Mon Nov 19 22:12:04 2018 +0000
@@ -1,3 +1,4 @@
+% !TEX program = xelatex
\documentclass{article}
\usepackage{../style}
\usepackage{../langs}
@@ -65,7 +66,8 @@
starting symbol):
-\begin{plstx}[rhs style=, margin=3cm]
: \meta{E} ::= \meta{T} $+$ \meta{E}
+\begin{plstx}[rhs style=, margin=3cm]
+: \meta{E} ::= \meta{T} $+$ \meta{E}
| \meta{T} $-$ \meta{E}
| \meta{T}\\
: \meta{T} ::= \meta{F} $*$ \meta{T}
@@ -73,7 +75,8 @@
| \meta{F}\\
: \meta{F} ::= ( \meta{E} )
| \meta{Id}
- | \meta{Num}\\
\end{plstx}
+ | \meta{Num}\\
+\end{plstx}
\noindent where \meta{Id} stands for variables and \meta{Num}
@@ -84,7 +87,9 @@
following tree.
\begin{center}
-\begin{tikzpicture}
\Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
\end{tikzpicture}
+\begin{tikzpicture}
+\Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]]
+\end{tikzpicture}
\end{center}
\noindent To generate code for this expression, we need to
@@ -238,7 +243,7 @@
\noindent
where $n_x$ is the index for the variable $x$.
-More complicated is the code for \pcode{if}-statments, say
+More complicated is the code for \pcode{if}-statements, say
\begin{lstlisting}[mathescape,language={},numbers=none]
if $b$ then $cs_1$ else $cs_2$
@@ -377,7 +382,7 @@
the most convenient.
We are now ready to give the compile function for
-if-statments---remember this function returns for staments a
+if-statements---remember this function returns for statements a
pair consisting of the code and an environment:
\begin{center}
@@ -427,10 +432,12 @@
L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$
\end{lstlisting}
-\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm)
+\begin{tikzpicture}[remember picture,overlay]
+ \draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm)
-- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east);
\draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm)
- -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
\end{tikzpicture}
+ -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east);
+\end{tikzpicture}
\noindent The first three lines correspond to the the boolean
expression $1 = 1$. The jump for when this boolean expression
@@ -534,10 +541,12 @@
L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$
\end{lstlisting}
-\begin{tikzpicture}[remember picture,overlay]
\draw[->,very thick] (LA) edge [->,to path={-- ++(10mm,0mm)
+\begin{tikzpicture}[remember picture,overlay]
+ \draw[->,very thick] (LA) edge [->,to path={-- ++(10mm,0mm)
-- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east);
\draw[->,very thick] (LC) edge [->,to path={-- ++(10mm,0mm)
- -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
\end{tikzpicture}
+ -- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east);
+\end{tikzpicture}
Next we need to consider the statement \pcode{write x}, which
@@ -634,7 +643,7 @@
stack and local variables.
To sum up, in Figure~\ref{test} is the complete code generated
-for the slightly non-sensical program
+for the slightly nonsensical program
\begin{lstlisting}[mathescape,language=While]
x := 1 + 2;