cw3_marking/c3.sc
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 03 Feb 2025 12:34:38 +0000
changeset 978 8778d23fef92
permissions -rw-r--r--
updated marking scripts

// 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)
  }
}