summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2013-03-04 16:36:32 +0000
committerAlain Frisch <alain@frisch.fr>2013-03-04 16:36:32 +0000
commita5059464fee285ba0b73253ed873c5df92a633b2 (patch)
tree5953fd0a5a8bad559fa0de2f6e8abc58557ac9da
parent46c790a6639e4fecfe9725d2f1cae43d202370cc (diff)
downloadocaml-a5059464fee285ba0b73253ed873c5df92a633b2.tar.gz
Attributes on open/include in signatures.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13343 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml4
-rw-r--r--camlp4/boot/Camlp4.ml4
-rw-r--r--ocamldoc/odoc_sig.ml2
-rw-r--r--otherlibs/labltk/browser/searchpos.ml6
-rw-r--r--parsing/ast_mapper.ml8
-rw-r--r--parsing/ast_mapper.mli4
-rw-r--r--parsing/parser.mly16
-rw-r--r--parsing/parsetree.mli4
-rw-r--r--parsing/pprintast.ml4
-rw-r--r--parsing/printast.ml7
-rw-r--r--tools/depend.ml4
-rw-r--r--tools/untypeast.ml4
-rw-r--r--typing/typemod.ml8
13 files changed, 39 insertions, 36 deletions
diff --git a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
index 1e4c5a4cf6..308d44d44d 100644
--- a/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
+++ b/camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml
@@ -1001,7 +1001,7 @@ value varify_constructors var_names =
{ped_args=List.map ctyp (list_of_ctyp t []); ped_attributes=[]}) :: l]
| SgExc _ _ -> assert False (*FIXME*)
| SgExt loc n t sl -> [mksig loc (Psig_value (with_loc n loc) (mkvalue_desc loc t (list_of_meta_list sl))) :: l]
- | SgInc loc mt -> [mksig loc (Psig_include (module_type mt)) :: l]
+ | SgInc loc mt -> [mksig loc (Psig_include (module_type mt) []) :: l]
| SgMod loc n mt -> [mksig loc (Psig_module (with_loc n loc) (module_type mt)) :: l]
| SgRecMod loc mb ->
[mksig loc (Psig_recmodule (module_sig_binding mb [])) :: l]
@@ -1013,7 +1013,7 @@ value varify_constructors var_names =
in
[mksig loc (Psig_modtype (with_loc n loc) si) :: l]
| SgOpn loc id ->
- [mksig loc (Psig_open (long_uident id)) :: l]
+ [mksig loc (Psig_open (long_uident id) []) :: l]
| SgTyp loc tdl -> [mksig loc (Psig_type (mktype_decl tdl [])) :: l]
| SgVal loc n t -> [mksig loc (Psig_value (with_loc n loc) (mkvalue_desc loc t [])) :: l]
| <:sig_item@loc< $anti:_$ >> -> error loc "antiquotation in sig_item" ]
diff --git a/camlp4/boot/Camlp4.ml b/camlp4/boot/Camlp4.ml
index 7dd6f6cd36..be1e85f698 100644
--- a/camlp4/boot/Camlp4.ml
+++ b/camlp4/boot/Camlp4.ml
@@ -15332,7 +15332,7 @@ module Struct =
(mkvalue_desc loc t (list_of_meta_list sl))))) ::
l
| SgInc (loc, mt) ->
- (mksig loc (Psig_include (module_type mt))) :: l
+ (mksig loc (Psig_include (module_type mt, []))) :: l
| SgMod (loc, n, mt) ->
(mksig loc
(Psig_module ((with_loc n loc), (module_type mt)))) ::
@@ -15347,7 +15347,7 @@ module Struct =
| _ -> Pmodtype_manifest (module_type mt))
in (mksig loc (Psig_modtype ((with_loc n loc), si))) :: l
| SgOpn (loc, id) ->
- (mksig loc (Psig_open (long_uident id))) :: l
+ (mksig loc (Psig_open (long_uident id, []))) :: l
| SgTyp (loc, tdl) ->
(mksig loc (Psig_type (mktype_decl tdl []))) :: l
| SgVal (loc, n, t) ->
diff --git a/ocamldoc/odoc_sig.ml b/ocamldoc/odoc_sig.ml
index c49135c167..ed96863cc3 100644
--- a/ocamldoc/odoc_sig.ml
+++ b/ocamldoc/odoc_sig.ml
@@ -867,7 +867,7 @@ module Analyser =
in
(maybe_more, new_env2, [ Element_module_type mt ])
- | Parsetree.Psig_include module_type ->
+ | Parsetree.Psig_include (module_type, _attrs) ->
let rec f = function
Parsetree.Pmty_ident longident ->
Name.from_longident longident.txt
diff --git a/otherlibs/labltk/browser/searchpos.ml b/otherlibs/labltk/browser/searchpos.ml
index aa89772793..f999dccfd6 100644
--- a/otherlibs/labltk/browser/searchpos.ml
+++ b/otherlibs/labltk/browser/searchpos.ml
@@ -189,7 +189,7 @@ let rec search_pos_signature l ~pos ~env =
List.fold_left l ~init:env ~f:
begin fun env pt ->
let env = match pt.psig_desc with
- Psig_open id ->
+ Psig_open (id, _) ->
let path, mt = lookup_module id.txt env in
begin match mt with
Mty_signature sign -> open_signature path sign env
@@ -222,8 +222,8 @@ let rec search_pos_signature l ~pos ~env =
List.iter l
~f:(fun ci -> search_pos_class_type ci.pci_expr ~pos ~env)
(* The last cases should not happen in generated interfaces *)
- | Psig_open lid -> add_found_sig (`Module, lid.txt) ~env ~loc:pt.psig_loc
- | Psig_include t -> search_pos_module t ~pos ~env
+ | Psig_open (lid, _) -> add_found_sig (`Module, lid.txt) ~env ~loc:pt.psig_loc
+ | Psig_include (t, _) -> search_pos_module t ~pos ~env
end;
env
end)
diff --git a/parsing/ast_mapper.ml b/parsing/ast_mapper.ml
index b149491d3b..d7c9652b3a 100644
--- a/parsing/ast_mapper.ml
+++ b/parsing/ast_mapper.ml
@@ -199,8 +199,8 @@ module MT = struct
let module_ ?loc a b = mk_item ?loc (Psig_module (a, b))
let rec_module ?loc a = mk_item ?loc (Psig_recmodule a)
let modtype ?loc a b = mk_item ?loc (Psig_modtype (a, b))
- let open_ ?loc a = mk_item ?loc (Psig_open a)
- let include_ ?loc a = mk_item ?loc (Psig_include a)
+ let open_ ?loc ?(attributes = []) a = mk_item ?loc (Psig_open (a, attributes))
+ let include_ ?loc ?(attributes = []) a = mk_item ?loc (Psig_include (a, attributes))
let class_ ?loc a = mk_item ?loc (Psig_class a)
let class_type ?loc a = mk_item ?loc (Psig_class_type a)
@@ -214,8 +214,8 @@ module MT = struct
| Psig_recmodule l -> rec_module ~loc (List.map (map_tuple (map_loc sub) (sub # module_type)) l)
| Psig_modtype (s, Pmodtype_manifest mt) -> modtype ~loc (map_loc sub s) (Pmodtype_manifest (sub # module_type mt))
| Psig_modtype (s, Pmodtype_abstract) -> modtype ~loc (map_loc sub s) Pmodtype_abstract
- | Psig_open s -> open_ ~loc (map_loc sub s)
- | Psig_include mt -> include_ ~loc (sub # module_type mt)
+ | Psig_open (lid, attrs) -> open_ ~loc ~attributes:(map_attributes sub attrs) (map_loc sub lid)
+ | Psig_include (mt, attrs) -> include_ ~loc (sub # module_type mt) ~attributes:(map_attributes sub attrs)
| Psig_class l -> class_ ~loc (List.map (sub # class_description) l)
| Psig_class_type l -> class_type ~loc (List.map (sub # class_type_declaration) l)
diff --git a/parsing/ast_mapper.mli b/parsing/ast_mapper.mli
index b6826f9181..55746c9601 100644
--- a/parsing/ast_mapper.mli
+++ b/parsing/ast_mapper.mli
@@ -149,8 +149,8 @@ module MT:
val module_: ?loc:Location.t -> string loc -> module_type -> signature_item
val rec_module: ?loc:Location.t -> (string loc * module_type) list -> signature_item
val modtype: ?loc:Location.t -> string loc -> modtype_declaration -> signature_item
- val open_: ?loc:Location.t -> Longident.t loc -> signature_item
- val include_: ?loc:Location.t -> module_type -> signature_item
+ val open_: ?loc:Location.t -> ?attributes:Parsetree.attribute list -> Longident.t loc -> signature_item
+ val include_: ?loc:Location.t -> ?attributes:Parsetree.attribute list -> module_type -> signature_item
val class_: ?loc:Location.t -> class_description list -> signature_item
val class_type: ?loc:Location.t -> class_type_declaration list -> signature_item
val map_signature_item: mapper -> signature_item -> signature_item
diff --git a/parsing/parser.mly b/parsing/parser.mly
index 92d143456e..2338896368 100644
--- a/parsing/parser.mly
+++ b/parsing/parser.mly
@@ -609,10 +609,10 @@ structure_item:
pval_loc = symbol_rloc ()})) }
| TYPE type_declarations
{ mkstr(Pstr_type(List.rev $2)) }
- | EXCEPTION UIDENT constructor_arguments
- { mkstr(Pstr_exception(mkrhs $2 2, {ped_args=$3;ped_attributes=[]})) }
- | EXCEPTION UIDENT EQUAL constr_longident
- { mkstr(Pstr_exn_rebind(mkrhs $2 2, mkloc $4 (rhs_loc 4))) }
+ | opt_with_pre_attributes EXCEPTION UIDENT constructor_arguments opt_with_attributes
+ { mkstr(Pstr_exception(mkrhs $3 3, {ped_args=$4;ped_attributes=$1 @ $5})) }
+ | opt_with_pre_attributes EXCEPTION UIDENT EQUAL constr_longident opt_with_attributes
+ { mkstr(Pstr_exn_rebind(mkrhs $3 3, mkloc $5 (rhs_loc 5))) (* todo: keep attributes *) }
| MODULE UIDENT module_binding
{ mkstr(Pstr_module(mkrhs $2 2, $3)) }
| MODULE REC module_rec_bindings
@@ -697,10 +697,10 @@ signature_item:
{ mksig(Psig_modtype(mkrhs $3 3, Pmodtype_abstract)) }
| MODULE TYPE ident EQUAL module_type
{ mksig(Psig_modtype(mkrhs $3 3, Pmodtype_manifest $5)) }
- | OPEN mod_longident
- { mksig(Psig_open (mkrhs $2 2)) }
- | INCLUDE module_type %prec below_WITH
- { mksig(Psig_include $2) }
+ | opt_with_pre_attributes OPEN mod_longident opt_with_attributes
+ { mksig(Psig_open (mkrhs $3 3, $1 @ $4)) }
+ | opt_with_pre_attributes INCLUDE module_type opt_with_attributes %prec below_WITH
+ { mksig(Psig_include ($3, $1 @ $4)) }
| CLASS class_descriptions
{ mksig(Psig_class (List.rev $2)) }
| CLASS TYPE class_type_declarations
diff --git a/parsing/parsetree.mli b/parsing/parsetree.mli
index 23a9c5898a..c3d17cea3a 100644
--- a/parsing/parsetree.mli
+++ b/parsing/parsetree.mli
@@ -270,8 +270,8 @@ and signature_item_desc =
| Psig_module of string loc * module_type
| Psig_recmodule of (string loc * module_type) list
| Psig_modtype of string loc * modtype_declaration
- | Psig_open of Longident.t loc
- | Psig_include of module_type
+ | Psig_open of Longident.t loc * attribute list
+ | Psig_include of module_type * attribute list
| Psig_class of class_description list
| Psig_class_type of class_type_declaration list
diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml
index 30fb8d79ba..7fb87312a9 100644
--- a/parsing/pprintast.ml
+++ b/parsing/pprintast.ml
@@ -891,9 +891,9 @@ class printer ()= object(self:'self)
pp f "@[<hov>module@ %s@ :@ %a@]"
s.txt
self#module_type mt
- | Psig_open li ->
+ | Psig_open (li, _attrs) ->
pp f "@[<hov2>open@ %a@]" self#longident_loc li
- | Psig_include (mt) ->
+ | Psig_include (mt, _attrs) ->
pp f "@[<hov2>include@ %a@]"
self#module_type mt
| Psig_modtype (s, md) ->
diff --git a/parsing/printast.ml b/parsing/printast.ml
index f1a5e26a97..1826934491 100644
--- a/parsing/printast.ml
+++ b/parsing/printast.ml
@@ -599,10 +599,13 @@ and signature_item i ppf x =
| Psig_modtype (s, md) ->
line i ppf "Psig_modtype %a\n" fmt_string_loc s;
modtype_declaration i ppf md;
- | Psig_open li -> line i ppf "Psig_open %a\n" fmt_longident_loc li;
- | Psig_include (mt) ->
+ | Psig_open (li, attrs) ->
+ line i ppf "Psig_open %a\n" fmt_longident_loc li;
+ attributes i ppf attrs
+ | Psig_include (mt, attrs) ->
line i ppf "Psig_include\n";
module_type i ppf mt;
+ attributes i ppf attrs
| Psig_class (l) ->
line i ppf "Psig_class\n";
list i class_description ppf l;
diff --git a/tools/depend.ml b/tools/depend.ml
index 9e3d89d341..3c1f16df9d 100644
--- a/tools/depend.ml
+++ b/tools/depend.ml
@@ -235,9 +235,9 @@ and add_sig_item bv item =
| Pmodtype_manifest mty -> add_modtype bv mty
end;
bv
- | Psig_open lid ->
+ | Psig_open (lid, _) ->
addmodule bv lid; bv
- | Psig_include mty ->
+ | Psig_include (mty, _) ->
add_modtype bv mty; bv
| Psig_class cdl ->
List.iter (add_class_description bv) cdl; bv
diff --git a/tools/untypeast.ml b/tools/untypeast.ml
index 52250c00fc..252fb59b72 100644
--- a/tools/untypeast.ml
+++ b/tools/untypeast.ml
@@ -322,8 +322,8 @@ and untype_signature_item item =
name, untype_module_type mtype) list)
| Tsig_modtype (_id, name, mdecl) ->
Psig_modtype (name, untype_modtype_declaration mdecl)
- | Tsig_open (_path, lid) -> Psig_open (lid)
- | Tsig_include (mty, _lid) -> Psig_include (untype_module_type mty)
+ | Tsig_open (_path, lid) -> Psig_open (lid, [])
+ | Tsig_include (mty, _lid) -> Psig_include (untype_module_type mty, [])
| Tsig_class list ->
Psig_class (List.map untype_class_description list)
| Tsig_class_type list ->
diff --git a/typing/typemod.ml b/typing/typemod.ml
index 05b3d7297c..cf90350894 100644
--- a/typing/typemod.ml
+++ b/typing/typemod.ml
@@ -315,10 +315,10 @@ and approx_sig env ssg =
let info = approx_modtype_info env sinfo in
let (id, newenv) = Env.enter_modtype name.txt info env in
Sig_modtype(id, info) :: approx_sig newenv srem
- | Psig_open lid ->
+ | Psig_open (lid, _attrs) ->
let (path, mty) = type_open env item.psig_loc lid in
approx_sig mty srem
- | Psig_include smty ->
+ | Psig_include (smty, _attrs) ->
let mty = approx_modtype env smty in
let sg = Subst.signature Subst.identity
(extract_sig env smty.pmty_loc mty) in
@@ -517,11 +517,11 @@ and transl_signature env sg =
mksig (Tsig_modtype (id, name, tinfo)) env loc :: trem,
Sig_modtype(id, info) :: rem,
final_env
- | Psig_open lid ->
+ | Psig_open (lid, _attrs) ->
let (path, newenv) = type_open env item.psig_loc lid in
let (trem, rem, final_env) = transl_sig newenv srem in
mksig (Tsig_open (path,lid)) env loc :: trem, rem, final_env
- | Psig_include smty ->
+ | Psig_include (smty, _attrs) ->
let tmty = transl_modtype env smty in
let mty = tmty.mty_type in
let sg = Subst.signature Subst.identity