--- a/coursework/cw02.tex Tue Nov 10 22:27:46 2015 +0000
+++ b/coursework/cw02.tex Sun Nov 15 21:31:31 2015 +0000
@@ -93,20 +93,40 @@
\end{center}
\noindent
+Try to design regular expressions to be as small as possible.
\subsection*{Question 2 (marked with 3\%)}
Implement the Sulzmann \& Lu tokeniser from the lectures. For
this you need to implement the functions $nullable$ and $der$
-(you can use your code from CW 1), as well as $mkeps$ and
+(you can use your code from CW~1), as well as $mkeps$ and
$inj$. These functions need to be appropriately extended for
-the extended regular expressions from Q1. Also add the record
-regular expression from the lectures and implement a function,
-say \pcode{env}, that returns all assignments from a value
-(such that you can extract easily the tokens from a value).
+the extended regular expressions from Q1. Write down the
+clauses for
-The functions $mkeps$ and $inj$ return values. Calculate the
-value for your regular expressions from Q1 and the string
+\begin{center}
+\begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}
+$mkeps([c_1 c_2 \ldots c_n])$ & $\dn$ & $?$\\
+$mkeps(r^+)$ & $\dn$ & $?$\\
+$mkeps(r^?)$ & $\dn$ & $?$\\
+$mkeps(r^{\{n\}})$ & $\dn$ & $?$\medskip\\
+$inj\, ([c_1 c_2 \ldots c_n])\,c\,\ldots$ & $\dn$ & $?$\\
+$inj\, (r^+)\,c\,\ldots$ & $\dn$ & $?$\\
+$inj\, (r^?)\,c\,\ldots$ & $\dn$ & $?$\\
+$inj\, (r^{\{n\}})\,c\,\ldots$ & $\dn$ & $?$\\
+\end{tabular}
+\end{center}
+
+\noindent where $inj$ takes three arguments: a regular
+expression, a character and a value. Also add the record
+regular expression from the lectures to your tokeniser and
+implement a function, say \pcode{env}, that returns all
+assignments from a value (such that you can extract easily the
+tokens from a value).\medskip
+
+\noindent
+Fiannly give the tokens for your regular expressions from Q1 and the
+string
\begin{center}
\code{"read n;"}