Adapt one more example.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14185 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2013-09-26 08:36:31 +00:00
parent 9e09513778
commit 13dd4d972d
1 changed files with 17 additions and 14 deletions

View File

@ -78,20 +78,23 @@ module Main : sig end = struct
let gen_builder tdecl =
with_default_loc tdecl.ptype_loc (fun () -> gen_builder tdecl)
let builder = object(this)
inherit Ast_mapper.mapper
method! structure l =
List.flatten
(List.map
(function
| {pstr_desc = Pstr_type tdecls; _} as i ->
i :: (List.flatten (List.map gen_builder tdecls))
| i -> [this # structure_item i]
)
l
let builder _args =
let open Ast_mapper in
let super = default_mapper in
{super
with
structure =
(fun this l ->
List.flatten
(List.map
(function
| {pstr_desc = Pstr_type tdecls; _} as i ->
i :: (List.flatten (List.map gen_builder tdecls))
| i -> [structure_item this i]
) l
)
)
end
}
let () = Ast_mapper.main builder
let () = Ast_mapper.run_main builder
end