diff -r c6c79d21f8a8 -r 1ee523c4f098 coursework/cw03.tex --- a/coursework/cw03.tex Wed Nov 06 23:17:05 2019 +0000 +++ b/coursework/cw03.tex Wed Nov 06 23:27:19 2019 +0000 @@ -46,12 +46,13 @@ \subsection*{Question 2} -You should implement a parser for the WHILE language using -parser combinators. Be careful that the parser takes as input -a stream, or list, of tokens generated by the tokenizer from -the previous coursework. For this you might want to filter out -whitespaces and comments. Your parser should be able to handle -the WHILE programs in Figures~\ref{fib} and \ref{loop}. +You should implement a parser for the WHILE language using parser +combinators. Be careful that the parser takes as input a stream, or +list, of tokens generated by the tokenizer from the previous +coursework. For this you might want to filter out whitespaces and +comments. Your parser should be able to handle the WHILE programs in +Figures~\ref{fib}, \ref{loop} and \ref{primes} (if your lexer cannot +deal with comments you can delete them from the prime number program). In addition give the parse tree for the statement: \begin{lstlisting}[language=While,numbers=none] @@ -118,6 +119,8 @@ evaluates to \pcode{true}, otherwise the else-branch. Loops should be run as long as the boolean is \pcode{true}. + + Give some time measurements for your interpreter and the loop program in Figure~\ref{loop}. For example how long does your interpreter take when \pcode{start} @@ -126,20 +129,21 @@ 1 Minute? \begin{figure}[p] -\begin{center} -\mbox{\lstinputlisting[language=while]{../progs/fib.while}} -\end{center} +\lstinputlisting[language=while,xleftmargin=20mm]{../progs/fib.while} \caption{Fibonacci program in the WHILE language.\label{fib}} \end{figure} \begin{figure}[p] -\begin{center} -\mbox{\lstinputlisting[language=while]{../progs/loops.while}} -\end{center} +\lstinputlisting[language=while,xleftmargin=20mm]{../progs/loops.while} \caption{The three-nested-loops program in the WHILE language. Usually used for timing measurements.\label{loop}} \end{figure} +\begin{figure}[p] +\lstinputlisting[language=while,xleftmargin=0mm]{../progs/primes.while} +\caption{Prime number program.\label{primes}} +\end{figure} + \end{document} %%% Local Variables: