Finish attributes on module/recursive modules in structures.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13354 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
d32b19008a
commit
a79811afe9
BIN
boot/ocamlc
BIN
boot/ocamlc
Binary file not shown.
BIN
boot/ocamldep
BIN
boot/ocamldep
Binary file not shown.
BIN
boot/ocamllex
BIN
boot/ocamllex
Binary file not shown.
|
@ -1028,7 +1028,11 @@ value varify_constructors var_names =
|
|||
[ <:module_binding< $x$ and $y$ >> ->
|
||||
module_str_binding x (module_str_binding y acc)
|
||||
| <:module_binding@loc< $s$ : $mt$ = $me$ >> ->
|
||||
[(with_loc s loc, module_type mt, module_expr me) :: acc]
|
||||
[{pmb_name=with_loc s loc;
|
||||
pmb_expr=
|
||||
{pmod_loc=Camlp4_import.Location.none;
|
||||
pmod_desc=Pmod_constraint(module_expr me,module_type mt)};
|
||||
pmb_attributes=[]} :: acc]
|
||||
| _ -> assert False ]
|
||||
and module_expr =
|
||||
fun
|
||||
|
@ -1073,7 +1077,7 @@ value varify_constructors var_names =
|
|||
| StExp loc e -> [mkstr loc (Pstr_eval (expr e)) :: l]
|
||||
| StExt loc n t sl -> [mkstr loc (Pstr_primitive (with_loc n loc) (mkvalue_desc loc t (list_of_meta_list sl))) :: l]
|
||||
| StInc loc me -> [mkstr loc (Pstr_include (module_expr me, [])) :: l]
|
||||
| StMod loc n me -> [mkstr loc (Pstr_module (with_loc n loc) (module_expr me)) :: l]
|
||||
| StMod loc n me -> [mkstr loc (Pstr_module {pmb_name=with_loc n loc;pmb_expr=module_expr me;pmb_attributes=[]}) :: l]
|
||||
| StRecMod loc mb ->
|
||||
[mkstr loc (Pstr_recmodule (module_str_binding mb [])) :: l]
|
||||
| StMty loc n mt -> [mkstr loc (Pstr_modtype (with_loc n loc) (module_type mt)) :: l]
|
||||
|
|
|
@ -15367,8 +15367,11 @@ module Struct =
|
|||
| Ast.MbAnd (_, x, y) ->
|
||||
module_str_binding x (module_str_binding y acc)
|
||||
| Ast.MbColEq (loc, s, mt, me) ->
|
||||
((with_loc s loc), (module_type mt), (module_expr me)) ::
|
||||
acc
|
||||
{pmb_name=with_loc s loc;
|
||||
pmb_expr=
|
||||
{pmod_loc=Camlp4_import.Location.none;
|
||||
pmod_desc=Pmod_constraint(module_expr me,module_type mt)};
|
||||
pmb_attributes=[]} :: acc
|
||||
| _ -> assert false
|
||||
and module_expr =
|
||||
function
|
||||
|
@ -15446,8 +15449,13 @@ module Struct =
|
|||
(mkstr loc (Pstr_include (module_expr me, []))) :: l
|
||||
| StMod (loc, n, me) ->
|
||||
(mkstr loc
|
||||
(Pstr_module ((with_loc n loc), (module_expr me)))) ::
|
||||
l
|
||||
(Pstr_module
|
||||
{pmb_name=with_loc n loc;
|
||||
pmb_expr=module_expr me;
|
||||
pmb_attributes=[]
|
||||
}
|
||||
))
|
||||
:: l
|
||||
| StRecMod (loc, mb) ->
|
||||
(mkstr loc (Pstr_recmodule (module_str_binding mb []))) ::
|
||||
l
|
||||
|
@ -21609,3 +21617,4 @@ module Register :
|
|||
end
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1287,7 +1287,7 @@ module Analyser =
|
|||
in
|
||||
(0, new_env, [ Element_exception new_ex ])
|
||||
|
||||
| Parsetree.Pstr_module (name, module_expr) ->
|
||||
| Parsetree.Pstr_module {Parsetree.pmb_name=name; pmb_expr=module_expr} ->
|
||||
(
|
||||
(* of string * module_expr *)
|
||||
try
|
||||
|
@ -1334,7 +1334,7 @@ module Analyser =
|
|||
dans les contraintes sur les modules *)
|
||||
let new_env =
|
||||
List.fold_left
|
||||
(fun acc_env (name, _, mod_exp) ->
|
||||
(fun acc_env {Parsetree.pmb_name=name;pmb_expr=mod_exp} ->
|
||||
let complete_name = Name.concat current_module_name name.txt in
|
||||
let e = Odoc_env.add_module acc_env complete_name in
|
||||
let tt_mod_exp =
|
||||
|
@ -1362,7 +1362,7 @@ module Analyser =
|
|||
let rec f ?(first=false) last_pos name_mod_exp_list =
|
||||
match name_mod_exp_list with
|
||||
[] -> []
|
||||
| (name, _, mod_exp) :: q ->
|
||||
| {Parsetree.pmb_name=name;pmb_expr=mod_exp} :: q ->
|
||||
let complete_name = Name.concat current_module_name name.txt in
|
||||
let loc_start = mod_exp.Parsetree.pmod_loc.Location.loc_start.Lexing.pos_cnum in
|
||||
let loc_end = mod_exp.Parsetree.pmod_loc.Location.loc_end.Lexing.pos_cnum in
|
||||
|
|
|
@ -440,9 +440,9 @@ let search_structure str ~name ~kind ~prefix =
|
|||
List.fold_left ~init:[] str ~f:
|
||||
begin fun acc item ->
|
||||
match item.pstr_desc with
|
||||
Pstr_module (s, mexp) when s.txt = modu ->
|
||||
loc := mexp.pmod_loc.loc_start.Lexing.pos_cnum;
|
||||
begin match mexp.pmod_desc with
|
||||
Pstr_module x when x.pmb_name.txt = modu ->
|
||||
loc := x.pmb_expr.pmod_loc.loc_start.Lexing.pos_cnum;
|
||||
begin match x.pmb_expr.pmod_desc with
|
||||
Pmod_structure str -> str
|
||||
| _ -> []
|
||||
end
|
||||
|
@ -468,7 +468,7 @@ let search_structure str ~name ~kind ~prefix =
|
|||
end;
|
||||
false
|
||||
| Pstr_exception ped when kind = Pconstructor -> name = ped.ped_name.txt
|
||||
| Pstr_module (s, _) when kind = Pmodule -> name = s.txt
|
||||
| Pstr_module x when kind = Pmodule -> name = x.pmb_name.txt
|
||||
| Pstr_modtype (s, _) when kind = Pmodtype -> name = s.txt
|
||||
| Pstr_class l when kind = Pclass || kind = Ptype || kind = Pcltype ->
|
||||
List.iter l ~f:
|
||||
|
|
|
@ -281,14 +281,14 @@ and add_struct_item bv item =
|
|||
List.iter (add_type bv) ped.ped_args; bv
|
||||
| Pstr_exn_rebind(id, l, _attrs) ->
|
||||
add bv l; bv
|
||||
| Pstr_module(id, modl) ->
|
||||
add_module bv modl; StringSet.add id.txt bv
|
||||
| Pstr_module x ->
|
||||
add_module bv x.pmb_expr; StringSet.add x.pmb_name.txt bv
|
||||
| Pstr_recmodule bindings ->
|
||||
let bv' =
|
||||
List.fold_right StringSet.add
|
||||
(List.map (fun (id,_,_) -> id.txt) bindings) bv in
|
||||
(List.map (fun x -> x.pmb_name.txt) bindings) bv in
|
||||
List.iter
|
||||
(fun (id, mty, modl) -> add_modtype bv' mty; add_module bv' modl)
|
||||
(fun x -> add_module bv' x.pmb_expr)
|
||||
bindings;
|
||||
bv'
|
||||
| Pstr_modtype(id, mty) ->
|
||||
|
|
|
@ -367,7 +367,8 @@ and rewrite_str_item iflag item =
|
|||
Pstr_eval exp -> rewrite_exp iflag exp
|
||||
| Pstr_value(_, exps)
|
||||
-> List.iter (function (_,exp) -> rewrite_exp iflag exp) exps
|
||||
| Pstr_module(name, smod) -> rewrite_mod iflag smod
|
||||
| Pstr_module x -> rewrite_mod iflag x.pmb_expr
|
||||
(* todo: Pstr_recmodule?? *)
|
||||
| Pstr_class classes -> List.iter (rewrite_class_declaration iflag) classes
|
||||
| _ -> ()
|
||||
|
||||
|
|
|
@ -57,11 +57,18 @@ and untype_structure_item item =
|
|||
| Tstr_exn_rebind (_id, name, _p, lid) ->
|
||||
Pstr_exn_rebind (name, lid, [])
|
||||
| Tstr_module (_id, name, mexpr) ->
|
||||
Pstr_module (name, untype_module_expr mexpr)
|
||||
Pstr_module {pmb_name = name; pmb_expr = untype_module_expr mexpr; pmb_attributes = []}
|
||||
| Tstr_recmodule list ->
|
||||
Pstr_recmodule (List.map (fun (_id, name, mtype, mexpr) ->
|
||||
name, untype_module_type mtype,
|
||||
untype_module_expr mexpr) list)
|
||||
Pstr_recmodule
|
||||
(List.map
|
||||
(fun (_id, name, mtype, mexpr) ->
|
||||
{pmb_name = name;
|
||||
pmb_expr = {pmod_loc = Location.none;
|
||||
pmod_desc = Pmod_constraint(
|
||||
untype_module_expr mexpr,
|
||||
untype_module_type mtype)};
|
||||
pmb_attributes = []})
|
||||
list)
|
||||
| Tstr_modtype (_id, name, mtype) ->
|
||||
Pstr_modtype (name, untype_module_type mtype)
|
||||
| Tstr_open (_path, lid) -> Pstr_open (lid, [])
|
||||
|
|
Loading…
Reference in New Issue