ML toplevel pretty-printing for logical entities.
*)
signature ML_PP = sig val toplevel_context: unit -> Proof.context val pp_context: Proof.context -> Pretty.T val pp_typ: Proof.context -> typ -> Pretty.T val pp_term: Proof.context -> term -> Pretty.T val pp_thm: Proof.context -> thm -> Pretty.T end;
structure ML_PP: ML_PP = struct
(* logical context *)
(*ML compiler toplevel context: fallback on theory Pure for regular runtime*) fun toplevel_context () = let fun global_context () =
Theory.get_pure ()
|> Config.put_global Name_Space.names_long true
|> Syntax.init_pretty_global; in
(case Context.get_generic_context () of
SOME (Context.Proof ctxt) => ctxt
| SOME (Context.Theory thy) =>
(casetry Syntax.init_pretty_global thy of
SOME ctxt => ctxt
| NONE => global_context ())
| NONE => global_context ()) end;
fun pp_context ctxt =
(if Config.get ctxt Proof_Context.debug then
Pretty.quote (Pretty.big_list "proof context:" (Proof_Context.pretty_context ctxt)) else Pretty.str "");
(* logical entities (with syntax) *)
fun pp_typ ctxt T = Pretty.quote (Syntax.pretty_typ ctxt T); fun pp_term ctxt t = Pretty.quote (Syntax.pretty_term ctxt t); fun pp_thm ctxt th = Thm.pretty_thm_raw ctxt {quote = true, show_hyps = false} th;
val _ =
ML_system_pp (fn _ => fn _ => Pretty.to_ML o pp_context);
and prt_proofs parens dp prf = let val (head, args) = strip_proof prf []; val prts =
head (dp - 1) :: flat (map_index (fn (i, prt) => prt (dp - FixedInt.fromInt i - 2)) args); inif parens then Pretty.enclose "("")" prts else Pretty.block prts end
and strip_proof (p % t) res =
strip_proof p
((fn d =>
[Pretty.str " %", Pretty.brk 1,
Pretty.from_ML (ML_system_pretty (t, d))]) :: res)
| strip_proof (p %% q) res =
strip_proof p ((fn d => [Pretty.str " %%", Pretty.brk 1, prt_proof true d q]) :: res)
| strip_proof p res = (fn d => prt_proof true d p, res);
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.