
diff -r 448a7a78aa86 -r fca7f33a426c coursework/cw02.tex
--- a/coursework/cw02.tex	Mon Aug 24 15:03:55 2020 +0100
+++ b/coursework/cw02.tex	Mon Aug 31 16:57:15 2020 +0100
@@ -5,16 +5,16 @@
 
 \begin{document}
 
-\section*{Coursework 2 (Strand 1)}
+\section*{Coursework 2}
 
-\noindent This coursework is worth 5\% and is due on
-\cwTWO{} at 18:00. You are asked to implement the Sulzmann \&
-Lu lexer for the WHILE language. You can do the
-implementation in any programming language you like, but you
-need to submit the source code with which you answered the
-questions, otherwise a mark of 0\% will be awarded. You can
-submit your answers in a txt-file or as pdf. Code submit as 
-code.
+\noindent This coursework is worth 8\% and is due on \cwTWO{} at
+18:00. You are asked to implement the Sulzmann \& Lu lexer for the
+WHILE language. You can do the implementation in any programming
+language you like, but you need to submit the source code with which
+you answered the questions, otherwise a mark of 0\% will be
+awarded. You can submit your answers in a txt-file or as pdf. Code
+submit as code. Please package everything in a zip-file that creates a
+directory with the name \texttt{YournameYourfamilyname} on my end. Thanks!
 
 \subsection*{Disclaimer}
 
@@ -28,12 +28,12 @@
 
 To implement a lexer for the WHILE language, you first
 need to design the appropriate regular expressions for the
-following eight syntactic entities:
+following eleven syntactic entities:
 
 \begin{enumerate}
 \item keywords are
 
-\begin{quote}
+\begin{center}
 \texttt{while}, 
 \texttt{if}, 
 \texttt{then}, 
@@ -46,11 +46,9 @@
 \texttt{read}, 
 \texttt{write},
 \texttt{skip}
-\end{quote} 
+\end{center} 
 
-\item operators are
-
-\begin{quote}
+\item operators are:
 \texttt{+}, 
 \texttt{-}, 
 \texttt{*}, 
@@ -59,13 +57,27 @@
 \texttt{==}, 
 \texttt{!=}, 
 \texttt{>}, 
-\texttt{<}, 
+\texttt{<},
+\texttt{<=}, 
+\texttt{>=},
 \texttt{:=},
 \texttt{\&\&},
 \texttt{||}
-\end{quote} 
+
+\item letters are uppercase and lowercase
 
-\item strings are enclosed by \texttt{"\ldots"} 
+\item symbols are letters plus the characters
+  \texttt{.},
+  \texttt{\_},
+  \texttt{>},
+  \texttt{<},
+  \texttt{=},
+  \texttt{;},
+  \texttt{,} and
+  \texttt{:}
+
+\item strings are enclosed by \texttt{"\ldots"} and consisting of
+  symbols, whitespaces and digits
 \item parentheses are \texttt{(}, \texttt{\{}, \texttt{)} and \texttt{\}}
 \item there are semicolons \texttt{;}
 \item whitespaces are either \texttt{" "} (one or more) or \texttt{$\backslash$n} or
@@ -75,6 +87,7 @@
 \item numbers are \pcode{0}, \pcode{1}, \ldots and so on; give 
 a regular expression that can recognise \pcode{0}, but not numbers 
 with leading zeroes, such as \pcode{001}
+\item comments start with \texttt{//} and contain symbols, spaces and digits until the end of the line
 \end{enumerate}
 
 \noindent
@@ -169,31 +182,38 @@
 
 \subsection*{Question 3}
 
-Extend your lexer from Q2 to also simplify regular expressions
-after each derivation step and rectify the computed values after each
+Extend your lexer from Q2 to also simplify regular expressions after
+each derivation step and rectify the computed values after each
 injection. Use this lexer to tokenize the programs in
-Figure~\ref{fib}, \ref{loop} and \ref{factors}. Give the tokens of these
-programs where whitespaces are filtered out. Make sure you can
-tokenise \textbf{exactly} these programs.\bigskip
+Figures~\ref{fib} -- \ref{collatz}. You can find the programms also on
+KEATS. Give the tokens of these programs where whitespaces are
+filtered out. Make sure you can tokenise \textbf{exactly} these
+programs.\bigskip
 
 
 \begin{figure}[h]
-\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/fib.while}}
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/fib.while}}
 \caption{Fibonacci program in the WHILE language.\label{fib}}
 \end{figure}
 
 \begin{figure}[h]
-\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/loops.while}}
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/loops.while}}
 \caption{The three-nested-loops program in the WHILE language. 
 (Usually used for timing measurements.)\label{loop}}
 \end{figure}
 
 \begin{figure}[h]
-\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/factors.while}}
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/factors.while}}
 \caption{A program that calculates factors for numbers in the WHILE
   language.\label{factors}}
 \end{figure}
 
+\begin{figure}[h]
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/collatz2.while}}
+\caption{A program that calculates the Collatz series for numbers
+  between 1 and 100.\label{collatz}}
+\end{figure}
+
 \end{document}
 
 %%% Local Variables: 




