From f35d068836f300bc3f48479747849283b90e04ad Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 21 Jun 2018 17:36:32 +0630 Subject: [PATCH] Move Jbuild.syntax to Stanza module Signed-off-by: Rudi Grinberg --- src/inline_tests.ml | 4 ++-- src/jbuild.ml | 21 ++++++++------------- src/jbuild.mli | 5 ----- src/preprocessing.ml | 2 +- src/stanza.ml | 6 ++++++ src/stanza.mli | 5 +++++ 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/inline_tests.ml b/src/inline_tests.ml index b305104c..24670da0 100644 --- a/src/inline_tests.ml +++ b/src/inline_tests.ml @@ -28,7 +28,7 @@ module Backend = struct If we wanted to make the ppx system an extension, then we would create a new one. *) - let syntax = Jbuild.syntax + let syntax = Stanza.syntax open Sexp.Of_sexp @@ -128,7 +128,7 @@ include Sub_system.Register_end_point( let loc t = t.loc let backends t = Option.map t.backend ~f:(fun x -> [x]) - let syntax = Jbuild.syntax + let syntax = Stanza.syntax open Sexp.Of_sexp diff --git a/src/jbuild.ml b/src/jbuild.ml index 713755d9..42ef6583 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -5,12 +5,6 @@ open Sexp.Of_sexp syntax for the various supported version of the specification. *) -let syntax = - Syntax.create ~name:"dune" ~desc:"the dune language" - [ (0, 0) (* Jbuild syntax *) - ; (1, 0) - ] - (* Deprecated *) module Jbuild_version = struct type t = @@ -233,10 +227,11 @@ module Dep_conf = struct ; "package" , (sw >>| fun x -> Package x) ; "universe" , return Universe ; "files_recursively_in", - (Syntax.renamed_in syntax (1, 0) ~to_:"source_tree" >>= fun () -> + (Syntax.renamed_in Stanza.syntax (1, 0) ~to_:"source_tree" + >>= fun () -> sw >>| fun x -> Source_tree x) ; "source_tree", - (Syntax.since syntax (1, 0) >>= fun () -> + (Syntax.since Stanza.syntax (1, 0) >>= fun () -> sw >>| fun x -> Source_tree x) ] in @@ -915,7 +910,7 @@ module Executables = struct let common names public_names ~multi = Buildable.t >>= fun buildable -> field "link_executables" ~default:true - (Syntax.deleted_in syntax (1, 0) >>> bool) + (Syntax.deleted_in Stanza.syntax (1, 0) >>> bool) >>= fun (_ : bool) -> field "link_deps" (list Dep_conf.t) ~default:[] >>= fun link_deps -> field_oslu "link_flags" >>= fun link_flags -> @@ -1359,10 +1354,10 @@ module Stanzas = struct (Documentation.t >>| fun d -> [Documentation d]) ; "jbuild_version", - (Syntax.deleted_in syntax (1, 0) >>= fun () -> + (Syntax.deleted_in Stanza.syntax (1, 0) >>= fun () -> Jbuild_version.t >>| fun _ -> []) ; "env", - (Syntax.since syntax (1, 0) >>= fun () -> + (Syntax.since Stanza.syntax (1, 0) >>= fun () -> loc >>= fun loc -> repeat Env.rule >>| fun rules -> [Env { loc; rules }]) @@ -1380,10 +1375,10 @@ module Stanzas = struct [Menhir.T { x with loc }]) ] in - Syntax.set syntax (0, 0) (sum stanzas) + Syntax.set Stanza.syntax (0, 0) (sum stanzas) let () = - Dune_project.Lang.register syntax stanzas + Dune_project.Lang.register Stanza.syntax stanzas exception Include_loop of Path.t * (Loc.t * Path.t) list diff --git a/src/jbuild.mli b/src/jbuild.mli index 4bceafd4..319d3082 100644 --- a/src/jbuild.mli +++ b/src/jbuild.mli @@ -2,11 +2,6 @@ open Import -(** Syntax identifier for the Dune language. [(0, X)] correspond to - the Jbuild language while versions from [(1, 0)] correspond to the - Dune one. *) -val syntax : Syntax.t - (** Ppx preprocessors *) module Pp : sig type t = private string diff --git a/src/preprocessing.ml b/src/preprocessing.ml index a8a4fffd..e49dd375 100644 --- a/src/preprocessing.ml +++ b/src/preprocessing.ml @@ -38,7 +38,7 @@ module Driver = struct If we wanted to make the ppx system an extension, then we would create a new one. *) - let syntax = Jbuild.syntax + let syntax = Stanza.syntax open Sexp.Of_sexp diff --git a/src/stanza.ml b/src/stanza.ml index 679e4f96..a82b9f9e 100644 --- a/src/stanza.ml +++ b/src/stanza.ml @@ -5,3 +5,9 @@ type t = .. module Parser = struct type nonrec t = string * t list Sexp.Of_sexp.t end + +let syntax = + Syntax.create ~name:"dune" ~desc:"the dune language" + [ (0, 0) (* Jbuild syntax *) + ; (1, 0) + ] diff --git a/src/stanza.mli b/src/stanza.mli index 36a683b9..d7d1800d 100644 --- a/src/stanza.mli +++ b/src/stanza.mli @@ -11,3 +11,8 @@ module Parser : sig of type [t], hence the [t list] here. *) type nonrec t = string * t list Sexp.Of_sexp.t end + +(** Syntax identifier for the Dune language. [(0, X)] correspond to + the Jbuild language while versions from [(1, 0)] correspond to the + Dune one. *) +val syntax : Syntax.t