Binary file cws/cw05.pdf has changed
--- a/cws/cw05.tex Thu Dec 06 18:37:17 2018 +0000
+++ b/cws/cw05.tex Thu Dec 06 18:50:53 2018 +0000
@@ -463,7 +463,16 @@
worthwhile overall (of course for the \pcode{>A}'s and so on, the compiler incurs a
penalty). Luckily, after you have performed all
optimisations in (5) - (7), you can expect that the
- \pcode{benchmark.bf} program runs four to five times faster.\hfill{[2 Marks]}
+ \pcode{benchmark.bf} program runs four to five times faster.
+ You can also test whether your compiler produces the correct result
+ by for example testing
+
+ \begin{center}
+ \pcode{run(load_bff("sierpinski.bf")) == run4(load_bff("sierpinski.bf"))}
+ \end{center}
+
+ which should return true for all the different compiler stages. \\
+ \mbox{}\hfill{[2 Marks]}
\end{itemize}
\end{document}
Binary file solutions5/bfc.jar has changed
--- a/solutions5/bfc.scala Thu Dec 06 18:37:17 2018 +0000
+++ b/solutions5/bfc.scala Thu Dec 06 18:50:53 2018 +0000
@@ -1,7 +1,7 @@
// Part 2 about a "Compiler" for the Brainf*** language
//======================================================
-//object CW10b {
+object CW10b {
// !!! Copy any function you need from file bf.scala !!!
//
@@ -254,7 +254,7 @@
def spl(s: String) = splice(s.toList, Nil).reverse
-spl(load_bff("benchmark.bf"))
+//spl(load_bff("benchmark.bf"))
def combine(s: String) : String = {
(for ((c, n) <- spl(s)) yield c match {
@@ -267,7 +267,7 @@
}
-combine(load_bff("benchmark.bf"))
+//combine(load_bff("benchmark.bf"))
def compute4(pg: String, tb: Map[Int, Int], pc: Int, mp: Int, mem: Mem) : Mem = {
if (0 <= pc && pc < pg.length) {
@@ -295,8 +295,8 @@
compute4(pg_opt, jtable(pg_opt), 0, 0, m)
}
-
-combine(optimise(load_bff("benchmark.bf"))) // => """>A+B[<A+M>A-A]<A[[....."""
+// testcases
+//combine(optimise(load_bff("benchmark.bf"))) // => """>A+B[<A+M>A-A]<A[[....."""
//time_needed(1, run4(load_bff("benchmark.bf")))
@@ -306,4 +306,4 @@
//time_needed(1, run4(load_bff("mandelbrot.bf")))
-//}
+}