2013-03-08 06:59:45 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Alain Frisch, LexiFi *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2012 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. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(** Helpers to produce Parsetree fragments *)
|
|
|
|
|
|
|
|
open Asttypes
|
|
|
|
open Parsetree
|
|
|
|
|
2013-04-10 11:00:11 -07:00
|
|
|
type lid = Longident.t loc
|
|
|
|
type str = string loc
|
|
|
|
type loc = Location.t
|
|
|
|
type attrs = attribute list
|
|
|
|
|
2013-04-11 05:50:38 -07:00
|
|
|
let default_loc = ref Location.none
|
|
|
|
|
|
|
|
let with_default_loc l f =
|
|
|
|
let old = !default_loc in
|
|
|
|
default_loc := l;
|
|
|
|
try let r = f () in default_loc := old; r
|
|
|
|
with exn -> default_loc := old; raise exn
|
|
|
|
|
2013-03-08 06:59:45 -08:00
|
|
|
module Typ = struct
|
2014-04-12 03:17:02 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
|
|
|
{ptyp_desc = d; ptyp_loc = loc; ptyp_attributes = attrs}
|
2013-03-08 06:59:45 -08:00
|
|
|
let attr d a = {d with ptyp_attributes = d.ptyp_attributes @ [a]}
|
|
|
|
|
|
|
|
let any ?loc ?attrs () = mk ?loc ?attrs Ptyp_any
|
|
|
|
let var ?loc ?attrs a = mk ?loc ?attrs (Ptyp_var a)
|
|
|
|
let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_arrow (a, b, c))
|
|
|
|
let tuple ?loc ?attrs a = mk ?loc ?attrs (Ptyp_tuple a)
|
|
|
|
let constr ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_constr (a, b))
|
2013-04-09 07:10:54 -07:00
|
|
|
let object_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_object (a, b))
|
2013-04-16 05:17:17 -07:00
|
|
|
let class_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_class (a, b))
|
2013-03-08 06:59:45 -08:00
|
|
|
let alias ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_alias (a, b))
|
|
|
|
let variant ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_variant (a, b, c))
|
2013-04-09 07:10:54 -07:00
|
|
|
let poly ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_poly (a, b))
|
2013-03-08 06:59:45 -08:00
|
|
|
let package ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_package (a, b))
|
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Ptyp_extension a)
|
2013-04-09 07:10:54 -07:00
|
|
|
|
|
|
|
let force_poly t =
|
|
|
|
match t.ptyp_desc with
|
|
|
|
| Ptyp_poly _ -> t
|
|
|
|
| _ -> poly ~loc:t.ptyp_loc [] t (* -> ghost? *)
|
2013-03-08 06:59:45 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
module Pat = struct
|
2014-04-12 03:17:02 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
|
|
|
{ppat_desc = d; ppat_loc = loc; ppat_attributes = attrs}
|
2013-03-08 06:59:45 -08:00
|
|
|
let attr d a = {d with ppat_attributes = d.ppat_attributes @ [a]}
|
|
|
|
|
|
|
|
let any ?loc ?attrs () = mk ?loc ?attrs Ppat_any
|
|
|
|
let var ?loc ?attrs a = mk ?loc ?attrs (Ppat_var a)
|
|
|
|
let alias ?loc ?attrs a b = mk ?loc ?attrs (Ppat_alias (a, b))
|
2013-05-23 08:12:04 -07:00
|
|
|
let constant ?loc ?attrs a = mk ?loc ?attrs (Ppat_constant a)
|
|
|
|
let interval ?loc ?attrs a b = mk ?loc ?attrs (Ppat_interval (a, b))
|
2013-03-08 06:59:45 -08:00
|
|
|
let tuple ?loc ?attrs a = mk ?loc ?attrs (Ppat_tuple a)
|
2013-04-17 02:46:52 -07:00
|
|
|
let construct ?loc ?attrs a b = mk ?loc ?attrs (Ppat_construct (a, b))
|
2013-03-08 06:59:45 -08:00
|
|
|
let variant ?loc ?attrs a b = mk ?loc ?attrs (Ppat_variant (a, b))
|
|
|
|
let record ?loc ?attrs a b = mk ?loc ?attrs (Ppat_record (a, b))
|
|
|
|
let array ?loc ?attrs a = mk ?loc ?attrs (Ppat_array a)
|
|
|
|
let or_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_or (a, b))
|
|
|
|
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_constraint (a, b))
|
|
|
|
let type_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_type a)
|
|
|
|
let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_lazy a)
|
|
|
|
let unpack ?loc ?attrs a = mk ?loc ?attrs (Ppat_unpack a)
|
2014-05-05 04:49:37 -07:00
|
|
|
let exception_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_exception a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Ppat_extension a)
|
|
|
|
end
|
|
|
|
|
|
|
|
module Exp = struct
|
2014-04-12 03:17:02 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
|
|
|
{pexp_desc = d; pexp_loc = loc; pexp_attributes = attrs}
|
2013-03-08 06:59:45 -08:00
|
|
|
let attr d a = {d with pexp_attributes = d.pexp_attributes @ [a]}
|
|
|
|
|
|
|
|
let ident ?loc ?attrs a = mk ?loc ?attrs (Pexp_ident a)
|
2013-05-23 08:12:04 -07:00
|
|
|
let constant ?loc ?attrs a = mk ?loc ?attrs (Pexp_constant a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_let (a, b, c))
|
2013-04-17 04:43:29 -07:00
|
|
|
let fun_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pexp_fun (a, b, c, d))
|
|
|
|
let function_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_function a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let apply ?loc ?attrs a b = mk ?loc ?attrs (Pexp_apply (a, b))
|
|
|
|
let match_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_match (a, b))
|
|
|
|
let try_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_try (a, b))
|
|
|
|
let tuple ?loc ?attrs a = mk ?loc ?attrs (Pexp_tuple a)
|
2013-04-17 02:46:52 -07:00
|
|
|
let construct ?loc ?attrs a b = mk ?loc ?attrs (Pexp_construct (a, b))
|
2013-03-08 06:59:45 -08:00
|
|
|
let variant ?loc ?attrs a b = mk ?loc ?attrs (Pexp_variant (a, b))
|
|
|
|
let record ?loc ?attrs a b = mk ?loc ?attrs (Pexp_record (a, b))
|
|
|
|
let field ?loc ?attrs a b = mk ?loc ?attrs (Pexp_field (a, b))
|
|
|
|
let setfield ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_setfield (a, b, c))
|
|
|
|
let array ?loc ?attrs a = mk ?loc ?attrs (Pexp_array a)
|
|
|
|
let ifthenelse ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_ifthenelse (a, b, c))
|
|
|
|
let sequence ?loc ?attrs a b = mk ?loc ?attrs (Pexp_sequence (a, b))
|
|
|
|
let while_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_while (a, b))
|
|
|
|
let for_ ?loc ?attrs a b c d e = mk ?loc ?attrs (Pexp_for (a, b, c, d, e))
|
2013-04-17 05:23:44 -07:00
|
|
|
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_constraint (a, b))
|
|
|
|
let coerce ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_coerce (a, b, c))
|
2013-03-08 06:59:45 -08:00
|
|
|
let send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b))
|
|
|
|
let new_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_new a)
|
|
|
|
let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b))
|
|
|
|
let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a)
|
|
|
|
let letmodule ?loc ?attrs a b c= mk ?loc ?attrs (Pexp_letmodule (a, b, c))
|
|
|
|
let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a)
|
|
|
|
let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_lazy a)
|
|
|
|
let poly ?loc ?attrs a b = mk ?loc ?attrs (Pexp_poly (a, b))
|
|
|
|
let object_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_object a)
|
|
|
|
let newtype ?loc ?attrs a b = mk ?loc ?attrs (Pexp_newtype (a, b))
|
|
|
|
let pack ?loc ?attrs a = mk ?loc ?attrs (Pexp_pack a)
|
2013-07-16 06:34:30 -07:00
|
|
|
let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_open (a, b, c))
|
2013-03-08 06:59:45 -08:00
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pexp_extension a)
|
2013-04-15 09:23:22 -07:00
|
|
|
|
|
|
|
let case lhs ?guard rhs =
|
|
|
|
{
|
|
|
|
pc_lhs = lhs;
|
|
|
|
pc_guard = guard;
|
|
|
|
pc_rhs = rhs;
|
|
|
|
}
|
2013-03-08 06:59:45 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
module Mty = struct
|
2014-04-12 03:17:02 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
|
|
|
{pmty_desc = d; pmty_loc = loc; pmty_attributes = attrs}
|
2013-03-08 06:59:45 -08:00
|
|
|
let attr d a = {d with pmty_attributes = d.pmty_attributes @ [a]}
|
|
|
|
|
|
|
|
let ident ?loc ?attrs a = mk ?loc ?attrs (Pmty_ident a)
|
2013-09-29 00:22:34 -07:00
|
|
|
let alias ?loc ?attrs a = mk ?loc ?attrs (Pmty_alias a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let signature ?loc ?attrs a = mk ?loc ?attrs (Pmty_signature a)
|
|
|
|
let functor_ ?loc ?attrs a b c = mk ?loc ?attrs (Pmty_functor (a, b, c))
|
|
|
|
let with_ ?loc ?attrs a b = mk ?loc ?attrs (Pmty_with (a, b))
|
|
|
|
let typeof_ ?loc ?attrs a = mk ?loc ?attrs (Pmty_typeof a)
|
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pmty_extension a)
|
|
|
|
end
|
|
|
|
|
|
|
|
module Mod = struct
|
2014-04-12 03:17:02 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
|
|
|
{pmod_desc = d; pmod_loc = loc; pmod_attributes = attrs}
|
2013-03-08 06:59:45 -08:00
|
|
|
let attr d a = {d with pmod_attributes = d.pmod_attributes @ [a]}
|
|
|
|
|
|
|
|
let ident ?loc ?attrs x = mk ?loc ?attrs (Pmod_ident x)
|
|
|
|
let structure ?loc ?attrs x = mk ?loc ?attrs (Pmod_structure x)
|
2014-04-12 03:17:02 -07:00
|
|
|
let functor_ ?loc ?attrs arg arg_ty body =
|
|
|
|
mk ?loc ?attrs (Pmod_functor (arg, arg_ty, body))
|
2013-03-08 06:59:45 -08:00
|
|
|
let apply ?loc ?attrs m1 m2 = mk ?loc ?attrs (Pmod_apply (m1, m2))
|
|
|
|
let constraint_ ?loc ?attrs m mty = mk ?loc ?attrs (Pmod_constraint (m, mty))
|
|
|
|
let unpack ?loc ?attrs e = mk ?loc ?attrs (Pmod_unpack e)
|
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pmod_extension a)
|
|
|
|
end
|
|
|
|
|
|
|
|
module Sig = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) d = {psig_desc = d; psig_loc = loc}
|
2013-03-08 06:59:45 -08:00
|
|
|
|
|
|
|
let value ?loc a = mk ?loc (Psig_value a)
|
2015-03-13 04:07:57 -07:00
|
|
|
let type_ ?loc rec_flag a = mk ?loc (Psig_type (rec_flag, a))
|
2014-05-04 16:08:45 -07:00
|
|
|
let type_extension ?loc a = mk ?loc (Psig_typext a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let exception_ ?loc a = mk ?loc (Psig_exception a)
|
|
|
|
let module_ ?loc a = mk ?loc (Psig_module a)
|
|
|
|
let rec_module ?loc a = mk ?loc (Psig_recmodule a)
|
|
|
|
let modtype ?loc a = mk ?loc (Psig_modtype a)
|
2014-04-15 04:26:00 -07:00
|
|
|
let open_ ?loc a = mk ?loc (Psig_open a)
|
|
|
|
let include_ ?loc a = mk ?loc (Psig_include a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let class_ ?loc a = mk ?loc (Psig_class a)
|
|
|
|
let class_type ?loc a = mk ?loc (Psig_class_type a)
|
|
|
|
let extension ?loc ?(attrs = []) a = mk ?loc (Psig_extension (a, attrs))
|
|
|
|
let attribute ?loc a = mk ?loc (Psig_attribute a)
|
|
|
|
end
|
|
|
|
|
|
|
|
module Str = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) d = {pstr_desc = d; pstr_loc = loc}
|
2013-03-08 06:59:45 -08:00
|
|
|
|
2013-04-11 07:07:32 -07:00
|
|
|
let eval ?loc ?(attrs = []) a = mk ?loc (Pstr_eval (a, attrs))
|
2013-06-03 08:14:19 -07:00
|
|
|
let value ?loc a b = mk ?loc (Pstr_value (a, b))
|
2013-03-08 06:59:45 -08:00
|
|
|
let primitive ?loc a = mk ?loc (Pstr_primitive a)
|
2015-03-13 04:07:57 -07:00
|
|
|
let type_ ?loc rec_flag a = mk ?loc (Pstr_type (rec_flag, a))
|
2014-05-04 16:08:45 -07:00
|
|
|
let type_extension ?loc a = mk ?loc (Pstr_typext a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let exception_ ?loc a = mk ?loc (Pstr_exception a)
|
|
|
|
let module_ ?loc a = mk ?loc (Pstr_module a)
|
|
|
|
let rec_module ?loc a = mk ?loc (Pstr_recmodule a)
|
|
|
|
let modtype ?loc a = mk ?loc (Pstr_modtype a)
|
2014-04-15 04:26:00 -07:00
|
|
|
let open_ ?loc a = mk ?loc (Pstr_open a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let class_ ?loc a = mk ?loc (Pstr_class a)
|
|
|
|
let class_type ?loc a = mk ?loc (Pstr_class_type a)
|
2014-04-15 04:26:00 -07:00
|
|
|
let include_ ?loc a = mk ?loc (Pstr_include a)
|
2013-03-08 06:59:45 -08:00
|
|
|
let extension ?loc ?(attrs = []) a = mk ?loc (Pstr_extension (a, attrs))
|
|
|
|
let attribute ?loc a = mk ?loc (Pstr_attribute a)
|
|
|
|
end
|
|
|
|
|
|
|
|
module Cl = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
2013-04-10 10:26:55 -07:00
|
|
|
{
|
|
|
|
pcl_desc = d;
|
|
|
|
pcl_loc = loc;
|
|
|
|
pcl_attributes = attrs;
|
|
|
|
}
|
|
|
|
let attr d a = {d with pcl_attributes = d.pcl_attributes @ [a]}
|
|
|
|
|
|
|
|
let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcl_constr (a, b))
|
|
|
|
let structure ?loc ?attrs a = mk ?loc ?attrs (Pcl_structure a)
|
|
|
|
let fun_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pcl_fun (a, b, c, d))
|
|
|
|
let apply ?loc ?attrs a b = mk ?loc ?attrs (Pcl_apply (a, b))
|
|
|
|
let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcl_let (a, b, c))
|
|
|
|
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pcl_constraint (a, b))
|
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pcl_extension a)
|
2013-03-08 06:59:45 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
module Cty = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
2013-04-10 10:44:15 -07:00
|
|
|
{
|
|
|
|
pcty_desc = d;
|
|
|
|
pcty_loc = loc;
|
|
|
|
pcty_attributes = attrs;
|
|
|
|
}
|
|
|
|
let attr d a = {d with pcty_attributes = d.pcty_attributes @ [a]}
|
2013-03-08 06:59:45 -08:00
|
|
|
|
2013-04-10 10:44:15 -07:00
|
|
|
let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcty_constr (a, b))
|
|
|
|
let signature ?loc ?attrs a = mk ?loc ?attrs (Pcty_signature a)
|
2013-04-16 01:59:09 -07:00
|
|
|
let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_arrow (a, b, c))
|
2013-04-10 10:44:15 -07:00
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pcty_extension a)
|
2013-03-08 06:59:45 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
module Ctf = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
2013-04-10 02:17:22 -07:00
|
|
|
{
|
|
|
|
pctf_desc = d;
|
|
|
|
pctf_loc = loc;
|
|
|
|
pctf_attributes = attrs;
|
|
|
|
}
|
|
|
|
let attr d a = {d with pctf_attributes = d.pctf_attributes @ [a]}
|
2013-03-08 06:59:45 -08:00
|
|
|
|
2013-04-10 04:17:41 -07:00
|
|
|
let inherit_ ?loc ?attrs a = mk ?loc ?attrs (Pctf_inherit a)
|
2013-04-10 02:17:22 -07:00
|
|
|
let val_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_val (a, b, c, d))
|
2013-04-10 04:17:41 -07:00
|
|
|
let method_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_method (a, b, c, d))
|
|
|
|
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pctf_constraint (a, b))
|
2013-04-10 10:54:54 -07:00
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pctf_extension a)
|
2014-05-04 13:42:34 -07:00
|
|
|
let attribute ?loc a = mk ?loc (Pctf_attribute a)
|
2013-03-08 06:59:45 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
module Cf = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) d =
|
2013-04-09 08:54:41 -07:00
|
|
|
{
|
|
|
|
pcf_desc = d;
|
|
|
|
pcf_loc = loc;
|
|
|
|
pcf_attributes = attrs;
|
|
|
|
}
|
|
|
|
let attr d a = {d with pcf_attributes = d.pcf_attributes @ [a]}
|
|
|
|
|
2013-04-10 04:17:41 -07:00
|
|
|
let inherit_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_inherit (a, b, c))
|
|
|
|
let val_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_val (a, b, c))
|
|
|
|
let method_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_method (a, b, c))
|
|
|
|
let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pcf_constraint (a, b))
|
|
|
|
let initializer_ ?loc ?attrs a = mk ?loc ?attrs (Pcf_initializer a)
|
2013-04-10 10:54:54 -07:00
|
|
|
let extension ?loc ?attrs a = mk ?loc ?attrs (Pcf_extension a)
|
2014-05-04 13:42:34 -07:00
|
|
|
let attribute ?loc a = mk ?loc (Pcf_attribute a)
|
2013-04-10 04:17:41 -07:00
|
|
|
|
|
|
|
let virtual_ ct = Cfk_virtual ct
|
|
|
|
let concrete o e = Cfk_concrete (o, e)
|
2013-03-08 06:59:45 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
module Val = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) ?(prim = []) name typ =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pval_name = name;
|
|
|
|
pval_type = typ;
|
|
|
|
pval_attributes = attrs;
|
|
|
|
pval_loc = loc;
|
|
|
|
pval_prim = prim;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
module Md = struct
|
2014-01-30 04:18:34 -08:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) name typ =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pmd_name = name;
|
|
|
|
pmd_type = typ;
|
|
|
|
pmd_attributes = attrs;
|
2014-01-30 04:18:34 -08:00
|
|
|
pmd_loc = loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
module Mtd = struct
|
2014-01-30 04:18:34 -08:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) ?typ name =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pmtd_name = name;
|
|
|
|
pmtd_type = typ;
|
|
|
|
pmtd_attributes = attrs;
|
2014-01-30 04:18:34 -08:00
|
|
|
pmtd_loc = loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
module Mb = struct
|
2014-01-30 04:18:34 -08:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) name expr =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pmb_name = name;
|
|
|
|
pmb_expr = expr;
|
|
|
|
pmb_attributes = attrs;
|
2014-01-30 04:18:34 -08:00
|
|
|
pmb_loc = loc;
|
2013-03-08 06:59:45 -08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2014-04-15 04:26:00 -07:00
|
|
|
module Opn = struct
|
2014-04-22 08:28:20 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) ?(override = Fresh) lid =
|
2014-04-15 04:26:00 -07:00
|
|
|
{
|
|
|
|
popen_lid = lid;
|
|
|
|
popen_override = override;
|
2014-04-22 08:28:20 -07:00
|
|
|
popen_loc = loc;
|
2014-04-15 04:26:00 -07:00
|
|
|
popen_attributes = attrs;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
module Incl = struct
|
2014-04-22 08:28:20 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) mexpr =
|
2014-04-15 04:26:00 -07:00
|
|
|
{
|
|
|
|
pincl_mod = mexpr;
|
2014-04-22 08:28:20 -07:00
|
|
|
pincl_loc = loc;
|
2014-04-15 04:26:00 -07:00
|
|
|
pincl_attributes = attrs;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-06-03 08:14:19 -07:00
|
|
|
module Vb = struct
|
2014-04-22 08:28:20 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) pat expr =
|
2013-06-03 08:14:19 -07:00
|
|
|
{
|
|
|
|
pvb_pat = pat;
|
|
|
|
pvb_expr = expr;
|
|
|
|
pvb_attributes = attrs;
|
2014-04-22 08:28:20 -07:00
|
|
|
pvb_loc = loc;
|
2013-06-03 08:14:19 -07:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-03-08 06:59:45 -08:00
|
|
|
module Ci = struct
|
2014-04-12 03:17:02 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = []) ?(virt = Concrete) ?(params = [])
|
|
|
|
name expr =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pci_virt = virt;
|
|
|
|
pci_params = params;
|
|
|
|
pci_name = name;
|
|
|
|
pci_expr = expr;
|
|
|
|
pci_attributes = attrs;
|
|
|
|
pci_loc = loc;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
module Type = struct
|
2013-04-11 05:50:38 -07:00
|
|
|
let mk ?(loc = !default_loc) ?(attrs = [])
|
2013-03-08 06:59:45 -08:00
|
|
|
?(params = [])
|
|
|
|
?(cstrs = [])
|
|
|
|
?(kind = Ptype_abstract)
|
|
|
|
?(priv = Public)
|
|
|
|
?manifest
|
|
|
|
name =
|
|
|
|
{
|
|
|
|
ptype_name = name;
|
|
|
|
ptype_params = params;
|
|
|
|
ptype_cstrs = cstrs;
|
|
|
|
ptype_kind = kind;
|
|
|
|
ptype_private = priv;
|
|
|
|
ptype_manifest = manifest;
|
|
|
|
ptype_attributes = attrs;
|
|
|
|
ptype_loc = loc;
|
|
|
|
}
|
|
|
|
|
2014-03-28 10:08:53 -07:00
|
|
|
let constructor ?(loc = !default_loc) ?(attrs = []) ?(args = Pcstr_tuple []) ?res name =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pcd_name = name;
|
|
|
|
pcd_args = args;
|
|
|
|
pcd_res = res;
|
|
|
|
pcd_loc = loc;
|
|
|
|
pcd_attributes = attrs;
|
|
|
|
}
|
|
|
|
|
2013-04-16 06:31:35 -07:00
|
|
|
let field ?(loc = !default_loc) ?(attrs = []) ?(mut = Immutable) name typ =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pld_name = name;
|
|
|
|
pld_mutable = mut;
|
|
|
|
pld_type = typ;
|
|
|
|
pld_loc = loc;
|
|
|
|
pld_attributes = attrs;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2014-05-04 16:08:45 -07:00
|
|
|
(** Type extensions *)
|
|
|
|
module Te = struct
|
|
|
|
let mk ?(attrs = []) ?(params = []) ?(priv = Public) path constructors =
|
|
|
|
{
|
|
|
|
ptyext_path = path;
|
|
|
|
ptyext_params = params;
|
|
|
|
ptyext_constructors = constructors;
|
|
|
|
ptyext_private = priv;
|
|
|
|
ptyext_attributes = attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
let constructor ?(loc = !default_loc) ?(attrs = []) name kind =
|
|
|
|
{
|
|
|
|
pext_name = name;
|
|
|
|
pext_kind = kind;
|
|
|
|
pext_loc = loc;
|
|
|
|
pext_attributes = attrs;
|
|
|
|
}
|
|
|
|
|
2014-10-14 08:51:30 -07:00
|
|
|
let decl ?(loc = !default_loc) ?(attrs = []) ?(args = Pcstr_tuple []) ?res name =
|
2014-05-04 16:08:45 -07:00
|
|
|
{
|
|
|
|
pext_name = name;
|
|
|
|
pext_kind = Pext_decl(args, res);
|
|
|
|
pext_loc = loc;
|
|
|
|
pext_attributes = attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
let rebind ?(loc = !default_loc) ?(attrs = []) name lid =
|
|
|
|
{
|
|
|
|
pext_name = name;
|
|
|
|
pext_kind = Pext_rebind lid;
|
|
|
|
pext_loc = loc;
|
|
|
|
pext_attributes = attrs;
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-03-08 06:59:45 -08:00
|
|
|
module Csig = struct
|
2013-04-16 02:21:05 -07:00
|
|
|
let mk self fields =
|
2013-03-08 06:59:45 -08:00
|
|
|
{
|
|
|
|
pcsig_self = self;
|
|
|
|
pcsig_fields = fields;
|
2013-04-16 02:21:05 -07:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
module Cstr = struct
|
|
|
|
let mk self fields =
|
|
|
|
{
|
|
|
|
pcstr_self = self;
|
|
|
|
pcstr_fields = fields;
|
2013-03-08 06:59:45 -08:00
|
|
|
}
|
|
|
|
end
|