1999-11-29 11:04:43 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1999-11-29 11:04:43 -08:00
|
|
|
(* *)
|
|
|
|
(* Damien Doligez, projet Para, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1999 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
open Asttypes;;
|
2000-04-21 01:13:22 -07:00
|
|
|
open Format;;
|
2002-11-01 09:06:47 -08:00
|
|
|
open Lexing;;
|
1999-11-29 11:04:43 -08:00
|
|
|
open Location;;
|
|
|
|
open Parsetree;;
|
|
|
|
|
2012-12-08 12:55:17 -08:00
|
|
|
let fmt_position with_name f l =
|
|
|
|
let fname = if with_name then l.pos_fname else "" in
|
2011-08-04 07:59:13 -07:00
|
|
|
if l.pos_lnum = -1
|
2012-12-08 12:55:17 -08:00
|
|
|
then fprintf f "%s[%d]" fname l.pos_cnum
|
|
|
|
else fprintf f "%s[%d,%d+%d]" fname l.pos_lnum l.pos_bol
|
2002-11-14 12:06:59 -08:00
|
|
|
(l.pos_cnum - l.pos_bol)
|
2002-11-01 09:06:47 -08:00
|
|
|
;;
|
|
|
|
|
1999-11-29 11:04:43 -08:00
|
|
|
let fmt_location f loc =
|
2012-12-08 12:55:17 -08:00
|
|
|
let p_2nd_name = loc.loc_start.pos_fname <> loc.loc_end.pos_fname in
|
|
|
|
fprintf f "(%a..%a)" (fmt_position true) loc.loc_start
|
|
|
|
(fmt_position p_2nd_name) loc.loc_end;
|
2002-11-01 09:06:47 -08:00
|
|
|
if loc.loc_ghost then fprintf f " ghost";
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
let rec fmt_longident_aux f x =
|
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Longident.Lident (s) -> fprintf f "%s" s;
|
|
|
|
| Longident.Ldot (y, s) -> fprintf f "%a.%s" fmt_longident_aux y s;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Longident.Lapply (y, z) ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf f "%a(%a)" fmt_longident_aux y fmt_longident_aux z;
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
2012-12-08 12:55:17 -08:00
|
|
|
let fmt_longident f x = fprintf f "\"%a\"" fmt_longident_aux x;;
|
|
|
|
|
|
|
|
let fmt_longident_loc f x =
|
|
|
|
fprintf f "\"%a\" %a" fmt_longident_aux x.txt fmt_location x.loc;
|
|
|
|
;;
|
|
|
|
|
|
|
|
let fmt_string_loc f x =
|
|
|
|
fprintf f "\"%s\" %a" x.txt fmt_location x.loc;
|
|
|
|
;;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2013-05-23 08:12:04 -07:00
|
|
|
let fmt_constant f x =
|
1999-11-29 11:04:43 -08:00
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Const_int (i) -> fprintf f "Const_int %d" i;
|
|
|
|
| Const_char (c) -> fprintf f "Const_char %02x" (Char.code c);
|
2013-03-26 04:17:17 -07:00
|
|
|
| Const_string (s, None) -> fprintf f "Const_string(%S,None)" s;
|
|
|
|
| Const_string (s, Some delim) ->
|
|
|
|
fprintf f "Const_string (%S,Some %S)" s delim;
|
2000-04-21 01:13:22 -07:00
|
|
|
| Const_float (s) -> fprintf f "Const_float %s" s;
|
2003-04-25 05:27:31 -07:00
|
|
|
| Const_int32 (i) -> fprintf f "Const_int32 %ld" i;
|
|
|
|
| Const_int64 (i) -> fprintf f "Const_int64 %Ld" i;
|
|
|
|
| Const_nativeint (i) -> fprintf f "Const_nativeint %nd" i;
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
let fmt_mutable_flag f x =
|
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Immutable -> fprintf f "Immutable";
|
|
|
|
| Mutable -> fprintf f "Mutable";
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
let fmt_virtual_flag f x =
|
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Virtual -> fprintf f "Virtual";
|
|
|
|
| Concrete -> fprintf f "Concrete";
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
2010-04-07 20:58:41 -07:00
|
|
|
let fmt_override_flag f x =
|
|
|
|
match x with
|
|
|
|
| Override -> fprintf f "Override";
|
|
|
|
| Fresh -> fprintf f "Fresh";
|
|
|
|
;;
|
|
|
|
|
2013-04-09 06:29:00 -07:00
|
|
|
let fmt_closed_flag f x =
|
|
|
|
match x with
|
|
|
|
| Closed -> fprintf f "Closed"
|
|
|
|
| Open -> fprintf f "Open"
|
|
|
|
|
1999-11-29 11:04:43 -08:00
|
|
|
let fmt_rec_flag f x =
|
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Nonrecursive -> fprintf f "Nonrec";
|
|
|
|
| Recursive -> fprintf f "Rec";
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
let fmt_direction_flag f x =
|
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Upto -> fprintf f "Up";
|
|
|
|
| Downto -> fprintf f "Down";
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
|
|
|
let fmt_private_flag f x =
|
|
|
|
match x with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Public -> fprintf f "Public";
|
|
|
|
| Private -> fprintf f "Private";
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let line i f s (*...*) =
|
|
|
|
fprintf f "%s" (String.make (2*i) ' ');
|
|
|
|
fprintf f s (*...*)
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
2007-10-08 07:19:34 -07:00
|
|
|
let list i f ppf l =
|
|
|
|
match l with
|
|
|
|
| [] -> line i ppf "[]\n";
|
2011-10-28 14:24:27 -07:00
|
|
|
| _ :: _ ->
|
2007-10-08 07:19:34 -07:00
|
|
|
line i ppf "[\n";
|
|
|
|
List.iter (f (i+1) ppf) l;
|
|
|
|
line i ppf "]\n";
|
|
|
|
;;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let option i f ppf x =
|
1999-11-29 11:04:43 -08:00
|
|
|
match x with
|
2000-03-06 14:12:09 -08:00
|
|
|
| None -> line i ppf "None\n";
|
1999-11-29 11:04:43 -08:00
|
|
|
| Some x ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Some\n";
|
|
|
|
f (i+1) ppf x;
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
2012-12-08 12:55:17 -08:00
|
|
|
let longident_loc i ppf li = line i ppf "%a\n" fmt_longident_loc li;;
|
2000-03-06 14:12:09 -08:00
|
|
|
let string i ppf s = line i ppf "\"%s\"\n" s;;
|
2012-12-08 12:55:17 -08:00
|
|
|
let string_loc i ppf s = line i ppf "%a\n" fmt_string_loc s;;
|
2000-03-06 14:12:09 -08:00
|
|
|
let bool i ppf x = line i ppf "%s\n" (string_of_bool x);;
|
|
|
|
let label i ppf x = line i ppf "label=\"%s\"\n" x;;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let rec core_type i ppf x =
|
|
|
|
line i ppf "core_type %a\n" fmt_location x.ptyp_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.ptyp_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.ptyp_desc with
|
2000-03-06 14:12:09 -08:00
|
|
|
| Ptyp_any -> line i ppf "Ptyp_any\n";
|
|
|
|
| Ptyp_var (s) -> line i ppf "Ptyp_var %s\n" s;
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ptyp_arrow (l, ct1, ct2) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ptyp_arrow\n";
|
|
|
|
string i ppf l;
|
|
|
|
core_type i ppf ct1;
|
|
|
|
core_type i ppf ct2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ptyp_tuple l ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ptyp_tuple\n";
|
|
|
|
list i core_type ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ptyp_constr (li, l) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Ptyp_constr %a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
list i core_type ppf l;
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ptyp_variant (l, closed, low) ->
|
2013-04-12 09:08:52 -07:00
|
|
|
line i ppf "Ptyp_variant closed=%a\n" fmt_closed_flag closed;
|
2000-03-06 14:12:09 -08:00
|
|
|
list i label_x_bool_x_core_type_list ppf l;
|
2001-09-25 02:54:18 -07:00
|
|
|
option i (fun i -> list i string) ppf low
|
2013-04-09 06:29:00 -07:00
|
|
|
| Ptyp_object (l, c) ->
|
|
|
|
line i ppf "Ptyp_object %a\n" fmt_closed_flag c;
|
|
|
|
let i = i + 1 in
|
|
|
|
List.iter
|
|
|
|
(fun (s, t) ->
|
|
|
|
line i ppf "method %s" s;
|
|
|
|
core_type (i + 1) ppf t
|
|
|
|
)
|
|
|
|
l
|
2013-04-16 05:17:17 -07:00
|
|
|
| Ptyp_class (li, l) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Ptyp_class %a\n" fmt_longident_loc li;
|
2013-04-16 05:17:17 -07:00
|
|
|
list i core_type ppf l
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ptyp_alias (ct, s) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ptyp_alias \"%s\"\n" s;
|
|
|
|
core_type i ppf ct;
|
2002-04-18 00:27:47 -07:00
|
|
|
| Ptyp_poly (sl, ct) ->
|
|
|
|
line i ppf "Ptyp_poly%a\n"
|
|
|
|
(fun ppf -> List.iter (fun x -> fprintf ppf " '%s" x)) sl;
|
|
|
|
core_type i ppf ct;
|
2009-10-26 03:53:16 -07:00
|
|
|
| Ptyp_package (s, l) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Ptyp_package %a\n" fmt_longident_loc s;
|
2011-10-28 14:24:27 -07:00
|
|
|
list i package_with ppf l;
|
2013-02-28 08:51:59 -08:00
|
|
|
| Ptyp_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Ptyp_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
2009-10-26 03:53:16 -07:00
|
|
|
|
|
|
|
and package_with i ppf (s, t) =
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "with type %a\n" fmt_longident_loc s;
|
2009-10-26 03:53:16 -07:00
|
|
|
core_type i ppf t
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and pattern i ppf x =
|
|
|
|
line i ppf "pattern %a\n" fmt_location x.ppat_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.ppat_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.ppat_desc with
|
2000-03-06 14:12:09 -08:00
|
|
|
| Ppat_any -> line i ppf "Ppat_any\n";
|
2012-12-08 12:55:17 -08:00
|
|
|
| Ppat_var (s) -> line i ppf "Ppat_var %a\n" fmt_string_loc s;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ppat_alias (p, s) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Ppat_alias %a\n" fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
pattern i ppf p;
|
|
|
|
| Ppat_constant (c) -> line i ppf "Ppat_constant %a\n" fmt_constant c;
|
2013-04-16 08:34:09 -07:00
|
|
|
| Ppat_interval (c1, c2) -> line i ppf "Ppat_interval %a..%a\n" fmt_constant c1 fmt_constant c2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ppat_tuple (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ppat_tuple\n";
|
|
|
|
list i pattern ppf l;
|
2013-04-17 02:46:52 -07:00
|
|
|
| Ppat_construct (li, po) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Ppat_construct %a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
option i pattern ppf po;
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ppat_variant (l, po) ->
|
2000-03-13 12:34:47 -08:00
|
|
|
line i ppf "Ppat_variant \"%s\"\n" l;
|
2000-03-06 14:12:09 -08:00
|
|
|
option i pattern ppf po;
|
2009-09-12 05:41:07 -07:00
|
|
|
| Ppat_record (l, c) ->
|
2013-04-09 06:29:00 -07:00
|
|
|
line i ppf "Ppat_record %a\n" fmt_closed_flag c;
|
2000-03-06 14:12:09 -08:00
|
|
|
list i longident_x_pattern ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ppat_array (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ppat_array\n";
|
|
|
|
list i pattern ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ppat_or (p1, p2) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ppat_or\n";
|
|
|
|
pattern i ppf p1;
|
|
|
|
pattern i ppf p2;
|
2008-07-09 06:03:38 -07:00
|
|
|
| Ppat_lazy p ->
|
|
|
|
line i ppf "Ppat_lazy\n";
|
|
|
|
pattern i ppf p;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Ppat_constraint (p, ct) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ppat_constraint";
|
|
|
|
pattern i ppf p;
|
|
|
|
core_type i ppf ct;
|
2012-05-30 07:52:37 -07:00
|
|
|
| Ppat_type (li) ->
|
2007-11-28 14:25:02 -08:00
|
|
|
line i ppf "Ppat_type";
|
2012-12-08 12:55:17 -08:00
|
|
|
longident_loc i ppf li
|
2010-10-21 16:59:33 -07:00
|
|
|
| Ppat_unpack s ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Ppat_unpack %a\n" fmt_string_loc s;
|
2013-03-04 05:52:23 -08:00
|
|
|
| Ppat_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Ppat_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and expression i ppf x =
|
|
|
|
line i ppf "expression %a\n" fmt_location x.pexp_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.pexp_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.pexp_desc with
|
2012-12-08 12:55:17 -08:00
|
|
|
| Pexp_ident (li) -> line i ppf "Pexp_ident %a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
| Pexp_constant (c) -> line i ppf "Pexp_constant %a\n" fmt_constant c;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_let (rf, l, e) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_let %a\n" fmt_rec_flag rf;
|
|
|
|
list i pattern_x_expression_def ppf l;
|
|
|
|
expression i ppf e;
|
2013-04-17 04:43:29 -07:00
|
|
|
| Pexp_function l ->
|
|
|
|
line i ppf "Pexp_function\n";
|
2013-04-15 09:23:22 -07:00
|
|
|
list i case ppf l;
|
2013-04-17 04:43:29 -07:00
|
|
|
| Pexp_fun (l, eo, p, e) ->
|
|
|
|
line i ppf "Pexp_fun \"%s\"\n" l;
|
|
|
|
option i expression ppf eo;
|
|
|
|
pattern i ppf p;
|
|
|
|
expression i ppf e;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_apply (e, l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_apply\n";
|
|
|
|
expression i ppf e;
|
|
|
|
list i label_x_expression ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_match (e, l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_match\n";
|
|
|
|
expression i ppf e;
|
2013-04-15 09:23:22 -07:00
|
|
|
list i case ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_try (e, l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_try\n";
|
|
|
|
expression i ppf e;
|
2013-04-15 09:23:22 -07:00
|
|
|
list i case ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_tuple (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_tuple\n";
|
|
|
|
list i expression ppf l;
|
2013-04-17 02:46:52 -07:00
|
|
|
| Pexp_construct (li, eo) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pexp_construct %a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
option i expression ppf eo;
|
1999-11-30 08:07:38 -08:00
|
|
|
| Pexp_variant (l, eo) ->
|
2000-03-13 12:34:47 -08:00
|
|
|
line i ppf "Pexp_variant \"%s\"\n" l;
|
2000-03-06 14:12:09 -08:00
|
|
|
option i expression ppf eo;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_record (l, eo) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_record\n";
|
|
|
|
list i longident_x_expression ppf l;
|
|
|
|
option i expression ppf eo;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_field (e, li) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_field\n";
|
|
|
|
expression i ppf e;
|
2012-12-08 12:55:17 -08:00
|
|
|
longident_loc i ppf li;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_setfield (e1, li, e2) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_setfield\n";
|
|
|
|
expression i ppf e1;
|
2012-12-08 12:55:17 -08:00
|
|
|
longident_loc i ppf li;
|
2000-03-06 14:12:09 -08:00
|
|
|
expression i ppf e2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_array (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_array\n";
|
|
|
|
list i expression ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_ifthenelse (e1, e2, eo) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_ifthenelse\n";
|
|
|
|
expression i ppf e1;
|
|
|
|
expression i ppf e2;
|
|
|
|
option i expression ppf eo;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_sequence (e1, e2) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_sequence\n";
|
|
|
|
expression i ppf e1;
|
|
|
|
expression i ppf e2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_while (e1, e2) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_while\n";
|
|
|
|
expression i ppf e1;
|
|
|
|
expression i ppf e2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_for (s, e1, e2, df, e3) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pexp_for %a %a\n" fmt_direction_flag df fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
expression i ppf e1;
|
|
|
|
expression i ppf e2;
|
|
|
|
expression i ppf e3;
|
2013-04-17 05:23:44 -07:00
|
|
|
| Pexp_constraint (e, ct) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_constraint\n";
|
|
|
|
expression i ppf e;
|
2013-04-17 05:23:44 -07:00
|
|
|
core_type i ppf ct;
|
|
|
|
| Pexp_coerce (e, cto1, cto2) ->
|
|
|
|
line i ppf "Pexp_coerce\n";
|
|
|
|
expression i ppf e;
|
2000-03-06 14:12:09 -08:00
|
|
|
option i core_type ppf cto1;
|
2013-04-17 05:23:44 -07:00
|
|
|
core_type i ppf cto2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_send (e, s) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_send \"%s\"\n" s;
|
|
|
|
expression i ppf e;
|
2012-12-08 12:55:17 -08:00
|
|
|
| Pexp_new (li) -> line i ppf "Pexp_new %a\n" fmt_longident_loc li;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_setinstvar (s, e) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pexp_setinstvar %a\n" fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
expression i ppf e;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_override (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pexp_override\n";
|
|
|
|
list i string_x_expression ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pexp_letmodule (s, me, e) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pexp_letmodule %a\n" fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
module_expr i ppf me;
|
|
|
|
expression i ppf e;
|
2000-12-04 07:37:05 -08:00
|
|
|
| Pexp_assert (e) ->
|
|
|
|
line i ppf "Pexp_assert";
|
|
|
|
expression i ppf e;
|
2002-01-20 09:39:10 -08:00
|
|
|
| Pexp_lazy (e) ->
|
|
|
|
line i ppf "Pexp_lazy";
|
|
|
|
expression i ppf e;
|
2002-04-18 00:27:47 -07:00
|
|
|
| Pexp_poly (e, cto) ->
|
|
|
|
line i ppf "Pexp_poly\n";
|
|
|
|
expression i ppf e;
|
|
|
|
option i core_type ppf cto;
|
2003-11-25 00:46:45 -08:00
|
|
|
| Pexp_object s ->
|
|
|
|
line i ppf "Pexp_object";
|
|
|
|
class_structure i ppf s
|
2009-10-06 05:51:42 -07:00
|
|
|
| Pexp_newtype (s, e) ->
|
|
|
|
line i ppf "Pexp_newtype \"%s\"\n" s;
|
|
|
|
expression i ppf e
|
2010-10-21 16:59:33 -07:00
|
|
|
| Pexp_pack me ->
|
|
|
|
line i ppf "Pexp_pack";
|
2009-10-26 03:53:16 -07:00
|
|
|
module_expr i ppf me
|
2009-11-01 13:52:29 -08:00
|
|
|
| Pexp_open (m, e) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pexp_open \"%a\"\n" fmt_longident_loc m;
|
2009-11-01 13:52:29 -08:00
|
|
|
expression i ppf e
|
2013-02-28 08:51:59 -08:00
|
|
|
| Pexp_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pexp_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and value_description i ppf x =
|
2013-03-06 04:00:18 -08:00
|
|
|
line i ppf "value_description %a %a\n" fmt_string_loc x.pval_name fmt_location x.pval_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.pval_attributes;
|
2000-03-06 14:12:09 -08:00
|
|
|
core_type (i+1) ppf x.pval_type;
|
2013-03-08 06:59:45 -08:00
|
|
|
list (i+1) string ppf x.pval_prim
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2013-04-02 08:33:35 -07:00
|
|
|
and type_parameter i ppf (x, _variance) =
|
|
|
|
match x with
|
|
|
|
| Some x ->
|
|
|
|
string_loc i ppf x
|
|
|
|
| None ->
|
|
|
|
string i ppf "_"
|
2010-09-20 22:30:25 -07:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and type_declaration i ppf x =
|
2013-03-06 03:47:59 -08:00
|
|
|
line i ppf "type_declaration %a %a\n" fmt_string_loc x.ptype_name fmt_location x.ptype_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.ptype_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "ptype_params =\n";
|
2013-04-02 08:33:35 -07:00
|
|
|
list (i+1) type_parameter ppf x.ptype_params;
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "ptype_cstrs =\n";
|
|
|
|
list (i+1) core_type_x_core_type_x_location ppf x.ptype_cstrs;
|
|
|
|
line i ppf "ptype_kind =\n";
|
|
|
|
type_kind (i+1) ppf x.ptype_kind;
|
2007-10-09 03:29:37 -07:00
|
|
|
line i ppf "ptype_private = %a\n" fmt_private_flag x.ptype_private;
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "ptype_manifest =\n";
|
2013-03-08 06:59:45 -08:00
|
|
|
option (i+1) core_type ppf x.ptype_manifest
|
2013-03-04 04:54:57 -08:00
|
|
|
|
|
|
|
and attributes i ppf l =
|
2013-03-25 07:16:07 -07:00
|
|
|
let i = i + 1 in
|
2013-03-01 04:44:04 -08:00
|
|
|
List.iter
|
|
|
|
(fun (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "attribute \"%s\"\n" s.txt;
|
|
|
|
structure (i + 1) ppf arg;
|
2013-03-01 04:44:04 -08:00
|
|
|
)
|
2013-03-04 04:54:57 -08:00
|
|
|
l
|
2000-03-06 14:12:09 -08:00
|
|
|
|
|
|
|
and type_kind i ppf x =
|
1999-11-29 11:04:43 -08:00
|
|
|
match x with
|
2000-09-07 03:57:32 -07:00
|
|
|
| Ptype_abstract ->
|
|
|
|
line i ppf "Ptype_abstract\n"
|
2007-10-09 03:29:37 -07:00
|
|
|
| Ptype_variant l ->
|
|
|
|
line i ppf "Ptype_variant\n";
|
2013-03-04 07:35:47 -08:00
|
|
|
list (i+1) constructor_decl ppf l;
|
2007-10-09 03:29:37 -07:00
|
|
|
| Ptype_record l ->
|
|
|
|
line i ppf "Ptype_record\n";
|
2013-03-06 05:51:18 -08:00
|
|
|
list (i+1) label_decl ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and class_type i ppf x =
|
|
|
|
line i ppf "class_type %a\n" fmt_location x.pcty_loc;
|
2013-04-10 10:44:15 -07:00
|
|
|
attributes i ppf x.pcty_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.pcty_desc with
|
|
|
|
| Pcty_constr (li, l) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pcty_constr %a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
list i core_type ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pcty_signature (cs) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pcty_signature\n";
|
|
|
|
class_signature i ppf cs;
|
2013-04-16 01:59:09 -07:00
|
|
|
| Pcty_arrow (l, co, cl) ->
|
|
|
|
line i ppf "Pcty_arrow \"%s\"\n" l;
|
2000-03-06 14:12:09 -08:00
|
|
|
core_type i ppf co;
|
|
|
|
class_type i ppf cl;
|
2013-04-10 10:44:15 -07:00
|
|
|
| Pcty_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pcty_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2012-12-10 05:16:10 -08:00
|
|
|
and class_signature i ppf cs =
|
2013-04-16 02:21:05 -07:00
|
|
|
line i ppf "class_signature\n";
|
2012-12-10 05:16:10 -08:00
|
|
|
core_type (i+1) ppf cs.pcsig_self;
|
|
|
|
list (i+1) class_type_field ppf cs.pcsig_fields;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and class_type_field i ppf x =
|
2012-12-10 05:16:10 -08:00
|
|
|
line i ppf "class_type_field %a\n" fmt_location x.pctf_loc;
|
|
|
|
let i = i+1 in
|
2013-04-10 02:17:22 -07:00
|
|
|
attributes i ppf x.pctf_attributes;
|
2012-05-30 07:52:37 -07:00
|
|
|
match x.pctf_desc with
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pctf_inherit (ct) ->
|
|
|
|
line i ppf "Pctf_inherit\n";
|
2000-03-06 14:12:09 -08:00
|
|
|
class_type i ppf ct;
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pctf_val (s, mf, vf, ct) ->
|
2012-12-10 05:16:10 -08:00
|
|
|
line i ppf "Pctf_val \"%s\" %a %a\n" s fmt_mutable_flag mf
|
|
|
|
fmt_virtual_flag vf;
|
2006-04-04 19:28:13 -07:00
|
|
|
core_type (i+1) ppf ct;
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pctf_method (s, pf, vf, ct) ->
|
|
|
|
line i ppf "Pctf_method \"%s\" %a %a\n" s fmt_private_flag pf fmt_virtual_flag vf;
|
2007-10-08 07:19:34 -07:00
|
|
|
core_type (i+1) ppf ct;
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pctf_constraint (ct1, ct2) ->
|
|
|
|
line i ppf "Pctf_constraint\n";
|
2012-12-10 05:16:10 -08:00
|
|
|
core_type (i+1) ppf ct1;
|
|
|
|
core_type (i+1) ppf ct2;
|
2013-04-10 10:54:54 -07:00
|
|
|
| Pctf_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pctf_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and class_description i ppf x =
|
|
|
|
line i ppf "class_description %a\n" fmt_location x.pci_loc;
|
2013-03-25 07:56:56 -07:00
|
|
|
attributes i ppf x.pci_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "pci_virt = %a\n" fmt_virtual_flag x.pci_virt;
|
|
|
|
line i ppf "pci_params =\n";
|
2013-04-02 08:33:35 -07:00
|
|
|
cl_type_parameters (i+1) ppf x.pci_params;
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "pci_name = %a\n" fmt_string_loc x.pci_name;
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "pci_expr =\n";
|
|
|
|
class_type (i+1) ppf x.pci_expr;
|
|
|
|
|
|
|
|
and class_type_declaration i ppf x =
|
|
|
|
line i ppf "class_type_declaration %a\n" fmt_location x.pci_loc;
|
2013-04-11 06:28:37 -07:00
|
|
|
attributes i ppf x.pci_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "pci_virt = %a\n" fmt_virtual_flag x.pci_virt;
|
|
|
|
line i ppf "pci_params =\n";
|
2013-04-02 08:33:35 -07:00
|
|
|
cl_type_parameters (i+1) ppf x.pci_params;
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "pci_name = %a\n" fmt_string_loc x.pci_name;
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "pci_expr =\n";
|
|
|
|
class_type (i+1) ppf x.pci_expr;
|
|
|
|
|
|
|
|
and class_expr i ppf x =
|
|
|
|
line i ppf "class_expr %a\n" fmt_location x.pcl_loc;
|
2013-04-10 10:26:55 -07:00
|
|
|
attributes i ppf x.pcl_attributes;
|
1999-12-30 04:52:33 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.pcl_desc with
|
|
|
|
| Pcl_constr (li, l) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pcl_constr %a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
list i core_type ppf l;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pcl_structure (cs) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pcl_structure\n";
|
|
|
|
class_structure i ppf cs;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pcl_fun (l, eo, p, e) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pcl_fun\n";
|
|
|
|
label i ppf l;
|
|
|
|
option i expression ppf eo;
|
|
|
|
pattern i ppf p;
|
|
|
|
class_expr i ppf e;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pcl_apply (ce, l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pcl_apply\n";
|
|
|
|
class_expr i ppf ce;
|
|
|
|
list i label_x_expression ppf l;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pcl_let (rf, l, ce) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pcl_let %a\n" fmt_rec_flag rf;
|
|
|
|
list i pattern_x_expression_def ppf l;
|
|
|
|
class_expr i ppf ce;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pcl_constraint (ce, ct) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pcl_constraint\n";
|
|
|
|
class_expr i ppf ce;
|
|
|
|
class_type i ppf ct;
|
2013-04-10 10:26:55 -07:00
|
|
|
| Pcl_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pcl_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2013-04-10 02:35:09 -07:00
|
|
|
and class_structure i ppf { pcstr_self = p; pcstr_fields = l } =
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "class_structure\n";
|
|
|
|
pattern (i+1) ppf p;
|
|
|
|
list (i+1) class_field ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and class_field i ppf x =
|
2012-12-10 05:16:10 -08:00
|
|
|
line i ppf "class_field %a\n" fmt_location x.pcf_loc;
|
|
|
|
let i = i + 1 in
|
2013-04-09 08:54:41 -07:00
|
|
|
attributes i ppf x.pcf_attributes;
|
2012-05-30 07:52:37 -07:00
|
|
|
match x.pcf_desc with
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pcf_inherit (ovf, ce, so) ->
|
|
|
|
line i ppf "Pcf_inherit %a\n" fmt_override_flag ovf;
|
2000-03-06 14:12:09 -08:00
|
|
|
class_expr (i+1) ppf ce;
|
|
|
|
option (i+1) string ppf so;
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pcf_val (s, mf, k) ->
|
|
|
|
line i ppf "Pcf_val %a\n" fmt_mutable_flag mf;
|
2012-12-08 12:55:17 -08:00
|
|
|
line (i+1) ppf "%a\n" fmt_string_loc s;
|
2013-04-10 04:17:41 -07:00
|
|
|
class_field_kind (i+1) ppf k
|
|
|
|
| Pcf_method (s, pf, k) ->
|
|
|
|
line i ppf "Pcf_method %a\n" fmt_private_flag pf;
|
2012-12-08 12:55:17 -08:00
|
|
|
line (i+1) ppf "%a\n" fmt_string_loc s;
|
2013-04-10 04:17:41 -07:00
|
|
|
class_field_kind (i+1) ppf k
|
|
|
|
| Pcf_constraint (ct1, ct2) ->
|
|
|
|
line i ppf "Pcf_constraint\n";
|
2000-03-06 14:12:09 -08:00
|
|
|
core_type (i+1) ppf ct1;
|
|
|
|
core_type (i+1) ppf ct2;
|
2013-04-10 04:17:41 -07:00
|
|
|
| Pcf_initializer (e) ->
|
|
|
|
line i ppf "Pcf_initializer\n";
|
2000-03-06 14:12:09 -08:00
|
|
|
expression (i+1) ppf e;
|
2013-04-10 10:54:54 -07:00
|
|
|
| Pcf_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pcf_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2013-04-10 04:17:41 -07:00
|
|
|
and class_field_kind i ppf = function
|
|
|
|
| Cfk_concrete (o, e) ->
|
|
|
|
line i ppf "Concrete %a\n" fmt_override_flag o;
|
|
|
|
expression i ppf e
|
|
|
|
| Cfk_virtual t ->
|
|
|
|
line i ppf "Virtual\n";
|
|
|
|
core_type i ppf t
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and class_declaration i ppf x =
|
|
|
|
line i ppf "class_declaration %a\n" fmt_location x.pci_loc;
|
2013-04-11 06:28:37 -07:00
|
|
|
attributes i ppf x.pci_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "pci_virt = %a\n" fmt_virtual_flag x.pci_virt;
|
|
|
|
line i ppf "pci_params =\n";
|
2013-04-02 08:33:35 -07:00
|
|
|
cl_type_parameters (i+1) ppf x.pci_params;
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "pci_name = %a\n" fmt_string_loc x.pci_name;
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "pci_expr =\n";
|
|
|
|
class_expr (i+1) ppf x.pci_expr;
|
|
|
|
|
|
|
|
and module_type i ppf x =
|
|
|
|
line i ppf "module_type %a\n" fmt_location x.pmty_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.pmty_attributes;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.pmty_desc with
|
2012-12-08 12:55:17 -08:00
|
|
|
| Pmty_ident li -> line i ppf "Pmty_ident %a\n" fmt_longident_loc li;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pmty_signature (s) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pmty_signature\n";
|
|
|
|
signature i ppf s;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pmty_functor (s, mt1, mt2) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pmty_functor %a\n" fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
module_type i ppf mt1;
|
|
|
|
module_type i ppf mt2;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pmty_with (mt, l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pmty_with\n";
|
|
|
|
module_type i ppf mt;
|
2013-04-16 03:47:45 -07:00
|
|
|
list i with_constraint ppf l;
|
2010-04-02 05:53:33 -07:00
|
|
|
| Pmty_typeof m ->
|
|
|
|
line i ppf "Pmty_typeof\n";
|
2011-10-28 14:24:27 -07:00
|
|
|
module_expr i ppf m;
|
2013-03-04 06:11:15 -08:00
|
|
|
| Pmty_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pmod_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and signature i ppf x = list i signature_item ppf x
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and signature_item i ppf x =
|
|
|
|
line i ppf "signature_item %a\n" fmt_location x.psig_loc;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.psig_desc with
|
2013-03-06 04:00:18 -08:00
|
|
|
| Psig_value vd ->
|
|
|
|
line i ppf "Psig_value\n";
|
2000-03-06 14:12:09 -08:00
|
|
|
value_description i ppf vd;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Psig_type (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Psig_type\n";
|
2013-03-06 03:47:59 -08:00
|
|
|
list i type_declaration ppf l;
|
2013-03-25 08:49:10 -07:00
|
|
|
| Psig_exception cd ->
|
2013-03-05 04:37:17 -08:00
|
|
|
line i ppf "Psig_exception\n";
|
2013-03-25 08:49:10 -07:00
|
|
|
constructor_decl i ppf cd;
|
2013-03-04 09:39:07 -08:00
|
|
|
| Psig_module pmd ->
|
|
|
|
line i ppf "Psig_module %a\n" fmt_string_loc pmd.pmd_name;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf pmd.pmd_attributes;
|
|
|
|
module_type i ppf pmd.pmd_type
|
2003-06-19 08:53:53 -07:00
|
|
|
| Psig_recmodule decls ->
|
|
|
|
line i ppf "Psig_recmodule\n";
|
2013-03-04 09:39:07 -08:00
|
|
|
list i module_declaration ppf decls;
|
2013-03-06 04:14:02 -08:00
|
|
|
| Psig_modtype x ->
|
|
|
|
line i ppf "Psig_modtype %a\n" fmt_string_loc x.pmtd_name;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.pmtd_attributes;
|
|
|
|
modtype_declaration i ppf x.pmtd_type
|
2013-03-04 08:36:32 -08:00
|
|
|
| Psig_open (li, attrs) ->
|
|
|
|
line i ppf "Psig_open %a\n" fmt_longident_loc li;
|
|
|
|
attributes i ppf attrs
|
|
|
|
| Psig_include (mt, attrs) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Psig_include\n";
|
|
|
|
module_type i ppf mt;
|
2013-03-04 08:36:32 -08:00
|
|
|
attributes i ppf attrs
|
1999-11-29 11:04:43 -08:00
|
|
|
| Psig_class (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Psig_class\n";
|
|
|
|
list i class_description ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Psig_class_type (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Psig_class_type\n";
|
|
|
|
list i class_type_declaration ppf l;
|
2013-03-05 03:46:25 -08:00
|
|
|
| Psig_extension ((s, arg), attrs) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Psig_extension \"%s\"\n" s.txt;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf attrs;
|
2013-04-19 00:40:57 -07:00
|
|
|
structure i ppf arg
|
2013-03-06 04:27:32 -08:00
|
|
|
| Psig_attribute (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Psig_attribute \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2013-03-25 10:47:28 -07:00
|
|
|
and modtype_declaration i ppf = function
|
|
|
|
| None -> line i ppf "#abstract"
|
|
|
|
| Some mt -> module_type (i+1) ppf mt
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and with_constraint i ppf x =
|
1999-12-30 04:52:33 -08:00
|
|
|
match x with
|
2013-04-16 03:47:45 -07:00
|
|
|
| Pwith_type (lid, td) ->
|
|
|
|
line i ppf "Pwith_type %a\n" fmt_longident_loc lid;
|
2000-03-06 14:12:09 -08:00
|
|
|
type_declaration (i+1) ppf td;
|
2010-04-17 07:45:12 -07:00
|
|
|
| Pwith_typesubst (td) ->
|
|
|
|
line i ppf "Pwith_typesubst\n";
|
|
|
|
type_declaration (i+1) ppf td;
|
2013-04-16 03:47:45 -07:00
|
|
|
| Pwith_module (lid1, lid2) ->
|
|
|
|
line i ppf "Pwith_module %a = %a\n"
|
|
|
|
fmt_longident_loc lid1
|
|
|
|
fmt_longident_loc lid2;
|
|
|
|
| Pwith_modsubst (s, li) ->
|
|
|
|
line i ppf "Pwith_modsubst %a = %a\n"
|
|
|
|
fmt_string_loc s
|
|
|
|
fmt_longident_loc li;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and module_expr i ppf x =
|
|
|
|
line i ppf "module_expr %a\n" fmt_location x.pmod_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.pmod_attributes;
|
1999-12-30 04:52:33 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.pmod_desc with
|
2012-12-08 12:55:17 -08:00
|
|
|
| Pmod_ident (li) -> line i ppf "Pmod_ident %a\n" fmt_longident_loc li;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pmod_structure (s) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pmod_structure\n";
|
|
|
|
structure i ppf s;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pmod_functor (s, mt, me) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pmod_functor %a\n" fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
module_type i ppf mt;
|
|
|
|
module_expr i ppf me;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pmod_apply (me1, me2) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pmod_apply\n";
|
|
|
|
module_expr i ppf me1;
|
|
|
|
module_expr i ppf me2;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Pmod_constraint (me, mt) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pmod_constraint\n";
|
|
|
|
module_expr i ppf me;
|
|
|
|
module_type i ppf mt;
|
2010-10-21 16:59:33 -07:00
|
|
|
| Pmod_unpack (e) ->
|
|
|
|
line i ppf "Pmod_unpack\n";
|
2009-10-26 03:53:16 -07:00
|
|
|
expression i ppf e;
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pmod_extension (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pmod_extension \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and structure i ppf x = list i structure_item ppf x
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and structure_item i ppf x =
|
|
|
|
line i ppf "structure_item %a\n" fmt_location x.pstr_loc;
|
1999-11-29 11:04:43 -08:00
|
|
|
let i = i+1 in
|
|
|
|
match x.pstr_desc with
|
2013-04-11 07:07:32 -07:00
|
|
|
| Pstr_eval (e, attrs) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pstr_eval\n";
|
2013-04-11 07:07:32 -07:00
|
|
|
attributes i ppf attrs;
|
2000-03-06 14:12:09 -08:00
|
|
|
expression i ppf e;
|
2013-04-11 06:52:06 -07:00
|
|
|
| Pstr_value (rf, l, attrs) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pstr_value %a\n" fmt_rec_flag rf;
|
2013-04-11 06:52:06 -07:00
|
|
|
attributes i ppf attrs;
|
2000-03-06 14:12:09 -08:00
|
|
|
list i pattern_x_expression_def ppf l;
|
2013-03-06 04:00:18 -08:00
|
|
|
| Pstr_primitive vd ->
|
|
|
|
line i ppf "Pstr_primitive\n";
|
2000-03-06 14:12:09 -08:00
|
|
|
value_description i ppf vd;
|
2012-05-30 07:52:37 -07:00
|
|
|
| Pstr_type l ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pstr_type\n";
|
2013-03-06 03:47:59 -08:00
|
|
|
list i type_declaration ppf l;
|
2013-03-25 08:49:10 -07:00
|
|
|
| Pstr_exception cd ->
|
|
|
|
line i ppf "Pstr_exception\n";
|
|
|
|
constructor_decl i ppf cd;
|
2013-03-05 04:44:40 -08:00
|
|
|
| Pstr_exn_rebind (s, li, attrs) ->
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "Pstr_exn_rebind\n";
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf attrs;
|
2012-12-08 12:55:17 -08:00
|
|
|
line (i+1) ppf "%a\n" fmt_string_loc s;
|
2013-03-08 06:59:45 -08:00
|
|
|
line (i+1) ppf "%a\n" fmt_longident_loc li
|
2013-03-05 08:50:05 -08:00
|
|
|
| Pstr_module x ->
|
|
|
|
line i ppf "Pstr_module\n";
|
|
|
|
module_binding i ppf x
|
2003-06-19 08:53:53 -07:00
|
|
|
| Pstr_recmodule bindings ->
|
2003-07-02 02:14:35 -07:00
|
|
|
line i ppf "Pstr_recmodule\n";
|
2013-03-05 08:50:05 -08:00
|
|
|
list i module_binding ppf bindings;
|
2013-03-06 02:49:44 -08:00
|
|
|
| Pstr_modtype x ->
|
2013-04-18 06:14:53 -07:00
|
|
|
line i ppf "Pstr_modtype %a\n" fmt_string_loc x.pmtd_name;
|
|
|
|
attributes i ppf x.pmtd_attributes;
|
|
|
|
modtype_declaration i ppf x.pmtd_type
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pstr_open (li, attrs) ->
|
|
|
|
line i ppf "Pstr_open %a\n" fmt_longident_loc li;
|
|
|
|
attributes i ppf attrs
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pstr_class (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pstr_class\n";
|
|
|
|
list i class_declaration ppf l;
|
1999-11-29 11:04:43 -08:00
|
|
|
| Pstr_class_type (l) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Pstr_class_type\n";
|
|
|
|
list i class_type_declaration ppf l;
|
2013-03-04 04:54:57 -08:00
|
|
|
| Pstr_include (me, attrs) ->
|
2000-12-01 01:35:00 -08:00
|
|
|
line i ppf "Pstr_include";
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf attrs;
|
|
|
|
module_expr i ppf me
|
2013-03-05 03:46:25 -08:00
|
|
|
| Pstr_extension ((s, arg), attrs) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pstr_extension \"%s\"\n" s.txt;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf attrs;
|
2013-04-19 00:40:57 -07:00
|
|
|
structure i ppf arg
|
2013-03-06 04:27:32 -08:00
|
|
|
| Pstr_attribute (s, arg) ->
|
2013-04-19 00:40:57 -07:00
|
|
|
line i ppf "Pstr_attribute \"%s\"\n" s.txt;
|
|
|
|
structure i ppf arg
|
2000-03-06 14:12:09 -08:00
|
|
|
|
2013-03-04 09:39:07 -08:00
|
|
|
and module_declaration i ppf pmd =
|
|
|
|
string_loc i ppf pmd.pmd_name;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf pmd.pmd_attributes;
|
2013-03-04 09:39:07 -08:00
|
|
|
module_type (i+1) ppf pmd.pmd_type;
|
2003-06-19 08:53:53 -07:00
|
|
|
|
2013-03-05 08:50:05 -08:00
|
|
|
and module_binding i ppf x =
|
|
|
|
string_loc i ppf x.pmb_name;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf x.pmb_attributes;
|
|
|
|
module_expr (i+1) ppf x.pmb_expr
|
2003-06-19 08:53:53 -07:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and core_type_x_core_type_x_location i ppf (ct1, ct2, l) =
|
|
|
|
line i ppf "<constraint> %a\n" fmt_location l;
|
|
|
|
core_type (i+1) ppf ct1;
|
|
|
|
core_type (i+1) ppf ct2;
|
|
|
|
|
2013-03-04 07:35:47 -08:00
|
|
|
and constructor_decl i ppf {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} =
|
|
|
|
line i ppf "%a\n" fmt_location pcd_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf pcd_attributes;
|
2013-03-04 07:35:47 -08:00
|
|
|
line (i+1) ppf "%a\n" fmt_string_loc pcd_name;
|
|
|
|
list (i+1) core_type ppf pcd_args;
|
2013-03-08 06:59:45 -08:00
|
|
|
option (i+1) core_type ppf pcd_res
|
2000-03-06 14:12:09 -08:00
|
|
|
|
2013-03-06 05:51:18 -08:00
|
|
|
and label_decl i ppf {pld_name; pld_mutable; pld_type; pld_loc; pld_attributes} =
|
|
|
|
line i ppf "%a\n" fmt_location pld_loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
attributes i ppf pld_attributes;
|
2013-03-06 05:51:18 -08:00
|
|
|
line (i+1) ppf "%a\n" fmt_mutable_flag pld_mutable;
|
|
|
|
line (i+1) ppf "%a" fmt_string_loc pld_name;
|
2013-03-08 06:59:45 -08:00
|
|
|
core_type (i+1) ppf pld_type
|
2000-03-06 14:12:09 -08:00
|
|
|
|
2013-04-16 00:51:27 -07:00
|
|
|
and cl_type_parameters i ppf l =
|
|
|
|
line i ppf "<params>\n";
|
2013-04-02 08:33:35 -07:00
|
|
|
list (i+1) cl_type_parameter ppf l;
|
|
|
|
|
|
|
|
and cl_type_parameter i ppf (x, _variance) =
|
|
|
|
string_loc i ppf x
|
2000-03-06 14:12:09 -08:00
|
|
|
|
|
|
|
and longident_x_pattern i ppf (li, p) =
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "%a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
pattern (i+1) ppf p;
|
|
|
|
|
2013-04-15 09:23:22 -07:00
|
|
|
and case i ppf {pc_lhs; pc_guard; pc_rhs} =
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "<case>\n";
|
2013-04-15 09:23:22 -07:00
|
|
|
pattern (i+1) ppf pc_lhs;
|
|
|
|
begin match pc_guard with
|
|
|
|
| None -> ()
|
|
|
|
| Some g -> line (i+1) ppf "<when>\n"; expression (i + 2) ppf g
|
|
|
|
end;
|
|
|
|
expression (i+1) ppf pc_rhs;
|
2000-03-06 14:12:09 -08:00
|
|
|
|
|
|
|
and pattern_x_expression_def i ppf (p, e) =
|
|
|
|
line i ppf "<def>\n";
|
|
|
|
pattern (i+1) ppf p;
|
|
|
|
expression (i+1) ppf e;
|
|
|
|
|
|
|
|
and string_x_expression i ppf (s, e) =
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "<override> %a\n" fmt_string_loc s;
|
2000-03-06 14:12:09 -08:00
|
|
|
expression (i+1) ppf e;
|
|
|
|
|
|
|
|
and longident_x_expression i ppf (li, e) =
|
2012-12-08 12:55:17 -08:00
|
|
|
line i ppf "%a\n" fmt_longident_loc li;
|
2000-03-06 14:12:09 -08:00
|
|
|
expression (i+1) ppf e;
|
|
|
|
|
|
|
|
and label_x_expression i ppf (l,e) =
|
|
|
|
line i ppf "<label> \"%s\"\n" l;
|
|
|
|
expression (i+1) ppf e;
|
|
|
|
|
2001-09-25 02:54:18 -07:00
|
|
|
and label_x_bool_x_core_type_list i ppf x =
|
|
|
|
match x with
|
|
|
|
Rtag (l, b, ctl) ->
|
|
|
|
line i ppf "Rtag \"%s\" %s\n" l (string_of_bool b);
|
|
|
|
list (i+1) core_type ppf ctl
|
|
|
|
| Rinherit (ct) ->
|
|
|
|
line i ppf "Rinherit\n";
|
|
|
|
core_type (i+1) ppf ct
|
1999-12-30 04:52:33 -08:00
|
|
|
;;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let rec toplevel_phrase i ppf x =
|
1999-12-30 04:52:33 -08:00
|
|
|
match x with
|
|
|
|
| Ptop_def (s) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ptop_def\n";
|
|
|
|
structure (i+1) ppf s;
|
1999-12-30 04:52:33 -08:00
|
|
|
| Ptop_dir (s, da) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
line i ppf "Ptop_dir \"%s\"\n" s;
|
|
|
|
directive_argument i ppf da;
|
1999-12-30 04:52:33 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
and directive_argument i ppf x =
|
1999-12-30 04:52:33 -08:00
|
|
|
match x with
|
2000-03-06 14:12:09 -08:00
|
|
|
| Pdir_none -> line i ppf "Pdir_none\n"
|
|
|
|
| Pdir_string (s) -> line i ppf "Pdir_string \"%s\"\n" s;
|
|
|
|
| Pdir_int (i) -> line i ppf "Pdir_int %d\n" i;
|
2012-12-08 12:55:17 -08:00
|
|
|
| Pdir_ident (li) -> line i ppf "Pdir_ident %a\n" fmt_longident li;
|
2000-03-06 14:12:09 -08:00
|
|
|
| Pdir_bool (b) -> line i ppf "Pdir_bool %s\n" (string_of_bool b);
|
1999-11-29 11:04:43 -08:00
|
|
|
;;
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let interface ppf x = list 0 signature_item ppf x;;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let implementation ppf x = list 0 structure_item ppf x;;
|
1999-11-29 11:04:43 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let top_phrase ppf x = toplevel_phrase 0 ppf x;;
|