1
+ open Model_Checker;
2
+
3
+ (* ** Printing utilites ***)
4
+ fun println s = print (s ^ " \n " )
5
+
6
+ fun list_to_string f = (fn x => " [" ^ x ^ " ]" ) o String.concatWith " , " o map f;
7
+
8
+ fun print_result NONE = println(" Invalid input\n " )
9
+ | print_result (SOME true ) = println(" Property is satisfied\n " )
10
+ | print_result (SOME false ) = println(" Property is not satisfied\n " )
11
+
12
+ (* ** Wrapping up the checker ***)
13
+ fun run_and_print check_deadlock s =
14
+ let
15
+ val debug_level: Int32.int Unsynchronized.ref = ref 0
16
+ val _ = debug_level := 2
17
+ val t = Time.now ()
18
+ val r = parse_convert_run check_deadlock s ()
19
+ val t = Time.- (Time.now (), t)
20
+ val _ = println(" " )
21
+ val _ = println(" Internal time for precondition check + actual checking: " ^ Time.toString t)
22
+ val _ = println(" " )
23
+ in
24
+ case r of
25
+ Error es => let
26
+ val _ = println " Failure:"
27
+ val _ = map println es
28
+ in () end
29
+ | Result r => let
30
+ val _ = if !debug_level >= 1 then let
31
+ val _ = println(" # explored states: " ^ Int.toString(Tracing.get_count ()))
32
+ val _ = println(" " )
33
+ in () end else ()
34
+ in println r end
35
+ end ;
36
+
37
+ fun read_lines stream =
38
+ let
39
+ val input = TextIO.inputLine stream
40
+ handle Size => (println " Input line too long!" ; raise Size)
41
+ in
42
+ case input of
43
+ NONE => " "
44
+ | SOME input => input ^ read_lines stream
45
+ end ;
46
+
47
+ fun check_and_verify_from_stream stream _ =
48
+ let
49
+ val args = CommandLine.arguments()
50
+ val check_deadlock = List.find (fn x => x = " -deadlock" orelse x = " -dc" ) args <> NONE
51
+ val input = read_lines stream
52
+ in
53
+ if input = " "
54
+ then println " Failed to read line from input!"
55
+ (* We append a space to terminate the input for the parser *)
56
+ else input ^ " " |> run_and_print check_deadlock
57
+ end ;
0 commit comments