@@ -8,7 +8,7 @@ fun print_timings () =
8
8
in map print_time tab; () end
9
9
10
10
(* ** Wrapping up the checker ***)
11
- fun
11
+ fun run_and_print
12
12
implementation num_threads check_deadlock s =
13
13
let
14
14
val debug_level: Int32.int Unsynchronized.ref = ref 0
@@ -46,7 +46,7 @@ fun check_and_verify_from_stream implementation num_threads model check_deadlock
46
46
if input = " "
47
47
then println " Failed to read line from input!"
48
48
(* We append a space to terminate the input for the parser *)
49
- else input ^ " " |>
49
+ else input ^ " " |> run_and_print
50
50
implementation num_threads check_deadlock
51
51
end ;
52
52
@@ -105,17 +105,25 @@ fun read_and_check check_deadlock (model, certificate, renaming, implementation,
105
105
)
106
106
end
107
107
108
+ val arguments = common_arguments @ [
109
+ ([" show-cert" , " sc" ], " Print the certificate." , Flag),
110
+ ([" renaming" , " r" ], " Path to renaming JSON." , Arg),
111
+ ([" certificate" , " c" ], " Path to binary certificate." , Arg),
112
+ ([" implementation" , " i" ], " The certifier variant to choose." , Arg)
113
+ ]
114
+
108
115
fun main () =
109
116
let
110
- val args = CommandLine.arguments()
111
- val check_deadlock = List.find (fn x => x = " -deadlock" orelse x = " -dc" ) args <> NONE
112
- val cpu_time = List.find (fn x => x = " -cpu-time" orelse x = " -cpu" ) args <> NONE
113
- val model = find_with_arg (fn x => x = " -model" orelse x = " -m" ) args
114
- val certificate = find_with_arg (fn x => x = " -certificate" orelse x = " -c" ) args
115
- val renaming = find_with_arg (fn x => x = " -renaming" orelse x = " -r" ) args
116
- val num_threads = find_with_arg (fn x => x = " -num-threads" orelse x = " -n" ) args
117
- val implementation = find_with_arg (fn x => x = " -implementation" orelse x = " -i" ) args
118
- val show_cert = List.find (fn x => x = " -explored" orelse x = " -e" ) args <> NONE
117
+ val _ = read_arguments arguments
118
+ val check_deadlock = is_present " deadlock"
119
+ val cpu_time = is_present " cpu-time"
120
+ val model = find_arg " model"
121
+ val num_threads = find_arg " num-threads"
122
+ val show_help = is_present " help"
123
+ val certificate = find_arg " certificate"
124
+ val renaming = find_arg " renaming"
125
+ val implementation = find_arg " implementation"
126
+ val show_cert = is_present " show-cert"
119
127
fun convert f NONE = NONE
120
128
| convert f (SOME x) = SOME (f x)
121
129
handle Fail msg => (println (" Argument error: " ^ msg); OS.Process.exit OS.Process.failure)
@@ -151,17 +159,21 @@ fun main () =
151
159
val args = [model, certificate, renaming]
152
160
val _ = if cpu_time then Timing.set_cpu true else ()
153
161
in
154
- if certificate = NONE andalso renaming = NONE andalso model <> NONE then
155
- (
156
- println " Falling back to munta!" ;
157
- check_and_verify_from_stream implementation num_threads (the model) check_deadlock
162
+ if show_help then
163
+ print_usage arguments
164
+ else (
165
+ if certificate = NONE andalso renaming = NONE andalso model <> NONE then
166
+ (
167
+ println " Falling back to munta!" ;
168
+ check_and_verify_from_stream implementation num_threads (the model) check_deadlock
169
+ )
170
+ else if exists (fn x => x = NONE ) args then
171
+ println " Missing command line arguments!"
172
+ else
173
+ let
174
+ val [model, certificate, renaming] = map the args
175
+ in
176
+ read_and_check check_deadlock (model, certificate, renaming, implementation, num_threads, show_cert)
177
+ end
158
178
)
159
- else if exists (fn x => x = NONE ) args then
160
- println " Missing command line arguments!"
161
- else
162
- let
163
- val [model, certificate, renaming] = map the args
164
- in
165
- read_and_check check_deadlock (model, certificate, renaming, implementation, num_threads, show_cert)
166
- end
167
179
end
0 commit comments