Skip to content

Commit ffcb433

Browse files
committed
ML code for new input language
1 parent 6eec984 commit ffcb433

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

ML/Muntax.sml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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;

ML/Writeln.sml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fun writeln s = (print s; print "\n")

ML/muntax.mlb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$(SML_LIB)/basis/basis.mlb
2+
$(SML_LIB)/basis/mlton.mlb
3+
4+
local
5+
Unsynchronized.sml
6+
7+
Writeln.sml
8+
9+
ann "nonexhaustiveMatch ignore" in
10+
Simple_Model_Checker.sml
11+
end
12+
in
13+
structure Tracing
14+
structure Model_Checker
15+
end
16+
17+
basics.ML
18+
ann "nonexhaustiveMatch ignore" in
19+
library.ML
20+
end
21+
Unsynchronized.sml
22+
Muntax.sml
23+
Mlton_Main.sml

0 commit comments

Comments
 (0)