Remove the Ocamllex/Ocamlyacc modules and desugar them instead
This commit is contained in:
parent
3158b0a483
commit
60be8f7734
|
@ -462,7 +462,7 @@ dependencies. See the [[User actions][actions section]] for more details.
|
||||||
(rule
|
(rule
|
||||||
((targets (<name>.ml))
|
((targets (<name>.ml))
|
||||||
(deps (<name>.mll))
|
(deps (<name>.mll))
|
||||||
(action (chdir ${ROOT} (run ocamllex ${<})))))
|
(action (chdir ${ROOT} (run ${bin:ocamllex} -q -o ${<})))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
**** ocamlyacc
|
**** ocamlyacc
|
||||||
|
@ -473,7 +473,7 @@ dependencies. See the [[User actions][actions section]] for more details.
|
||||||
(rule
|
(rule
|
||||||
((targets (<name>.ml <name>.mli))
|
((targets (<name>.ml <name>.mli))
|
||||||
(deps (<name>.mly))
|
(deps (<name>.mly))
|
||||||
(action (chdir ${ROOT} (run ocamlyacc ${<})))))
|
(action (chdir ${ROOT} (run ${bin:ocamlyacc} ${<})))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
**** alias
|
**** alias
|
||||||
|
|
|
@ -1416,28 +1416,6 @@ module Gen(P : Params) = struct
|
||||||
>>> Action_interpret.run action ~dir ~targets:[] in
|
>>> Action_interpret.run action ~dir ~targets:[] in
|
||||||
add_rule (deps >>> dummy)
|
add_rule (deps >>> dummy)
|
||||||
|
|
||||||
(* +-----------------------------------------------------------------+
|
|
||||||
| lex/yacc |
|
|
||||||
+-----------------------------------------------------------------+ *)
|
|
||||||
|
|
||||||
let ocamllex_rules (conf : Ocamllex.t) ~dir =
|
|
||||||
List.iter conf.names ~f:(fun name ->
|
|
||||||
let src = Path.relative dir (name ^ ".mll" ) in
|
|
||||||
let dst = Path.relative dir (name ^ ".ml" ) in
|
|
||||||
add_rule
|
|
||||||
(Build.run ~dir:ctx.build_dir (Dep ctx.ocamllex)
|
|
||||||
[A "-q"; A "-o"; Target dst; Dep src]))
|
|
||||||
|
|
||||||
let ocamlyacc_rules (conf : Ocamlyacc.t) ~dir =
|
|
||||||
List.iter conf.names ~f:(fun name ->
|
|
||||||
let src = Path.relative dir (name ^ ".mly" ) in
|
|
||||||
let dst = Path.relative dir (name ^ ".ml" ) in
|
|
||||||
let dsti = Path.relative dir (name ^ ".mli" ) in
|
|
||||||
add_rule
|
|
||||||
(Build.run ~extra_targets:[dst; dsti] ~dir:ctx.build_dir
|
|
||||||
(Dep ctx.ocamlyacc)
|
|
||||||
[ Dep src ]))
|
|
||||||
|
|
||||||
(* +-----------------------------------------------------------------+
|
(* +-----------------------------------------------------------------+
|
||||||
| Modules listing |
|
| Modules listing |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
@ -1512,8 +1490,6 @@ module Gen(P : Params) = struct
|
||||||
let dir = ctx_dir in
|
let dir = ctx_dir in
|
||||||
match (stanza : Stanza.t) with
|
match (stanza : Stanza.t) with
|
||||||
| Rule rule -> user_rule rule ~dir
|
| Rule rule -> user_rule rule ~dir
|
||||||
| Ocamllex conf -> ocamllex_rules conf ~dir
|
|
||||||
| Ocamlyacc conf -> ocamlyacc_rules conf ~dir
|
|
||||||
| Alias alias -> alias_rules alias ~dir
|
| Alias alias -> alias_rules alias ~dir
|
||||||
| Library _ | Executables _ | Provides _ | Install _ -> ());
|
| Library _ | Executables _ | Provides _ | Install _ -> ());
|
||||||
let files = lazy (
|
let files = lazy (
|
||||||
|
|
|
@ -563,20 +563,39 @@ module Rule = struct
|
||||||
record
|
record
|
||||||
(ignore_fields ["sandbox"] >>= fun () ->
|
(ignore_fields ["sandbox"] >>= fun () ->
|
||||||
common)
|
common)
|
||||||
end
|
|
||||||
|
|
||||||
module Ocamllex = struct
|
let ocamllex_v1 names =
|
||||||
type t = { names : string list }
|
let str s = String_with_vars.of_string s in
|
||||||
|
List.map names ~f:(fun name ->
|
||||||
|
let src = name ^ ".mll" in
|
||||||
|
let dst = name ^ ".ml" in
|
||||||
|
{ targets = [dst]
|
||||||
|
; deps = [File (str src)]
|
||||||
|
; action =
|
||||||
|
Shexp
|
||||||
|
(Chdir
|
||||||
|
(str "${ROOT}",
|
||||||
|
Run (str "${bin:ocamllex}",
|
||||||
|
[str "-q"; str "-o"; str dst; str src])))
|
||||||
|
})
|
||||||
|
|
||||||
let v1 sexp = { names = list string sexp }
|
let ocamllex_vjs = ocamllex_v1
|
||||||
let vjs = v1
|
|
||||||
end
|
|
||||||
|
|
||||||
module Ocamlyacc = struct
|
let ocamlyacc_v1 names =
|
||||||
type t = { names : string list }
|
let str s = String_with_vars.of_string s in
|
||||||
|
List.map names ~f:(fun name ->
|
||||||
|
let src = name ^ ".mll" in
|
||||||
|
{ targets = [name ^ ".ml"; name ^ ".mli"]
|
||||||
|
; deps = [File (str src)]
|
||||||
|
; action =
|
||||||
|
Shexp
|
||||||
|
(Chdir
|
||||||
|
(str "${ROOT}",
|
||||||
|
Run (str "${bin:ocamlyacc}",
|
||||||
|
[str src])))
|
||||||
|
})
|
||||||
|
|
||||||
let v1 sexp = { names = list string sexp }
|
let ocamlyacc_vjs = ocamlyacc_v1
|
||||||
let vjs = v1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Provides = struct
|
module Provides = struct
|
||||||
|
@ -669,49 +688,46 @@ module Stanza = struct
|
||||||
| Library of Library.t
|
| Library of Library.t
|
||||||
| Executables of Executables.t
|
| Executables of Executables.t
|
||||||
| Rule of Rule.t
|
| Rule of Rule.t
|
||||||
| Ocamllex of Ocamllex.t
|
|
||||||
| Ocamlyacc of Ocamlyacc.t
|
|
||||||
| Provides of Provides.t
|
| Provides of Provides.t
|
||||||
| Install of Install_conf.t
|
| Install of Install_conf.t
|
||||||
| Alias of Alias_conf.t
|
| Alias of Alias_conf.t
|
||||||
|
|
||||||
let cstr' name args f =
|
let rules l = List.map l ~f:(fun x -> Rule x)
|
||||||
cstr name args (fun x -> Some (f x))
|
|
||||||
|
|
||||||
let v1 =
|
let v1 =
|
||||||
sum
|
sum
|
||||||
[ cstr' "library" (Library.v1 @> nil) (fun x -> Library x)
|
[ cstr "library" (Library.v1 @> nil) (fun x -> [Library x])
|
||||||
; cstr' "executables" (Executables.v1 @> nil) (fun x -> Executables x)
|
; cstr "executables" (Executables.v1 @> nil) (fun x -> [Executables x])
|
||||||
; cstr' "rule" (Rule.v1 @> nil) (fun x -> Rule x)
|
; cstr "rule" (Rule.v1 @> nil) (fun x -> [Rule x])
|
||||||
; cstr' "ocamllex" (Ocamllex.v1 @> nil) (fun x -> Ocamllex x)
|
; cstr "ocamllex" (list string @> nil) (fun x -> rules (Rule.ocamllex_v1 x))
|
||||||
; cstr' "ocamlyacc" (Ocamlyacc.v1 @> nil) (fun x -> Ocamlyacc x)
|
; cstr "ocamlyacc" (list string @> nil) (fun x -> rules (Rule.ocamlyacc_v1 x))
|
||||||
; cstr' "provides" (Provides.v1 @> nil) (fun x -> Provides x)
|
; cstr "provides" (Provides.v1 @> nil) (fun x -> [Provides x])
|
||||||
; cstr' "install" (Install_conf.v1 @> nil) (fun x -> Install x)
|
; cstr "install" (Install_conf.v1 @> nil) (fun x -> [Install x])
|
||||||
; cstr' "alias" (Alias_conf.v1 @> nil) (fun x -> Alias x)
|
; cstr "alias" (Alias_conf.v1 @> nil) (fun x -> [Alias x])
|
||||||
(* Just for validation and error messages *)
|
(* Just for validation and error messages *)
|
||||||
; cstr "jbuild_version" (Jbuild_version.t @> nil) (fun _ -> None)
|
; cstr "jbuild_version" (Jbuild_version.t @> nil) (fun _ -> [])
|
||||||
]
|
]
|
||||||
|
|
||||||
let vjs =
|
let vjs =
|
||||||
let ign name = cstr name ((fun _ -> ()) @> nil) (fun () -> None) in
|
let ign name = cstr name ((fun _ -> ()) @> nil) (fun () -> []) in
|
||||||
sum
|
sum
|
||||||
[ cstr' "library" (Library.vjs @> nil) (fun x -> Library x)
|
[ cstr "library" (Library.vjs @> nil) (fun x -> [Library x])
|
||||||
; cstr' "executables" (Executables.vjs @> nil) (fun x -> Executables x)
|
; cstr "executables" (Executables.vjs @> nil) (fun x -> [Executables x])
|
||||||
; cstr' "rule" (Rule.vjs @> nil) (fun x -> Rule x)
|
; cstr "rule" (Rule.vjs @> nil) (fun x -> [Rule x])
|
||||||
; cstr' "ocamllex" (Ocamllex.vjs @> nil) (fun x -> Ocamllex x)
|
; cstr "ocamllex" (list string @> nil) (fun x -> rules (Rule.ocamllex_vjs x))
|
||||||
; cstr' "ocamlyacc" (Ocamlyacc.vjs @> nil) (fun x -> Ocamlyacc x)
|
; cstr "ocamlyacc" (list string @> nil) (fun x -> rules (Rule.ocamlyacc_vjs x))
|
||||||
; cstr' "provides" (Provides.vjs @> nil) (fun x -> Provides x)
|
; cstr "provides" (Provides.vjs @> nil) (fun x -> [Provides x])
|
||||||
; cstr' "install" (Install_conf.vjs @> nil) (fun x -> Install x)
|
; cstr "install" (Install_conf.vjs @> nil) (fun x -> [Install x])
|
||||||
; cstr' "alias" (Alias_conf.vjs @> nil) (fun x -> Alias x)
|
; cstr "alias" (Alias_conf.vjs @> nil) (fun x -> [Alias x])
|
||||||
; ign "enforce_style"
|
; ign "enforce_style"
|
||||||
; ign "toplevel_expect_tests"
|
; ign "toplevel_expect_tests"
|
||||||
; ign "unified_tests"
|
; ign "unified_tests"
|
||||||
; ign "embed"
|
; ign "embed"
|
||||||
(* Just for validation and error messages *)
|
(* Just for validation and error messages *)
|
||||||
; cstr "jbuild_version" (Jbuild_version.t @> nil) (fun _ -> None)
|
; cstr "jbuild_version" (Jbuild_version.t @> nil) (fun _ -> [])
|
||||||
]
|
]
|
||||||
|
|
||||||
let select : Jbuild_version.t -> t option Sexp.Of_sexp.t = function
|
let select : Jbuild_version.t -> t list Sexp.Of_sexp.t = function
|
||||||
| V1 -> v1
|
| V1 -> v1
|
||||||
| Vjs -> vjs
|
| Vjs -> vjs
|
||||||
|
|
||||||
|
@ -790,6 +806,6 @@ module Stanzas = struct
|
||||||
| _ :: (_, loc) :: _ ->
|
| _ :: (_, loc) :: _ ->
|
||||||
Loc.fail loc "jbuild_version specified too many times"
|
Loc.fail loc "jbuild_version specified too many times"
|
||||||
in
|
in
|
||||||
List.filter_map sexps ~f:(Stanza.select version)
|
List.concat_map sexps ~f:(Stanza.select version)
|
||||||
|> resolve_packages ~dir ~visible_packages
|
|> resolve_packages ~dir ~visible_packages
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue