coursework/cw02.tex
changeset 659 fe1f9c2e3c5b
parent 657 065a119cc511
child 663 393d8ae074a4
equal deleted inserted replaced
658:e215f5a6912e 659:fe1f9c2e3c5b
   170 \subsection*{Question 3}
   170 \subsection*{Question 3}
   171 
   171 
   172 Extend your lexer from Q2 to also simplify regular expressions
   172 Extend your lexer from Q2 to also simplify regular expressions
   173 after each derivation step and rectify the computed values after each
   173 after each derivation step and rectify the computed values after each
   174 injection. Use this lexer to tokenize the programs in
   174 injection. Use this lexer to tokenize the programs in
   175 Figure~\ref{fib} and \ref{loop}. Give the tokens of these
   175 Figure~\ref{fib}, \ref{loop} and \ref{factor}. Give the tokens of these
   176 programs where whitespaces are filtered out. Make sure you can
   176 programs where whitespaces are filtered out. Make sure you can
   177 tokenise \textbf{exactly} these programs.\bigskip
   177 tokenise \textbf{exactly} these programs.\bigskip
   178 
   178 
   179 
   179 
   180 \begin{figure}[h]
   180 \begin{figure}[h]
   186 \mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/loops.while}}
   186 \mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/loops.while}}
   187 \caption{The three-nested-loops program in the WHILE language. 
   187 \caption{The three-nested-loops program in the WHILE language. 
   188 (Usually used for timing measurements.)\label{loop}}
   188 (Usually used for timing measurements.)\label{loop}}
   189 \end{figure}
   189 \end{figure}
   190 
   190 
       
   191 \begin{figure}[h]
       
   192 \mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/factors.while}}
       
   193 \caption{A program that calculates factors for numbers in the WHILE
       
   194   language.\label{factors}}
       
   195 \end{figure}
       
   196 
   191 \end{document}
   197 \end{document}
   192 
   198 
   193 %%% Local Variables: 
   199 %%% Local Variables: 
   194 %%% mode: latex
   200 %%% mode: latex
   195 %%% TeX-master: t
   201 %%% TeX-master: t