diff -r c82a45f48bfc -r 5365ef60707e cws/cw04.tex --- a/cws/cw04.tex Fri Oct 13 23:49:34 2023 +0100 +++ b/cws/cw04.tex Sat Oct 21 09:09:09 2023 +0100 @@ -237,8 +237,8 @@ \subsection*{Question 4} -Extend the lexer and parser to add a \texttt{break} keyword. Modify -the compiler such that when a \texttt{break}-statement is encountered +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 program @@ -246,11 +246,13 @@ \begin{center} \begin{minipage}{12cm} \begin{lstlisting}[language=While, numbers=none] +// should print 0 .. 10 for i := 0 upto 10 do { write i; write "\n" }; +// should print 0 .. 4 for i := 0 upto 10 do { if i > 4 then break else skip; write i;