--- a/cws/cw04.tex Sat Dec 02 21:37:04 2023 +0000
+++ b/cws/cw04.tex Wed Feb 21 09:14:12 2024 +0000
@@ -103,7 +103,7 @@
below as a slightly different syntax.
-\subsection*{Krakatau Assembler}
+\subsection*{Krakatau Assembler (Version 1 \& 2)}
The Krakatau assembler is available from
@@ -119,11 +119,11 @@
\end{center}
\noindent This assembler is largely compatible with the Jasmin
-syntax---that means for the files we are concerned with here,
-it understands the same input syntax (no changes to your
-compiler need to be made; ok maybe some small syntactic
-adjustments are needed). You can generate Java Byte Code by
-using
+syntax---that means for the files we are concerned with here, it
+understands the same input syntax (no changes to your compiler need to
+be made; ok maybe some small syntactic adjustments are needed, for
+example labels need to start with a capital '\texttt{L}'). You can generate Java
+Byte Code by using
\begin{center}
\texttt{python Krakatau-master/assemble.py loops.j}
@@ -161,16 +161,16 @@
\subsection*{Question 1}
-You need to lex and parse WHILE programs, and then generate
-Java Byte Code instructions for the Jasmin assembler (or
-Krakatau assembler). As solution you need to submit the
-assembler instructions for the Fibonacci and Factorial
-programs. Both should be so modified that a user can input on
-the console which Fibonacci number and which Factorial should
-be calculated. The Fibonacci program is given in
-Figure~\ref{fibs}. You can write your own program for
-calculating factorials. Submit your assembler code as
-a file that can be run, not as PDF-text.
+You need to lex and parse WHILE programs, and then generate Java Byte
+Code instructions for the Jasmin assembler (or Krakatau
+assembler). For this you should use the ASTs defined in CW3 (including
+logical operators). As part of the solution you need to submit the assembler
+instructions for the Fibonacci and Factorial programs. Both should be
+so modified that a user can input on the console which Fibonacci
+number and which Factorial should be calculated. The Fibonacci program
+is given in Figure~\ref{fibs}. You can write your own program for
+calculating factorials. Submit your assembler code as a file that can
+be run, not as PDF-text.
\begin{figure}[t]
\lstinputlisting[language=while]{../cwtests/cw04/fib.while}
@@ -255,8 +255,8 @@
Extend the lexer and parser to add a \textcolor{codepurple}{\pcode{break}} keyword. Modify
the compiler (including lexer and parser) such that when a \textcolor{codepurple}{\texttt{break}}-statement is encountered
-the code should jump out of the ``enclosing'' for-loop, or in case it
-is not inside a for-loop to the end of the program. For example the
+the code should jump out of the ``enclosing'' for/while-loop, or in case it
+is not inside such a loop to the end of the program. For example the
program
\begin{center}
@@ -286,7 +286,7 @@
should print out 0 to 10 with the first for-loop, but only 0
to 4 in the second. Similarly it should print out \code{"Should print"},
but not \code{"Should not print"}. For this you need to add
-a label to the end of every for-loop and also to the end of the
+a label to the end of every for- and while-loop and also to the end of the
whole program just in case you need to jump to that label via a
\code{break}. The file you need to be able to process for this question
is called \texttt{break.while}.