equal
deleted
inserted
replaced
60 |
60 |
61 |
61 |
62 |
62 |
63 \section*{Coursework 2} |
63 \section*{Coursework 2} |
64 |
64 |
|
65 {\bf UPDATE:} There was a typo in Q1 about the regular expressions for comments: |
|
66 they should, of course, start with $\slash\slash$, as in C for example, not with |
|
67 $\backslash\backslash$.\bigskip\bigskip |
|
68 |
|
69 \noindent |
65 This coursework is worth 3\% and is due on 27 November at 16:00. You are asked to |
70 This coursework is worth 3\% and is due on 27 November at 16:00. You are asked to |
66 |
71 |
67 \begin{enumerate} |
72 \begin{enumerate} |
68 \item implement a tokeniser for the WHILE language, |
73 \item implement a tokeniser for the WHILE language, |
69 \item implement a parser and an evaluator for boolean and arithmetic expressions, and |
74 \item implement a parser and an evaluator for boolean and arithmetic expressions, and |
99 |
104 |
100 \item strings are enclosed by \texttt{"\ldots"} |
105 \item strings are enclosed by \texttt{"\ldots"} |
101 \item parentheses are \texttt{(}, \texttt{\{}, \texttt{)} and \texttt{\}} |
106 \item parentheses are \texttt{(}, \texttt{\{}, \texttt{)} and \texttt{\}} |
102 \item there are semicolons \texttt{;} |
107 \item there are semicolons \texttt{;} |
103 \item whitespaces are either \texttt{" "} or \texttt{$\backslash$n} |
108 \item whitespaces are either \texttt{" "} or \texttt{$\backslash$n} |
104 \item comments either start with $\backslash\,\backslash$ and run to the end of the corresponding line |
109 \item comments either start with $\slash\,\slash$ and run to the end of the corresponding line |
105 (indicated by \texttt{$\backslash$n}), or they can also run over several lines but then need to be enclosed by |
110 (indicated by \texttt{$\backslash$n}), or they can also run over several lines but then need to be enclosed by |
106 $\slash\texttt{*}$ as the beginning marker and $\texttt{*}\slash{}$\smallskip as the end marker |
111 $\slash\texttt{*}$ as the beginning marker and $\texttt{*}\slash{}$\smallskip as the end marker |
107 \item identifiers are letters followed by underscores \texttt{\_\!\_}, letters |
112 \item identifiers are letters followed by underscores \texttt{\_\!\_}, letters |
108 or digits |
113 or digits |
109 \item numbers are \texttt{0}, \text{1}, \ldots |
114 \item numbers are \texttt{0}, \text{1}, \ldots |