Skip to content

Commit

Permalink
Printtyped: printing {exp,pat}_extra reflects tree representation
Browse files Browse the repository at this point in the history
  • Loading branch information
let-def committed Apr 14, 2020
1 parent 0cffb4e commit 3d8d70b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions typing/printtyped.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@ and pattern : type k . _ -> _ -> k general_pattern -> unit = fun i ppf x ->
line i ppf "pattern %a\n" fmt_location x.pat_loc;
attributes i ppf x.pat_attributes;
let i = i+1 in
match x.pat_extra with
| extra :: rem ->
pattern_extra i ppf extra;
pattern i ppf { x with pat_extra = rem }
| [] ->
begin match x.pat_extra with
| [] -> ()
| extra ->
line i ppf "extra\n";
List.iter (pattern_extra (i+1) ppf) extra;
end;
match x.pat_desc with
| Tpat_any -> line i ppf "Tpat_any\n";
| Tpat_var (s,_) -> line i ppf "Tpat_var \"%a\"\n" fmt_ident s;
Expand Down Expand Up @@ -287,7 +288,7 @@ and pattern_extra i ppf (extra_pat, _, attrs) =
line i ppf "Tpat_extra_open %a\n" fmt_path id;
attributes i ppf attrs;

and expression_extra i ppf x attrs =
and expression_extra i ppf (x,_,attrs) =
match x with
| Texp_constraint ct ->
line i ppf "Texp_constraint\n";
Expand All @@ -309,11 +310,13 @@ and expression_extra i ppf x attrs =
and expression i ppf x =
line i ppf "expression %a\n" fmt_location x.exp_loc;
attributes i ppf x.exp_attributes;
let i =
List.fold_left (fun i (extra,_,attrs) ->
expression_extra i ppf extra attrs; i+1)
(i+1) x.exp_extra
in
let i = i+1 in
begin match x.exp_extra with
| [] -> ()
| extra ->
line i ppf "extra\n";
List.iter (expression_extra (i+1) ppf) extra;
end;
match x.exp_desc with
| Texp_ident (li,_,_) -> line i ppf "Texp_ident %a\n" fmt_path li;
| Texp_instvar (_, li,_) -> line i ppf "Texp_instvar %a\n" fmt_path li;
Expand Down

0 comments on commit 3d8d70b

Please sign in to comment.