1 |
1 |
2 fun exit 0 = (OS.Process.exit OS.Process.success): unit |
2 fun exit 0 = (OS.Process.exit OS.Process.success): unit |
3 | exit _ = OS.Process.exit OS.Process.failure; |
3 | exit _ = OS.Process.exit OS.Process.failure; |
4 |
4 |
5 use "ML-Systems/polyml.ML"; |
5 fun reraise exn = |
|
6 (case PolyML.exceptionLocation exn of |
|
7 NONE => raise exn |
|
8 | SOME location => PolyML.raiseWithLocation (exn, location)); |
6 |
9 |
7 print_depth 10; |
10 exception Interrupt = SML90.Interrupt; |
|
11 val ord = SML90.ord; |
|
12 val chr = SML90.chr; |
|
13 val raw_explode = SML90.explode; |
|
14 val implode = SML90.implode; |
|
15 |
|
16 val pointer_eq = PolyML.pointerEq; |
|
17 |
|
18 val exception_trace = PolyML.exception_trace; |
|
19 |
|
20 open Thread; |
|
21 val seconds = Time.fromReal; |
|
22 use "General/exn.ML"; |
|
23 use "ML-Systems/multithreading.ML"; |
|
24 use "ML-Systems/multithreading_polyml.ML"; |
|
25 use "ML-Systems/unsynchronized.ML"; |
|
26 |
|
27 use "ML-Systems/ml_pretty.ML"; |
|
28 |
|
29 val pretty_ml = |
|
30 let |
|
31 fun convert len (PolyML.PrettyBlock (ind, _, context, prts)) = |
|
32 let |
|
33 fun property name default = |
|
34 (case List.find (fn PolyML.ContextProperty (a, _) => name = a | _ => false) context of |
|
35 SOME (PolyML.ContextProperty (_, b)) => b |
|
36 | NONE => default); |
|
37 val bg = property "begin" ""; |
|
38 val en = property "end" ""; |
|
39 val len' = property "length" len; |
|
40 in ML_Pretty.Block ((bg, en), map (convert len') prts, ind) end |
|
41 | convert len (PolyML.PrettyString s) = |
|
42 ML_Pretty.String (s, case Int.fromString len of SOME i => i | NONE => size s) |
|
43 | convert _ (PolyML.PrettyBreak (wd, _)) = |
|
44 ML_Pretty.Break (if wd < 99999 then (false, wd) else (true, 2)); |
|
45 in convert "" end; |
|
46 |
|
47 fun ml_pretty (ML_Pretty.Block ((bg, en), prts, ind)) = |
|
48 let val context = |
|
49 (if bg = "" then [] else [PolyML.ContextProperty ("begin", bg)]) @ |
|
50 (if en = "" then [] else [PolyML.ContextProperty ("end", en)]) |
|
51 in PolyML.PrettyBlock (ind, false, context, map ml_pretty prts) end |
|
52 | ml_pretty (ML_Pretty.String (s, len)) = |
|
53 if len = size s then PolyML.PrettyString s |
|
54 else PolyML.PrettyBlock |
|
55 (0, false, [PolyML.ContextProperty ("length", Int.toString len)], [PolyML.PrettyString s]) |
|
56 | ml_pretty (ML_Pretty.Break (false, wd)) = PolyML.PrettyBreak (wd, 0) |
|
57 | ml_pretty (ML_Pretty.Break (true, _)) = PolyML.PrettyBreak (99999, 0); |
8 |
58 |
9 use "General/basics.ML"; |
59 use "General/basics.ML"; |
10 use "library.ML"; |
60 use "library.ML"; |
11 use "General/alist.ML"; |
61 use "General/alist.ML"; |
12 use "General/table.ML"; |
62 use "General/table.ML"; |