summaryrefslogtreecommitdiff
path: root/parsing
diff options
context:
space:
mode:
authorGuillaume Petiot <guillaume@tarides.com>2021-09-13 19:46:46 +0100
committerGitHub <noreply@github.com>2021-09-13 20:46:46 +0200
commitf9fe08c9c10af768c6f2e3158416862feb080237 (patch)
tree12d0ea6c11b7ba980b046e8002631902ded9cb7f /parsing
parent61ecb0735d628e08fca095b88ebcd9584d6c7226 (diff)
downloadocaml-f9fe08c9c10af768c6f2e3158416862feb080237.tar.gz
Expose more Pprintast functions (#10618)
Diffstat (limited to 'parsing')
-rw-r--r--parsing/pprintast.ml55
-rw-r--r--parsing/pprintast.mli9
2 files changed, 41 insertions, 23 deletions
diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml
index cb8eb31bbb..330ecfbcb5 100644
--- a/parsing/pprintast.ml
+++ b/parsing/pprintast.ml
@@ -865,34 +865,34 @@ and exception_declaration ctxt f x =
(extension_constructor ctxt) x.ptyexn_constructor
(item_attributes ctxt) x.ptyexn_attributes
+and class_type_field ctxt f x =
+ match x.pctf_desc with
+ | Pctf_inherit (ct) ->
+ pp f "@[<2>inherit@ %a@]%a" (class_type ctxt) ct
+ (item_attributes ctxt) x.pctf_attributes
+ | Pctf_val (s, mf, vf, ct) ->
+ pp f "@[<2>val @ %a%a%s@ :@ %a@]%a"
+ mutable_flag mf virtual_flag vf s.txt (core_type ctxt) ct
+ (item_attributes ctxt) x.pctf_attributes
+ | Pctf_method (s, pf, vf, ct) ->
+ pp f "@[<2>method %a %a%s :@;%a@]%a"
+ private_flag pf virtual_flag vf s.txt (core_type ctxt) ct
+ (item_attributes ctxt) x.pctf_attributes
+ | Pctf_constraint (ct1, ct2) ->
+ pp f "@[<2>constraint@ %a@ =@ %a@]%a"
+ (core_type ctxt) ct1 (core_type ctxt) ct2
+ (item_attributes ctxt) x.pctf_attributes
+ | Pctf_attribute a -> floating_attribute ctxt f a
+ | Pctf_extension e ->
+ item_extension ctxt f e;
+ item_attributes ctxt f x.pctf_attributes
+
and class_signature ctxt f { pcsig_self = ct; pcsig_fields = l ;_} =
- let class_type_field f x =
- match x.pctf_desc with
- | Pctf_inherit (ct) ->
- pp f "@[<2>inherit@ %a@]%a" (class_type ctxt) ct
- (item_attributes ctxt) x.pctf_attributes
- | Pctf_val (s, mf, vf, ct) ->
- pp f "@[<2>val @ %a%a%s@ :@ %a@]%a"
- mutable_flag mf virtual_flag vf s.txt (core_type ctxt) ct
- (item_attributes ctxt) x.pctf_attributes
- | Pctf_method (s, pf, vf, ct) ->
- pp f "@[<2>method %a %a%s :@;%a@]%a"
- private_flag pf virtual_flag vf s.txt (core_type ctxt) ct
- (item_attributes ctxt) x.pctf_attributes
- | Pctf_constraint (ct1, ct2) ->
- pp f "@[<2>constraint@ %a@ =@ %a@]%a"
- (core_type ctxt) ct1 (core_type ctxt) ct2
- (item_attributes ctxt) x.pctf_attributes
- | Pctf_attribute a -> floating_attribute ctxt f a
- | Pctf_extension e ->
- item_extension ctxt f e;
- item_attributes ctxt f x.pctf_attributes
- in
pp f "@[<hv0>@[<hv2>object@[<1>%a@]@ %a@]@ end@]"
(fun f -> function
{ptyp_desc=Ptyp_any; ptyp_attributes=[]; _} -> ()
| ct -> pp f " (%a)" (core_type ctxt) ct) ct
- (list class_type_field ~sep:"@;") l
+ (list (class_type_field ctxt) ~sep:"@;") l
(* call [class_signature] called by [class_signature] *)
and class_type ctxt f x =
@@ -1705,3 +1705,12 @@ let pattern = pattern reset_ctxt
let signature = signature reset_ctxt
let structure = structure reset_ctxt
let module_expr = module_expr reset_ctxt
+let module_type = module_type reset_ctxt
+let class_field = class_field reset_ctxt
+let class_type_field = class_type_field reset_ctxt
+let class_expr = class_expr reset_ctxt
+let class_type = class_type reset_ctxt
+let structure_item = structure_item reset_ctxt
+let signature_item = signature_item reset_ctxt
+let binding = binding reset_ctxt
+let payload = payload reset_ctxt
diff --git a/parsing/pprintast.mli b/parsing/pprintast.mli
index 6c7022cf69..42acd5f15c 100644
--- a/parsing/pprintast.mli
+++ b/parsing/pprintast.mli
@@ -40,6 +40,15 @@ val module_expr: Format.formatter -> Parsetree.module_expr -> unit
val toplevel_phrase : Format.formatter -> Parsetree.toplevel_phrase -> unit
val top_phrase: Format.formatter -> Parsetree.toplevel_phrase -> unit
+val class_field: Format.formatter -> Parsetree.class_field -> unit
+val class_type_field: Format.formatter -> Parsetree.class_type_field -> unit
+val class_expr: Format.formatter -> Parsetree.class_expr -> unit
+val class_type: Format.formatter -> Parsetree.class_type -> unit
+val module_type: Format.formatter -> Parsetree.module_type -> unit
+val structure_item: Format.formatter -> Parsetree.structure_item -> unit
+val signature_item: Format.formatter -> Parsetree.signature_item -> unit
+val binding: Format.formatter -> Parsetree.value_binding -> unit
+val payload: Format.formatter -> Parsetree.payload -> unit
val tyvar: Format.formatter -> string -> unit
(** Print a type variable name, taking care of the special treatment