updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Sun, 05 Sep 2021 23:51:37 +0100
changeset 836 a3418ee8c404
parent 835 08b157566a73
child 837 499405058cfd
updated
cws/build.sc
cws/cw01.pdf
cws/cw02.pdf
cws/cw03.pdf
cws/cw04.pdf
cws/cw04.tex
cws/cw05.pdf
cws/cw05.tex
cwtests/cw03/collatz2.while
cwtests/cw03/fib.while
cwtests/cw03/loops.while
cwtests/cw03/primes.while
cwtests/cw04/fib.while
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cws/build.sc	Sun Sep 05 23:51:37 2021 +0100
@@ -0,0 +1,25 @@
+#!/usr/bin/env amm
+
+val files = List("cw01.tex",
+	         "cw02.tex",
+	         "cw03.tex",
+	         "cw04.tex",
+	         "cw05.tex")
+
+
+
+
+@main
+def make() = {
+  for (f <- files) {
+    println(s"Processing $f ...")
+    os.proc("xelatex", f).call(stdout = os.Inherit, stdin = os.Inherit)
+    os.proc("xelatex", f).call(stdout = os.Inherit, stdin = os.Inherit)
+  }
+}
+
+
+@main
+def hg() = {
+  os.proc("hg", "commit", "-m texupdate", files.mkString(" ")).call()
+}
Binary file cws/cw01.pdf has changed
Binary file cws/cw02.pdf has changed
Binary file cws/cw03.pdf has changed
Binary file cws/cw04.pdf has changed
--- a/cws/cw04.tex	Sat Sep 04 14:09:26 2021 +0100
+++ b/cws/cw04.tex	Sun Sep 05 23:51:37 2021 +0100
@@ -13,7 +13,7 @@
 
 \section*{Coursework 4}
 
-\noindent This coursework is worth 10\% and is due on \cwFOUR{}
+\noindent This coursework is worth 15\% and is due on \cwFOUR{}
 at 18:00. You are asked to implement a compiler for
 the WHILE language that targets the assembler language
 provided by Jasmin or Krakatau (both have a very similar
@@ -82,13 +82,13 @@
 Internet, for example
 
 \begin{center}
-\small\url{http://www.ceng.metu.edu.tr/courses/ceng444/link/f3jasmintutorial.html}
+\small\url{https://saksagan.ceng.metu.edu.tr/courses/ceng444/link/f3jasmintutorial.html}
 \end{center}
 
 \noindent and
 
 \begin{center}
-  \small\url{http://www.csc.villanova.edu/~tway/courses/csc4181/s2018/labs/lab4/JVM.pdf}
+  \small\url{http://www.csc.villanova.edu/~tway/courses/csc4181/s2021/labs/lab4/JVM.pdf}
 \end{center}
 
 \subsection*{Krakatau Assembler}
Binary file cws/cw05.pdf has changed
--- a/cws/cw05.tex	Sat Sep 04 14:09:26 2021 +0100
+++ b/cws/cw05.tex	Sun Sep 05 23:51:37 2021 +0100
@@ -6,11 +6,11 @@
 
 \begin{document}
 
-\section*{Coursework 5\footnote{\today}}
+\section*{Coursework 5}
 
 
 
-\noindent This coursework is worth 12\% and is due on \cwFIVE{} at
+\noindent This coursework is worth 25\% and is due on \cwFIVE{} at
 18:00. You are asked to implement a compiler targeting the LLVM-IR.
 Be careful that this CW needs some material about the LLVM-IR
 that has not been shown in the lectures and your own experiments
@@ -27,8 +27,8 @@
 you generated the LLVM-IR files, otherwise a mark of 0\% will be
 awarded. You should use the lexer and parser from the previous
 courseworks, but you need to make some modifications to them for the
-`typed' fun-language. I will award up to 4\% if a lexer and parser are
-implemented. At the end, please package everything(!) in a zip-file
+`typed' fun-language. I will award up to 5\% if a lexer and a parser are
+correctly implemented. At the end, please package everything(!) in a zip-file
 that creates a directory with the name \texttt{YournameYourFamilyname}
 on my end.
 
@@ -214,7 +214,9 @@
   with simple first-order functions, nothing on the scale
   as the `Hindley-Milner' typing-algorithm is needed. I suggest
   to just look at what data is avaliable and generate all
-  missing information by simple means.
+  missing information by ``simple means''\ldots rather than
+  looking at the literature which solves the problem
+  with much heavier machinery.
 
 \item \textbf{Build-In Functions}: The `prelude' comes
   with several build-in functions: \texttt{new\_line()},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cwtests/cw03/collatz2.while	Sun Sep 05 23:51:37 2021 +0100
@@ -0,0 +1,27 @@
+// Collatz series
+//
+// needs writing of strings and numbers; comments
+
+bnd := 1;
+while bnd < 101 do {
+  write bnd;
+  write ": ";
+  n := bnd;
+  cnt := 0;
+
+  while n > 1 do {
+    write n;
+    write ",";
+    
+    if n % 2 == 0 
+    then n := n / 2 
+    else n := 3 * n+1;
+
+    cnt := cnt + 1
+  };
+
+  write " => ";
+  write cnt;
+  write "\n";
+  bnd := bnd + 1
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cwtests/cw03/fib.while	Sun Sep 05 23:51:37 2021 +0100
@@ -0,0 +1,13 @@
+write "Fib";
+read n;  
+minus1 := 0;
+minus2 := 1;
+while n > 0 do {
+       temp := minus2;
+       minus2 := minus1 + minus2;
+       minus1 := temp;
+       n := n - 1
+};
+write "Result";
+write minus2 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cwtests/cw03/loops.while	Sun Sep 05 23:51:37 2021 +0100
@@ -0,0 +1,14 @@
+start := 1000; 
+x := start;
+y := start;
+z := start;
+while 0 < x do {
+ while 0 < y do {
+  while 0 < z do { z := z - 1 };
+  z := start;
+  y := y - 1
+ };     
+ y := start;
+ x := x - 1
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cwtests/cw03/primes.while	Sun Sep 05 23:51:37 2021 +0100
@@ -0,0 +1,14 @@
+// prints out prime numbers from 2 to 100 
+
+end := 100;
+n := 2;
+while (n < end) do {
+  f := 2;
+  tmp := 0;
+  while ((f < n / 2 + 1) && (tmp == 0)) do {
+    if ((n / f) * f == n) then  { tmp := 1 } else { skip };
+    f := f + 1
+  };
+  if (tmp == 0) then { write(n) } else { skip };
+  n  := n + 1
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cwtests/cw04/fib.while	Sun Sep 05 23:51:37 2021 +0100
@@ -0,0 +1,12 @@
+write "Fib";
+read n;
+minus1 := 0;
+minus2 := 1;
+while n > 0 do {
+temp := minus2;
+minus2 := minus1 + minus2;
+minus1 := temp;
+n := n - 1
+};
+write "Result";
+write minus2