diff options
| author | Alain Frisch <alain@frisch.fr> | 2013-04-23 13:53:47 +0000 |
|---|---|---|
| committer | Alain Frisch <alain@frisch.fr> | 2013-04-23 13:53:47 +0000 |
| commit | 365bcdeadc2ed05eb86513485416462fbca288af (patch) | |
| tree | 7624e465ff0aaac1a83afa6ae40e5d6fbd50f66c /parsing | |
| parent | af3b4790e7399241ac2e40567a9a66c743acd49c (diff) | |
| download | ocaml-365bcdeadc2ed05eb86513485416462fbca288af.tar.gz | |
Print attributes on types and patterns.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13598 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'parsing')
| -rw-r--r-- | parsing/pprintast.ml | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml index 002bc7c0ed..36c6599ca1 100644 --- a/parsing/pprintast.ml +++ b/parsing/pprintast.ml @@ -224,7 +224,11 @@ class printer ()= object(self:'self) | _ -> failwith "invalid input in print_type_with_label" else pp f "%s:%a" s self#core_type1 c method core_type f x = - match x.ptyp_desc with + if x.ptyp_attributes <> [] then begin + pp f "((%a)%a)" self#core_type {x with ptyp_attributes=[]} + self#attributes x.ptyp_attributes + end + else match x.ptyp_desc with | Ptyp_arrow (l, ct1, ct2) -> pp f "@[<2>%a@;->@;%a@]" (* FIXME remove parens later *) self#type_with_label (l,ct1) self#core_type ct2 @@ -241,7 +245,8 @@ class printer ()= object(self:'self) (self#list self#tyvar ~sep:"@;") l) l) sl self#core_type ct | _ -> pp f "@[<2>%a@]" self#core_type1 x method core_type1 f x = - match x.ptyp_desc with + if x.ptyp_attributes <> [] then self#core_type f x + else match x.ptyp_desc with | Ptyp_any -> pp f "_"; | Ptyp_var s -> self#tyvar f s; | Ptyp_tuple l -> pp f "(%a)" (self#list self#core_type1 ~sep:"*@;") l @@ -314,7 +319,11 @@ class printer ()= object(self:'self) | {ppat_desc= Ppat_or (p1,p2);_} -> list_of_pattern (p2::acc) p1 | x -> x::acc in - match x.ppat_desc with + if x.ppat_attributes <> [] then begin + pp f "((%a)%a)" self#pattern {x with ppat_attributes=[]} + self#attributes x.ppat_attributes + end + else match x.ppat_desc with | Ppat_alias (p, s) -> pp f "@[<2>%a@;as@;%a@]" self#pattern p (fun f s-> @@ -333,7 +342,8 @@ class printer ()= object(self:'self) -> pp f "%a::%a" self#simple_pattern pat1 pattern_list_helper pat2 (*RA*) | p -> self#pattern1 f p in - match x.ppat_desc with + if x.ppat_attributes <> [] then self#pattern f x + else match x.ppat_desc with | Ppat_variant (l, Some p) -> pp f "@[<2>`%s@;%a@]" l self#pattern1 p (*RA*) | Ppat_construct (({txt=Lident("()"|"[]");_}), _) -> self#simple_pattern f x | Ppat_construct (({txt;_} as li), po) -> (* FIXME The third field always false *) |
