--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cw3_marking/c3.sc Mon Feb 03 12:34:38 2025 +0000
@@ -0,0 +1,25 @@
+// for testing parsing
+
+import scala.util.{Try, Success, Failure}
+import $file.cw033_add
+import cw033_add._
+
+// programs to test (and number of toplevel definitions)
+val uprogs = List("collatz.while",
+ "collatz2.while",
+ "factors.while",
+ "fib.while",
+ "loops.while",
+ "primes.while")
+
+for (file <- uprogs) {
+
+ print(s" Testing parsing with ${file.padTo(16, ' ')} ")
+ val str = os.read(os.pwd / file)
+
+ Try(test_string(str)) match {
+ case Success(v) => println(s"--> Success. Generated AST ${v.toString.take(30)}...")
+ case Failure(e) => println(s"--> FAIL. Exception raised.") ; throw(e)
+ }
+}
+