equal
deleted
inserted
replaced
|
1 // for testing parsing |
|
2 |
|
3 import scala.util.{Try, Success, Failure} |
|
4 import $file.cw033_add |
|
5 import cw033_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 parsing 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 AST ${v.toString.take(30)}...") |
|
22 case Failure(e) => println(s"--> FAIL. Exception raised.") ; throw(e) |
|
23 } |
|
24 } |
|
25 |