--- a/solutions/cw4/compiler.sc Tue Sep 19 09:54:41 2023 +0100
+++ b/solutions/cw4/compiler.sc Tue Sep 19 12:56:10 2023 +0100
@@ -280,4 +280,23 @@
println(tokenise(os.read(os.pwd / "forloop.while")))
-compile_run(Stmts.parse_all(tokenise(os.read(os.pwd / "forloop.while"))).head, "forloop")
\ No newline at end of file
+compile_all(Stmts.parse_all(tokenise(os.read(os.pwd / "forloop.while"))).head, "forloop")
+
+
+
+// for automated testing
+
+@main
+def main(file: String) = {
+ // empty - nothing to run
+}
+
+@main
+def test(file: String) = {
+ val contents = os.read(os.pwd / file)
+ val class_name = file.stripSuffix(".")
+ compile_all(Stmts.parse_all(tokenise(os.read(os.pwd / file))).head, class_name)
+ tokenise(contents)
+}
+
+