diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw03.tex --- a/cws/cw03.tex Fri Sep 26 23:10:52 2025 +0100 +++ b/cws/cw03.tex Sun Sep 28 14:03:59 2025 +0100 @@ -22,20 +22,21 @@ explained during the lectures. This might make your grammar simpler. However, make sure you understand the code involved in the ``hack'' because if you just do ``mix-and-match'' you will receive -strange errors. The main function that will be tested is called +strange error messages. The main function that will be tested is called \texttt{eval} and \texttt{Stmts.parse\_all}. The latter expects a list of tokens as input and generates an AST. The former expects an AST and ``runs'' the program. The marks will be distributed such that 6 marks are given for the correct grammar (and parsers); 4 marks for the correct \texttt{eval} function. You should use the lexer from CW2 for the -parser - you potentially need to make additions for CW3. +parser - you potentially need to make modifications to the regular +expressions for CW3. \subsection*{Disclaimer\alert} 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 I showed during the lectures or uploaded to KEATS, which -you can both use. You can also use your own code from the CW~1 and +you can both use. You can also use your own code from CW~1 and CW~2. %But do not %be tempted to ask Github Copilot for help or do any other @@ -133,17 +134,20 @@ from Task 1, parse the assignments of the form \begin{quote} -\texttt{... += ...} \;\;and\;\; \texttt{... *= ...} +\texttt{... += ...} \;\;, \texttt{... -= ...} \;\; and\;\; \texttt{... *= ...} \end{quote} +\noindent and translate them into simple assignments. For example \begin{quote} \texttt{cnt += 1} \end{quote} -should give the assignment \texttt{cnt := cnt + 1}. Similarly -for \texttt{*=}. +\noindent +should produce the assignment \texttt{cnt := cnt + 1}. Similarly +for \texttt{-=} and \texttt{*=}. Be careful to \emph{translate} these +assignments---they should not produce a separate AST-node. \subsection*{Task 4}