cw2_marking/c3.sc
changeset 978 8778d23fef92
equal deleted inserted replaced
977:1e6eca42d90b 978:8778d23fef92
       
     1 // for testing tokenisation
       
     2 
       
     3 import scala.util.{Try, Success, Failure}
       
     4 import $file.cw023_add
       
     5 import cw023_add._
       
     6 
       
     7 // programs to test (and number of toplevel definitions)
       
     8 val uprogs = List("collatz.while", 
       
     9                   "collatz2.while", 
       
    10 		  "factors.while",  
       
    11 		  "fib.while",      
       
    12                   "loops.while",    
       
    13                   "primes.while") 
       
    14 
       
    15 for (file <- uprogs) {
       
    16 
       
    17   print(s"  Testing lexing with ${file.padTo(16, ' ')} ")
       
    18   val str = os.read(os.pwd / file)
       
    19   
       
    20   Try(test_string(str)) match {
       
    21     case Success(v) => println(s"--> Success. Generated ${v.toString.take(30)}...")
       
    22     case Failure(e) => println(s"--> FAIL. Exception raised.") ; throw(e)
       
    23   }
       
    24 }