# HG changeset patch # User Christian Urban # Date 1759064639 -3600 # Node ID c3dd3a98f919d0b6bcc323baf75c8a4970c2b0ed # Parent 5d01eccc20365c0efe84074ed0ee4a6460307efe updated diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw01.pdf Binary file cws/cw01.pdf has changed diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw02.pdf Binary file cws/cw02.pdf has changed diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw02.tex --- a/cws/cw02.tex Fri Sep 26 23:10:52 2025 +0100 +++ b/cws/cw02.tex Sun Sep 28 14:03:59 2025 +0100 @@ -35,11 +35,13 @@ \subsection*{Disclaimer\alert} It should be understood that the work you submit represents -your own effort. You have not copied from anyone else -including CoPilot, ChatGPT \& Co. An +your own effort. +%You have not copied from anyone else +%including CoPilot, ChatGPT \& Co. +An exception is the Scala code from KEATS and the code I showed during the lectures, which you can both freely use. You can -also use your own code from the CW~1. +also use your own code from CW~1. %But do not %be tempted to ask Github Copilot for help or do any other %shenanigans like this! @@ -104,7 +106,7 @@ \texttt{$\backslash$t} or \texttt{$\backslash$r} \item identifiers are letters followed by underscores \texttt{\_\!\_}, letters or digits -\item numbers for numbers give +\item for numbers give a regular expression that can recognise \pcode{0}, but not numbers with leading zeroes, such as \pcode{001} \item strings are enclosed by double quotes, like \texttt{"\ldots"}, and consisting of @@ -152,7 +154,7 @@ 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 -the extended regular expressions from Q1. The definitions +the extended regular expressions from Task 1. The definitions you need to create are: @@ -195,7 +197,7 @@ \noindent Finally make that the function \texttt{lexing\_simp} generates -with the regular expression from Q1 for the string +with the regular expression from Task 1 for the string \begin{center} \code{"read n;"} @@ -214,7 +216,7 @@ \subsection*{Task 3} -Make sure your lexer from Q2 also simplifies regular expressions after +Make sure your lexer from Task 2 also simplifies regular expressions after each derivation step and rectifies the computed values after each injection. Use this lexer to tokenise the six WHILE programs in the \texttt{examples} directory. Make sure that the \texttt{tokenise} diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw03.pdf Binary file cws/cw03.pdf has changed 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} diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw04.pdf Binary file cws/cw04.pdf has changed diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw04.tex --- a/cws/cw04.tex Fri Sep 26 23:10:52 2025 +0100 +++ b/cws/cw04.tex Sun Sep 28 14:03:59 2025 +0100 @@ -32,10 +32,11 @@ 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, -which you can use. You can also use your own code from the -CW~1, CW~2 and CW~3. But do not -be tempted to ask Github Copilot for help or do any other -shenanigans like this! +which you can use. You can also use your own code from +CW~1, CW~2 and CW~3. +%But do not +%be tempted to ask Github Copilot for help or do any other +%shenanigans like this! \subsection*{Jasmin Assembler} @@ -48,7 +49,8 @@ \end{center} \noindent -This is a jar-file you can run on the commandline. +This jar-file is also included in your template files for CW 4. +You can run it on the command line with \texttt{java -jar jasmin}. There is a user guide for Jasmin \begin{center} @@ -69,7 +71,7 @@ \texttt{java -jar jasmin.jar loops.j} \end{center} -\noindent in order to translate it into Java Byte Code. If needed, you +\noindent in order to translate it into Java Byte Code. If relevant, you need to give the path to the Jasmin jar-file. The resulting class file can be run with @@ -94,10 +96,11 @@ \noindent and \begin{center} - \small\url{http://www.csc.villanova.edu/~tway/courses/csc4181/s2022/labs/finalproject/JVM.pdf} + \small\url{https://urbanchr.github.io/cfl/JVM.pdf} \end{center} \noindent +The latter is courtesy of Tom Way. If possible use Jasmin for the coursework. The Krakatau assembler below has a slightly different syntax. diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw05.pdf Binary file cws/cw05.pdf has changed diff -r 5d01eccc2036 -r c3dd3a98f919 cws/cw05.tex --- a/cws/cw05.tex Fri Sep 26 23:10:52 2025 +0100 +++ b/cws/cw05.tex Sun Sep 28 14:03:59 2025 +0100 @@ -85,7 +85,7 @@ 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 -- +you can both use. You can also use your own code from CW~1 -- CW~4. %But do not %be tempted to ask Github Copilot for help or do any other %shenanigans like this! @@ -93,7 +93,7 @@ \subsection*{Task} -The goal is to lex and parse 5 Fun-programs, including the +The goal is to lex and parse five Fun-programs, including the Mandelbrot program shown in Figure~\ref{mand}, and generate corresponding code for the LLVM-IR. Unfortunately the calculations for the Mandelbrot Set require floating point arithmetic and therefore we