# HG changeset patch # User wenzelm # Date 1313061742 -7200 # Node ID 4231c55b2d5e97b8bb0b5b2e066075f469f7f1f5 # Parent aefbb5cc890885ec50ed9fea03f77454200759a9 disentangled nested ML files; diff -r aefbb5cc8908 -r 4231c55b2d5e Admin/polyml/future/ROOT.ML --- a/Admin/polyml/future/ROOT.ML Thu Aug 11 13:05:23 2011 +0200 +++ b/Admin/polyml/future/ROOT.ML Thu Aug 11 13:22:22 2011 +0200 @@ -2,9 +2,59 @@ fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure; -use "ML-Systems/polyml.ML"; +fun reraise exn = + (case PolyML.exceptionLocation exn of + NONE => raise exn + | SOME location => PolyML.raiseWithLocation (exn, location)); + +exception Interrupt = SML90.Interrupt; +val ord = SML90.ord; +val chr = SML90.chr; +val raw_explode = SML90.explode; +val implode = SML90.implode; + +val pointer_eq = PolyML.pointerEq; + +val exception_trace = PolyML.exception_trace; + +open Thread; +val seconds = Time.fromReal; +use "General/exn.ML"; +use "ML-Systems/multithreading.ML"; +use "ML-Systems/multithreading_polyml.ML"; +use "ML-Systems/unsynchronized.ML"; + +use "ML-Systems/ml_pretty.ML"; -print_depth 10; +val pretty_ml = + let + fun convert len (PolyML.PrettyBlock (ind, _, context, prts)) = + let + fun property name default = + (case List.find (fn PolyML.ContextProperty (a, _) => name = a | _ => false) context of + SOME (PolyML.ContextProperty (_, b)) => b + | NONE => default); + val bg = property "begin" ""; + val en = property "end" ""; + val len' = property "length" len; + in ML_Pretty.Block ((bg, en), map (convert len') prts, ind) end + | convert len (PolyML.PrettyString s) = + ML_Pretty.String (s, case Int.fromString len of SOME i => i | NONE => size s) + | convert _ (PolyML.PrettyBreak (wd, _)) = + ML_Pretty.Break (if wd < 99999 then (false, wd) else (true, 2)); + in convert "" end; + +fun ml_pretty (ML_Pretty.Block ((bg, en), prts, ind)) = + let val context = + (if bg = "" then [] else [PolyML.ContextProperty ("begin", bg)]) @ + (if en = "" then [] else [PolyML.ContextProperty ("end", en)]) + in PolyML.PrettyBlock (ind, false, context, map ml_pretty prts) end + | ml_pretty (ML_Pretty.String (s, len)) = + if len = size s then PolyML.PrettyString s + else PolyML.PrettyBlock + (0, false, [PolyML.ContextProperty ("length", Int.toString len)], [PolyML.PrettyString s]) + | ml_pretty (ML_Pretty.Break (false, wd)) = PolyML.PrettyBreak (wd, 0) + | ml_pretty (ML_Pretty.Break (true, _)) = PolyML.PrettyBreak (99999, 0); use "General/basics.ML"; use "library.ML";