2001-09-07 01:00:42 -07:00
|
|
|
(* camlp4r *)
|
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Camlp4 *)
|
|
|
|
(* *)
|
|
|
|
(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
2002-02-13 04:34:45 -08:00
|
|
|
(* Copyright 2002 Institut National de Recherche en Informatique et *)
|
2001-09-07 01:00:42 -07:00
|
|
|
(* Automatique. Distributed only by permission. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
open Format;
|
|
|
|
open Outcometree;
|
|
|
|
|
|
|
|
exception Ellipsis;
|
|
|
|
value cautious f ppf arg =
|
|
|
|
try f ppf arg with [ Ellipsis -> fprintf ppf "..." ]
|
|
|
|
;
|
|
|
|
|
|
|
|
value rec print_ident ppf =
|
|
|
|
fun
|
|
|
|
[ Oide_ident s -> fprintf ppf "%s" s
|
|
|
|
| Oide_dot id s -> fprintf ppf "%a.%s" print_ident id s
|
|
|
|
| Oide_apply id1 id2 ->
|
|
|
|
fprintf ppf "%a(%a)" print_ident id1 print_ident id2 ]
|
|
|
|
;
|
|
|
|
|
|
|
|
value value_ident ppf name =
|
|
|
|
if List.mem name ["or"; "mod"; "land"; "lor"; "lxor"; "lsl"; "lsr"; "asr"]
|
|
|
|
then
|
|
|
|
fprintf ppf "( %s )" name
|
|
|
|
else
|
|
|
|
match name.[0] with
|
|
|
|
[ 'a'..'z' | '\223'..'\246' | '\248'..'\255' | '_' ->
|
|
|
|
fprintf ppf "%s" name
|
|
|
|
| _ -> fprintf ppf "( %s )" name ]
|
|
|
|
;
|
|
|
|
|
|
|
|
(* Values *)
|
|
|
|
|
|
|
|
value print_out_value ppf tree =
|
|
|
|
let rec print_tree ppf =
|
|
|
|
fun
|
|
|
|
[ Oval_constr name ([_ :: _] as params) ->
|
|
|
|
fprintf ppf "@[<1>%a@ %a@]" print_ident name
|
|
|
|
(print_tree_list print_simple_tree "") params
|
|
|
|
| Oval_variant name (Some param) ->
|
|
|
|
fprintf ppf "@[<2>`%s@ %a@]" name print_simple_tree param
|
|
|
|
| tree -> print_simple_tree ppf tree ]
|
|
|
|
and print_simple_tree ppf =
|
|
|
|
fun
|
|
|
|
[ Oval_int i -> fprintf ppf "%i" i
|
2003-07-15 02:14:00 -07:00
|
|
|
| Oval_int32 i -> fprintf ppf "%ldl" i
|
|
|
|
| Oval_int64 i -> fprintf ppf "%LdL" i
|
|
|
|
| Oval_nativeint i -> fprintf ppf "%ndn" i
|
2001-09-07 01:00:42 -07:00
|
|
|
| Oval_float f -> fprintf ppf "%.12g" f
|
|
|
|
| Oval_char c -> fprintf ppf "'%s'" (Char.escaped c)
|
|
|
|
| Oval_string s ->
|
|
|
|
try fprintf ppf "\"%s\"" (String.escaped s) with
|
|
|
|
[ Invalid_argument "String.create" -> fprintf ppf "<huge string>" ]
|
|
|
|
| Oval_list tl ->
|
|
|
|
fprintf ppf "@[<1>[%a]@]" (print_tree_list print_tree ";") tl
|
|
|
|
| Oval_array tl ->
|
|
|
|
fprintf ppf "@[<2>[|%a|]@]" (print_tree_list print_tree ";") tl
|
|
|
|
| Oval_constr (Oide_ident "true") [] -> fprintf ppf "True"
|
|
|
|
| Oval_constr (Oide_ident "false") [] -> fprintf ppf "False"
|
|
|
|
| Oval_constr name [] -> print_ident ppf name
|
|
|
|
| Oval_variant name None -> fprintf ppf "`%s" name
|
|
|
|
| Oval_stuff s -> fprintf ppf "%s" s
|
|
|
|
| Oval_record fel ->
|
|
|
|
fprintf ppf "@[<1>{%a}@]" (cautious (print_fields True)) fel
|
|
|
|
| Oval_tuple tree_list ->
|
|
|
|
fprintf ppf "@[(%a)@]" (print_tree_list print_tree ",") tree_list
|
|
|
|
| Oval_ellipsis -> raise Ellipsis
|
|
|
|
| Oval_printer f -> f ppf
|
|
|
|
| tree -> fprintf ppf "@[<1>(%a)@]" (cautious print_tree) tree ]
|
|
|
|
and print_fields first ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [(name, tree) :: fields] ->
|
|
|
|
let name =
|
|
|
|
match name with
|
|
|
|
[ Oide_ident "contents" -> Oide_ident "val"
|
|
|
|
| x -> x ]
|
|
|
|
in
|
|
|
|
do {
|
|
|
|
if not first then fprintf ppf ";@ " else ();
|
|
|
|
fprintf ppf "@[<1>%a=@,%a@]" print_ident name (cautious print_tree)
|
|
|
|
tree;
|
|
|
|
print_fields False ppf fields
|
|
|
|
} ]
|
|
|
|
and print_tree_list print_item sep ppf tree_list =
|
|
|
|
let rec print_list first ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [tree :: tree_list] ->
|
|
|
|
do {
|
|
|
|
if not first then fprintf ppf "%s@ " sep else ();
|
|
|
|
print_item ppf tree;
|
|
|
|
print_list False ppf tree_list
|
|
|
|
} ]
|
|
|
|
in
|
|
|
|
cautious (print_list True) ppf tree_list
|
|
|
|
in
|
|
|
|
cautious print_tree ppf tree
|
|
|
|
;
|
|
|
|
|
|
|
|
value rec print_list pr sep ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [a] -> pr ppf a
|
|
|
|
| [a :: l] -> do { pr ppf a; sep ppf; print_list pr sep ppf l } ]
|
|
|
|
;
|
|
|
|
|
2003-09-23 05:52:34 -07:00
|
|
|
value pr_vars =
|
|
|
|
print_list (fun ppf s -> fprintf ppf "'%s" s) (fun ppf -> fprintf ppf "@ ")
|
|
|
|
;
|
|
|
|
|
2001-09-07 01:00:42 -07:00
|
|
|
value pr_present =
|
|
|
|
print_list (fun ppf s -> fprintf ppf "`%s" s) (fun ppf -> fprintf ppf "@ ")
|
|
|
|
;
|
|
|
|
|
|
|
|
(* Types *)
|
|
|
|
|
|
|
|
value rec print_out_type ppf =
|
|
|
|
fun
|
|
|
|
[ Otyp_alias ty s -> fprintf ppf "@[%a as '%s@]" print_out_type ty s
|
|
|
|
| ty -> print_out_type_1 ppf ty ]
|
|
|
|
and print_out_type_1 ppf =
|
|
|
|
fun
|
|
|
|
[ Otyp_arrow lab ty1 ty2 ->
|
|
|
|
fprintf ppf "@[%s%a ->@ %a@]" (if lab <> "" then lab ^ ":" else "")
|
|
|
|
print_out_type_2 ty1 print_out_type_1 ty2
|
2003-09-23 05:52:34 -07:00
|
|
|
| Otyp_poly sl ty ->
|
|
|
|
fprintf ppf "@[<hov 2>%a.@ %a@]"
|
|
|
|
pr_vars sl
|
|
|
|
print_out_type ty
|
2001-09-07 01:00:42 -07:00
|
|
|
| ty -> print_out_type_2 ppf ty ]
|
|
|
|
and print_out_type_2 ppf =
|
|
|
|
fun
|
|
|
|
[ Otyp_constr id ([_ :: _] as tyl) ->
|
|
|
|
fprintf ppf "@[%a@;<1 2>%a@]" print_ident id
|
|
|
|
(print_typlist print_simple_out_type "") tyl
|
|
|
|
| ty -> print_simple_out_type ppf ty ]
|
|
|
|
and print_simple_out_type ppf =
|
2003-07-02 02:14:35 -07:00
|
|
|
let rec print_tkind ppf =
|
2001-09-07 01:00:42 -07:00
|
|
|
fun
|
|
|
|
[ Otyp_var ng s -> fprintf ppf "'%s%s" (if ng then "_" else "") s
|
|
|
|
| Otyp_constr id [] -> fprintf ppf "@[%a@]" print_ident id
|
|
|
|
| Otyp_tuple tyl ->
|
|
|
|
fprintf ppf "@[<1>(%a)@]" (print_typlist print_out_type " *") tyl
|
|
|
|
| Otyp_stuff s -> fprintf ppf "%s" s
|
|
|
|
| Otyp_variant non_gen row_fields closed tags ->
|
|
|
|
let print_present ppf =
|
|
|
|
fun
|
|
|
|
[ None | Some [] -> ()
|
|
|
|
| Some l -> fprintf ppf "@;<1 -2>> @[<hov>%a@]" pr_present l ]
|
|
|
|
in
|
2001-09-25 04:01:47 -07:00
|
|
|
let print_fields ppf =
|
|
|
|
fun
|
|
|
|
[ Ovar_fields fields ->
|
|
|
|
print_list print_row_field (fun ppf -> fprintf ppf "@;<1 -2>| ")
|
|
|
|
ppf fields
|
|
|
|
| Ovar_name id tyl ->
|
|
|
|
fprintf ppf "@[%a%a@]" print_typargs tyl print_ident id ]
|
|
|
|
in
|
2001-09-07 01:00:42 -07:00
|
|
|
fprintf ppf "%s[|%s@[<hv>@[<hv>%a@]%a|]@]" (if non_gen then "_" else "")
|
|
|
|
(if closed then if tags = None then " " else "< "
|
|
|
|
else if tags = None then "> "
|
|
|
|
else "? ")
|
2001-09-25 04:01:47 -07:00
|
|
|
print_fields row_fields
|
|
|
|
print_present tags
|
2001-09-07 01:00:42 -07:00
|
|
|
| Otyp_object fields rest ->
|
|
|
|
fprintf ppf "@[<2>< %a >@]" (print_fields rest) fields
|
2001-09-25 04:01:47 -07:00
|
|
|
| Otyp_class ng id tyl ->
|
|
|
|
fprintf ppf "@[%a%s#%a@]" print_typargs tyl (if ng then "_" else "")
|
|
|
|
print_ident id
|
2001-09-07 01:00:42 -07:00
|
|
|
| Otyp_manifest ty1 ty2 ->
|
|
|
|
fprintf ppf "@[<2>%a ==@ %a@]" print_out_type ty1 print_out_type ty2
|
2003-07-02 02:14:35 -07:00
|
|
|
| Otyp_sum constrs priv ->
|
|
|
|
fprintf ppf "@[<hv>%a[ %a ]@]" print_private priv
|
2001-09-07 01:00:42 -07:00
|
|
|
(print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) constrs
|
2003-07-02 02:14:35 -07:00
|
|
|
| Otyp_record lbls priv ->
|
|
|
|
fprintf ppf "@[<hv 2>%a{ %a }@]" print_private priv
|
2001-09-07 01:00:42 -07:00
|
|
|
(print_list print_out_label (fun ppf -> fprintf ppf ";@ ")) lbls
|
|
|
|
| Otyp_abstract -> fprintf ppf "'abstract"
|
2002-04-18 00:00:34 -07:00
|
|
|
| Otyp_alias _ _ | Otyp_poly _ _
|
|
|
|
| Otyp_arrow _ _ _ | Otyp_constr _ [_ :: _] as ty ->
|
2001-09-07 01:00:42 -07:00
|
|
|
fprintf ppf "@[<1>(%a)@]" print_out_type ty ]
|
2003-07-02 02:14:35 -07:00
|
|
|
and print_private ppf =
|
|
|
|
fun
|
|
|
|
[ Asttypes.Public -> ()
|
|
|
|
| Asttypes.Private -> fprintf ppf "private "
|
|
|
|
]
|
2003-02-27 23:53:08 -08:00
|
|
|
in
|
2003-07-02 02:14:35 -07:00
|
|
|
print_tkind ppf
|
2001-09-07 01:00:42 -07:00
|
|
|
and print_out_constr ppf (name, tyl) =
|
|
|
|
match tyl with
|
|
|
|
[ [] -> fprintf ppf "%s" name
|
|
|
|
| _ ->
|
|
|
|
fprintf ppf "@[<2>%s of@ %a@]" name
|
|
|
|
(print_typlist print_out_type " and") tyl ]
|
|
|
|
and print_out_label ppf (name, mut, arg) =
|
|
|
|
fprintf ppf "@[<2>%s :@ %s%a@]" name (if mut then "mutable " else "")
|
|
|
|
print_out_type arg
|
|
|
|
and print_fields rest ppf =
|
|
|
|
fun
|
|
|
|
[ [] ->
|
|
|
|
match rest with
|
|
|
|
[ Some non_gen -> fprintf ppf "%s.." (if non_gen then "_" else "")
|
|
|
|
| None -> () ]
|
|
|
|
| [(s, t)] ->
|
|
|
|
do {
|
|
|
|
fprintf ppf "%s : %a" s print_out_type t;
|
|
|
|
match rest with
|
|
|
|
[ Some _ -> fprintf ppf ";@ "
|
|
|
|
| None -> () ];
|
|
|
|
print_fields rest ppf []
|
|
|
|
}
|
|
|
|
| [(s, t) :: l] ->
|
|
|
|
fprintf ppf "%s : %a;@ %a" s print_out_type t (print_fields rest) l ]
|
|
|
|
and print_row_field ppf (l, opt_amp, tyl) =
|
|
|
|
let pr_of ppf =
|
|
|
|
if opt_amp then fprintf ppf " of@ &@ "
|
|
|
|
else if tyl <> [] then fprintf ppf " of@ "
|
|
|
|
else fprintf ppf ""
|
|
|
|
in
|
|
|
|
fprintf ppf "@[<hv 2>`%s%t%a@]" l pr_of (print_typlist print_out_type " &")
|
|
|
|
tyl
|
|
|
|
and print_typlist print_elem sep ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [ty] -> print_elem ppf ty
|
|
|
|
| [ty :: tyl] ->
|
|
|
|
fprintf ppf "%a%s@ %a" print_elem ty sep (print_typlist print_elem sep)
|
|
|
|
tyl ]
|
|
|
|
and print_typargs ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [ty1] -> fprintf ppf "%a@ " print_simple_out_type ty1
|
|
|
|
| tyl ->
|
|
|
|
fprintf ppf "@[<1>(%a)@]@ " (print_typlist print_out_type ",") tyl ]
|
|
|
|
;
|
|
|
|
|
|
|
|
value print_out_class_params ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| tyl ->
|
|
|
|
fprintf ppf "@[<1>[%a]@]@ "
|
|
|
|
(print_list (fun ppf x -> fprintf ppf "'%s" x)
|
|
|
|
(fun ppf -> fprintf ppf ", "))
|
|
|
|
tyl ]
|
|
|
|
;
|
|
|
|
|
|
|
|
(* Signature items *)
|
|
|
|
|
|
|
|
value rec print_out_class_type ppf =
|
|
|
|
fun
|
|
|
|
[ Octy_constr id tyl ->
|
|
|
|
let pr_tyl ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| tyl ->
|
|
|
|
fprintf ppf "@[<1>[%a]@]@ "
|
|
|
|
(print_typlist Toploop.print_out_type.val ",") tyl ]
|
|
|
|
in
|
|
|
|
fprintf ppf "@[%a%a@]" pr_tyl tyl print_ident id
|
|
|
|
| Octy_fun lab ty cty ->
|
|
|
|
fprintf ppf "@[%s[ %a ] ->@ %a@]" (if lab <> "" then lab ^ ":" else "")
|
|
|
|
Toploop.print_out_type.val ty print_out_class_type cty
|
|
|
|
| Octy_signature self_ty csil ->
|
|
|
|
let pr_param ppf =
|
|
|
|
fun
|
|
|
|
[ Some ty -> fprintf ppf "@ @[(%a)@]" Toploop.print_out_type.val ty
|
|
|
|
| None -> () ]
|
|
|
|
in
|
|
|
|
fprintf ppf "@[<hv 2>@[<2>object%a@]@ %a@;<1 -2>end@]" pr_param self_ty
|
|
|
|
(print_list print_out_class_sig_item (fun ppf -> fprintf ppf "@ "))
|
|
|
|
csil ]
|
|
|
|
and print_out_class_sig_item ppf =
|
|
|
|
fun
|
|
|
|
[ Ocsg_constraint ty1 ty2 ->
|
|
|
|
fprintf ppf "@[<2>type %a =@ %a;@]" Toploop.print_out_type.val ty1
|
|
|
|
Toploop.print_out_type.val ty2
|
|
|
|
| Ocsg_method name priv virt ty ->
|
|
|
|
fprintf ppf "@[<2>method %s%s%s :@ %a;@]"
|
|
|
|
(if priv then "private " else "") (if virt then "virtual " else "")
|
|
|
|
name Toploop.print_out_type.val ty
|
|
|
|
| Ocsg_value name mut ty ->
|
|
|
|
fprintf ppf "@[<2>value %s%s :@ %a;@]" (if mut then "mutable " else "")
|
|
|
|
name Toploop.print_out_type.val ty ]
|
|
|
|
;
|
|
|
|
|
|
|
|
value rec print_out_module_type ppf =
|
|
|
|
fun
|
|
|
|
[ Omty_ident id -> fprintf ppf "%a" print_ident id
|
|
|
|
| Omty_signature sg ->
|
2002-02-13 04:34:45 -08:00
|
|
|
fprintf ppf "@[<hv 2>sig@ %a@;<1 -2>end@]"
|
|
|
|
Toploop.print_out_signature.val sg
|
2001-09-07 01:00:42 -07:00
|
|
|
| Omty_functor name mty_arg mty_res ->
|
|
|
|
fprintf ppf "@[<2>functor@ (%s : %a) ->@ %a@]" name
|
|
|
|
print_out_module_type mty_arg print_out_module_type mty_res
|
|
|
|
| Omty_abstract -> () ]
|
2002-02-13 04:34:45 -08:00
|
|
|
and print_out_signature ppf =
|
2001-09-07 01:00:42 -07:00
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [item] -> fprintf ppf "%a;" Toploop.print_out_sig_item.val item
|
|
|
|
| [item :: items] ->
|
|
|
|
fprintf ppf "%a;@ %a" Toploop.print_out_sig_item.val item
|
2002-02-13 04:34:45 -08:00
|
|
|
print_out_signature items ]
|
2001-09-07 01:00:42 -07:00
|
|
|
and print_out_sig_item ppf =
|
|
|
|
fun
|
|
|
|
[ Osig_class vir_flag name params clt ->
|
|
|
|
fprintf ppf "@[<2>class%s@ %a%s@ :@ %a@]"
|
|
|
|
(if vir_flag then " virtual" else "") print_out_class_params params
|
2002-02-13 04:34:45 -08:00
|
|
|
name Toploop.print_out_class_type.val clt
|
2001-09-07 01:00:42 -07:00
|
|
|
| Osig_class_type vir_flag name params clt ->
|
|
|
|
fprintf ppf "@[<2>class type%s@ %a%s@ =@ %a@]"
|
|
|
|
(if vir_flag then " virtual" else "") print_out_class_params params
|
2002-02-13 04:34:45 -08:00
|
|
|
name Toploop.print_out_class_type.val clt
|
2001-09-07 01:00:42 -07:00
|
|
|
| Osig_exception id tyl ->
|
|
|
|
fprintf ppf "@[<2>exception %a@]" print_out_constr (id, tyl)
|
|
|
|
| Osig_modtype name Omty_abstract ->
|
|
|
|
fprintf ppf "@[<2>module type %s@]" name
|
|
|
|
| Osig_modtype name mty ->
|
2002-02-13 04:34:45 -08:00
|
|
|
fprintf ppf "@[<2>module type %s =@ %a@]" name
|
|
|
|
Toploop.print_out_module_type.val mty
|
2001-09-07 01:00:42 -07:00
|
|
|
| Osig_module name mty ->
|
2002-02-13 04:34:45 -08:00
|
|
|
fprintf ppf "@[<2>module %s :@ %a@]" name
|
|
|
|
Toploop.print_out_module_type.val mty
|
2001-09-07 01:00:42 -07:00
|
|
|
| Osig_type tdl -> print_out_type_decl_list ppf tdl
|
|
|
|
| Osig_value name ty prims ->
|
|
|
|
let kwd = if prims = [] then "value" else "external" in
|
|
|
|
let pr_prims ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [s :: sl] ->
|
|
|
|
do {
|
|
|
|
fprintf ppf "@ = \"%s\"" s;
|
|
|
|
List.iter (fun s -> fprintf ppf "@ \"%s\"" s) sl
|
|
|
|
} ]
|
|
|
|
in
|
|
|
|
fprintf ppf "@[<2>%s %a :@ %a%a@]" kwd value_ident name
|
|
|
|
Toploop.print_out_type.val ty pr_prims prims ]
|
|
|
|
and print_out_type_decl_list ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [x] -> print_out_type_decl "type" ppf x
|
|
|
|
| [x :: l] ->
|
|
|
|
do {
|
|
|
|
print_out_type_decl "type" ppf x;
|
|
|
|
List.iter (fun x -> fprintf ppf "@ %a" (print_out_type_decl "and") x)
|
|
|
|
l
|
|
|
|
} ]
|
|
|
|
and print_out_type_decl kwd ppf (name, args, ty, constraints) =
|
|
|
|
let constrain ppf (ty, ty') =
|
|
|
|
fprintf ppf "@ @[<2>constraint %a =@ %a@]" Toploop.print_out_type.val ty
|
|
|
|
Toploop.print_out_type.val ty'
|
|
|
|
in
|
|
|
|
let print_constraints ppf params = List.iter (constrain ppf) params in
|
|
|
|
let type_parameter ppf (ty, (co, cn)) =
|
|
|
|
fprintf ppf "%s'%s" (if not cn then "+" else if not co then "-" else "")
|
|
|
|
ty
|
|
|
|
in
|
|
|
|
let type_defined ppf =
|
|
|
|
match args with
|
|
|
|
[ [] -> fprintf ppf "%s" name
|
|
|
|
| [arg] -> fprintf ppf "%s %a" name type_parameter arg
|
|
|
|
| _ ->
|
|
|
|
fprintf ppf "%s@ %a" name
|
|
|
|
(print_list type_parameter (fun ppf -> fprintf ppf "@ ")) args ]
|
|
|
|
in
|
2002-01-26 09:47:40 -08:00
|
|
|
fprintf ppf "@[<2>@[<hv 2>@[%s %t@] =@ %a@]%a@]" kwd type_defined
|
2001-09-07 01:00:42 -07:00
|
|
|
Toploop.print_out_type.val ty print_constraints constraints
|
|
|
|
;
|
|
|
|
|
|
|
|
(* Phrases *)
|
|
|
|
|
|
|
|
value print_out_exception ppf exn outv =
|
|
|
|
match exn with
|
|
|
|
[ Sys.Break -> fprintf ppf "Interrupted.@."
|
|
|
|
| Out_of_memory -> fprintf ppf "Out of memory during evaluation.@."
|
|
|
|
| Stack_overflow ->
|
|
|
|
fprintf ppf "Stack overflow during evaluation (looping recursion?).@."
|
|
|
|
| _ ->
|
2002-02-13 10:38:24 -08:00
|
|
|
fprintf ppf "@[Exception:@ %a.@]@." Toploop.print_out_value.val outv ]
|
2001-09-07 01:00:42 -07:00
|
|
|
;
|
|
|
|
|
|
|
|
value rec print_items ppf =
|
|
|
|
fun
|
|
|
|
[ [] -> ()
|
|
|
|
| [(tree, valopt) :: items] ->
|
|
|
|
do {
|
|
|
|
match valopt with
|
|
|
|
[ Some v ->
|
|
|
|
fprintf ppf "@[<2>%a =@ %a@]" Toploop.print_out_sig_item.val tree
|
|
|
|
Toploop.print_out_value.val v
|
|
|
|
| None -> fprintf ppf "@[%a@]" Toploop.print_out_sig_item.val tree ];
|
|
|
|
if items <> [] then fprintf ppf "@ %a" print_items items else ()
|
|
|
|
} ]
|
|
|
|
;
|
|
|
|
|
|
|
|
value print_out_phrase ppf =
|
|
|
|
fun
|
|
|
|
[ Ophr_eval outv ty ->
|
|
|
|
fprintf ppf "@[- : %a@ =@ %a@]@." Toploop.print_out_type.val ty
|
|
|
|
Toploop.print_out_value.val outv
|
|
|
|
| Ophr_signature [] -> ()
|
|
|
|
| Ophr_signature items -> fprintf ppf "@[<v>%a@]@." print_items items
|
|
|
|
| Ophr_exception (exn, outv) -> print_out_exception ppf exn outv ]
|
|
|
|
;
|
|
|
|
|
|
|
|
Toploop.print_out_value.val := print_out_value;
|
|
|
|
Toploop.print_out_type.val := print_out_type;
|
2002-02-13 04:34:45 -08:00
|
|
|
Toploop.print_out_class_type.val := print_out_class_type;
|
|
|
|
Toploop.print_out_module_type.val := print_out_module_type;
|
2001-09-07 01:00:42 -07:00
|
|
|
Toploop.print_out_sig_item.val := print_out_sig_item;
|
2002-02-13 04:34:45 -08:00
|
|
|
Toploop.print_out_signature.val := print_out_signature;
|
2001-09-07 01:00:42 -07:00
|
|
|
Toploop.print_out_phrase.val := print_out_phrase;
|