Implement re_of_rei

This commit is contained in:
Jeremie Dimino 2017-06-01 17:07:06 +01:00
parent 5e06daa5b2
commit 29e9b37c61
1 changed files with 18 additions and 0 deletions

View File

@ -761,6 +761,23 @@ module Rule = struct
; Echo (strf "\nend = %s\ninclude %s\n" m m)
])
})
let re_of_rei names =
List.map names ~f:(fun (loc, name) ->
let strf fmt = Printf.ksprintf (String_with_vars.of_string ~loc) fmt in
let m = String.capitalize_ascii name in
{ targets = Infer
; deps = []
; action =
Redirect
(Stdout,
strf "%s.ml" name,
Progn
[ Echo (strf "[@@@warning \"-a\"]\nmodule type %s = {\n" m)
; Cat (strf "%s.mli" name)
; Echo (strf "\nend\nmodule rec %s : %s = %s = %s\ninclude %s\n" m m m m m)
])
})
end
module Menhir = struct
@ -944,6 +961,7 @@ module Stanza = struct
let sexps = Foreach.expand pat vals sexps in
List.concat_map sexps ~f:(v1 pkgs))
; cstr "ml_of_mli" (list (located string) @> nil) (fun x -> rules (Rule.ml_of_mli x))
; cstr "re_of_rei" (list (located string) @> nil) (fun x -> rules (Rule.re_of_rei x))
(* Just for validation and error messages *)
; cstr "jbuild_version" (Jbuild_version.t @> nil) (fun _ -> [])
]