Minimal support for raw ML pretty printing, notably for toplevel pp.
*)
signature ML_PRETTY = sig datatype context = datatype PolyML.context val markup_get: PolyML.context list -> string * string val markup_context: string * string -> PolyML.context list val no_markup_context: PolyML.context list -> PolyML.context list val open_block_detect: PolyML.context list -> bool val open_block_context: bool -> PolyML.context list datatype pretty = datatype PolyML.pretty val no_markup: pretty -> pretty val block: pretty list -> pretty val str: string -> pretty val brk: FixedInt.int -> pretty val dots: pretty val pair: ('a * FixedInt.int -> pretty) -> ('b * FixedInt.int -> pretty) ->
('a * 'b) * FixedInt.int -> pretty val enum: string -> string -> string -> ('a * FixedInt.int -> pretty) -> 'a list * FixedInt.int -> pretty val prune: FixedInt.int -> pretty -> pretty val format: int -> pretty -> string val default_margin: int val get_margin: int option -> int val string_of: pretty -> string val make_string_fn: string end;
structure ML_Pretty: ML_PRETTY = struct
(** context **)
(* properties *)
datatype context = datatype PolyML.context;
fun get_property context name =
(caseList.find (fn ContextProperty (a, _) => name = a | _ => false) context of
SOME (ContextProperty (_, b)) => b
| _ => "");
(* markup *)
val markup_bg = "markup_bg"; val markup_en = "markup_en";
fun markup_get context = let val bg = get_property context markup_bg; val en = get_property context markup_en; in (bg, en) end;
fun format margin prt = let val result = Unsynchronized.ref []; val () = PolyML.prettyPrint (fn s => result := s :: ! result, margin) prt; in implode (rev (! result)) end;
val default_margin = 76;
val get_margin = the_default default_margin;
(* make string *)
val string_of = format default_margin;
val make_string_fn = "(fn x => ML_Pretty.string_of (ML_system_pretty \
\(x, FixedInt.fromInt (ML_Print_Depth.get_print_depth ()))))";
end;
¤ Dauer der Verarbeitung: 0.6 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.