--- a/coursework/cw04.tex Mon Dec 07 01:35:42 2015 +0000
+++ b/coursework/cw04.tex Mon Dec 07 17:50:05 2015 +0000
@@ -147,17 +147,19 @@
\texttt{for}-loops, like
\begin{center}
-\texttt{for} \;\textit{Id} \texttt{:=} \textit{AExp}\; \texttt{upto} \;\textit{AExp}\; \texttt{do} \textit{Block}
+\lstset{language=While}
+\code{for} \;\textit{Id} \texttt{:=} \textit{AExp}\; \code{upto}
+\;\textit{AExp}\; \code{do} \textit{Block}
\end{center}
\noindent The intended meaning is to first assign the variable
-\textit{Id} the value of the first arithmetic expression, then
-go through the loop, at the end increase the value of the
-variable by 1, and finally test wether the value is not less
-or equal to the value of the second arithmetic expression (in
-case it is greater, you should leave the loop). For example
-the following instance of a \texttt{for}-loop is supposed to
-print out the numbers \texttt{2}, \texttt{3}, \texttt{4}.
+\textit{Id} the value of the first arithmetic expression, test
+wether this value is less or equal than the value of the
+second arithmetic expression. If yes, go through the loop, and
+at the end increase the value of the loop variable by 1 and
+start again with the test. If no, leave the loop. For example
+the following instance of a \code{for}-loop is supposed to
+print out the numbers \pcode{2}, \pcode{3}, \pcode{4}.
\begin{center}
@@ -172,11 +174,11 @@
\noindent There are two ways how this can be implemented: one
is to adapt the code generation part of the compiler and
-generate specific code for \texttt{for}-loops; the other is to
-translate the abstract syntax tree of \texttt{for}-loops into
+generate specific code for \code{for}-loops; the other is to
+translate the abstract syntax tree of \code{for}-loops into
an abstract syntax tree using existing language constructs.
For example the loop above could be translated to the
-following \texttt{while}-loop:
+following \code{while}-loop:
\begin{center}
\begin{minipage}{12cm}