diff -r 4e97783862ff -r d0fc671bcbbf coursework/cw01.tex --- a/coursework/cw01.tex Sun May 21 00:46:21 2017 +0100 +++ b/coursework/cw01.tex Sun May 21 07:35:35 2017 +0100 @@ -59,7 +59,7 @@ $0$. In the case of $r^{\{n,m\}}$ you can also assume $0 \le n \le m$.\bigskip \noindent {\bf Important!} Your implementation should have explicit -cases for the basic regular expressions, but also explicit cases for +cases for the basic regular expressions, but also for explicit cases for the extended regular expressions. That means do not treat the extended regular expressions by just translating them into the basic ones. See also Question 2, where you are asked to explicitly give the rules for @@ -172,23 +172,25 @@ \subsection*{Question 3} -There are a number of explicit regular expressions that deal with single or several -characters, for example: +As you can see, there are a number of explicit regular expressions +that deal with single or several characters, for example: \begin{center} \begin{tabular}{ll} - $c$ & match a single character\\ - $[c_1,c_2,\ldots,c_n]$ & match a set of characters---for character ranges\\ - $\textit{ALL}$ & match any character + $c$ & matches a single character\\ + $[c_1,c_2,\ldots,c_n]$ & matches a set of characters---for character ranges\\ + $\textit{ALL}$ & matches any character \end{tabular} \end{center} \noindent the latter is useful for matching any string (for example -$\textit{ALL}^*$). In order to avoid having an explicit constructor -for each case, we can generalise all such cases and introduce a single +by using $\textit{ALL}^*$). In order to avoid having an explicit constructor +for each case, we can generalise all these cases and introduce a single constructor $\textit{CFUN}(f)$ where $f$ is a function from characters -to a boolean. Implement +to a boolean. The idea is that the function $f$ determines which character(s) +are matched, namely those where $f$ returns \texttt{true}. +In this question implement \textit{CFUN} and define \begin{center} \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}} @@ -197,7 +199,7 @@ \end{tabular} \end{center} -\noindent in your matcher and then give definitions for +\noindent in your matcher and then also give definitions for \begin{center} \begin{tabular}{@ {}l@ {\hspace{2mm}}c@ {\hspace{2mm}}l@ {}}