diff -r 5deefcc8cffa -r e3acf2bf3895 coursework/cw02.tex --- a/coursework/cw02.tex Tue Sep 20 12:24:29 2016 +0100 +++ b/coursework/cw02.tex Tue Sep 20 12:25:09 2016 +0100 @@ -6,25 +6,26 @@ \section*{Coursework 2 (Strand 1)} -\noindent This coursework is worth 5\% and is due on 6 +\noindent This coursework is worth 4\% and is due on 3 November at 16:00. You are asked to implement the Sulzmann \& -Lu tokeniser for the WHILE language. You can do the +Lu lexer for the WHILE language. You can do the implementation in any programming language you like, but you need to submit the source code with which you answered the questions, otherwise a mark of 0\% will be awarded. You can -submit your answers in a txt-file or as pdf. +submit your answers in a txt-file or as pdf. Code submit as +code. \subsection*{Disclaimer} It should be understood that the work you submit represents your own effort. You have not copied from anyone else. An exception is the Scala code from KEATS and the code I showed -during the lectures, which you can both use. You can also use -your own code from the CW~1. +during the lectures, which you can both freely use. You can +also use your own code from the CW~1. -\subsection*{Question 1 (marked with 1\%)} +\subsection*{Question 1} -To implement a tokeniser for the WHILE language, you first +To implement a lexer for the WHILE language, you first need to design the appropriate regular expressions for the following eight syntactic entities: @@ -78,7 +79,7 @@ You can use the basic regular expressions \[ -\varnothing, \epsilon, c, r_1 + r_2, r_1 \cdot r_2, r^* +\ZERO,\; \ONE,\; c,\; r_1 + r_2,\; r_1 \cdot r_2,\; r^* \] \noindent @@ -97,9 +98,9 @@ small as possible. For example you should use character ranges for identifiers and numbers. -\subsection*{Question 2 (marked with 3\%)} +\subsection*{Question 2} -Implement the Sulzmann \& Lu tokeniser from the lectures. For +Implement the Sulzmann \& Lu lexer 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 $inj$. These functions need to be appropriately extended for @@ -138,7 +139,7 @@ Also add the record regular expression from the -lectures to your tokeniser and implement a function, say +lectures to your lexer 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 @@ -154,11 +155,11 @@ and use your \pcode{env} function to give the token sequence. -\subsection*{Question 3 (marked with 1\%)} +\subsection*{Question 3} -Extend your tokenizer from Q2 to also simplify regular expressions +Extend your lexer from Q2 to also simplify regular expressions after each derivation step and rectify the computed values after each -injection. Use this tokenizer to tokenize the programs in +injection. Use this lexer to tokenize the programs in Figure~\ref{fib} and \ref{loop}. Give the tokens of these programs where whitespaces are filtered out.