diff --git a/src/action.ml b/src/action.ml index ad8ac979..514bb1b0 100644 --- a/src/action.ml +++ b/src/action.ml @@ -1,5 +1,5 @@ open Import -open Sexp.Of_sexp +open Dsexp.Of_sexp let ignore_loc k ~loc:_ = k @@ -27,7 +27,7 @@ struct let t = let path = Path.t and string = String.t in - Sexp.Of_sexp.fix (fun t -> + Dsexp.Of_sexp.fix (fun t -> sum [ "run", (let%map prog = Program.t @@ -268,7 +268,7 @@ module Prog = struct type t = (Path.t, Not_found.t) result - let t : t Sexp.Of_sexp.t = Sexp.Of_sexp.map Path.t ~f:Result.ok + let t : t Dsexp.Of_sexp.t = Dsexp.Of_sexp.map Path.t ~f:Result.ok let sexp_of_t = function | Ok s -> Path.sexp_of_t s @@ -283,7 +283,7 @@ module rec Ast : Ast = Ast module String_with_sexp = struct type t = string - let t = Sexp.Of_sexp.string + let t = Dsexp.Of_sexp.string let sexp_of_t = Sexp.To_sexp.string end diff --git a/src/action.mli b/src/action.mli index 5815d07f..eaaf5da2 100644 --- a/src/action.mli +++ b/src/action.mli @@ -31,7 +31,7 @@ include Action_intf.Helpers with type string := string with type t := t -val t : t Sexp.Of_sexp.t +val t : t Dsexp.Of_sexp.t module For_shell : sig include Action_intf.Ast @@ -39,7 +39,7 @@ module For_shell : sig with type path := string with type string := string - val sexp_of_t : t Sexp.To_sexp.t + val sexp_of_t : t Dsexp.To_sexp.t end (** Convert the action to a format suitable for printing *) diff --git a/src/binary_kind.ml b/src/binary_kind.ml index c209eda9..0324aa2e 100644 --- a/src/binary_kind.ml +++ b/src/binary_kind.ml @@ -6,7 +6,7 @@ type t = | Shared_object let t = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in enum [ "exe" , Exe ; "object" , Object diff --git a/src/binary_kind.mli b/src/binary_kind.mli index b389c80d..cb53e0f5 100644 --- a/src/binary_kind.mli +++ b/src/binary_kind.mli @@ -7,7 +7,7 @@ type t = | Object | Shared_object -val t : t Sexp.Of_sexp.t +val t : t Dsexp.Of_sexp.t val sexp_of_t : t Sexp.To_sexp.t diff --git a/src/build_system.ml b/src/build_system.ml index 26ac4f58..974fa2e0 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -1275,7 +1275,7 @@ let update_universe t = Utils.Cached_digest.remove universe_file; let n = if Path.exists universe_file then - Sexp.Of_sexp.(parse int) Univ_map.empty + Dsexp.Of_sexp.(parse int) Univ_map.empty (Io.Dsexp.load ~mode:Single universe_file) + 1 else 0 diff --git a/src/config.mli b/src/config.mli index 7e03b92e..a131a3b9 100644 --- a/src/config.mli +++ b/src/config.mli @@ -32,7 +32,7 @@ module Display : sig | Verbose (** Display all commands fully *) | Quiet (** Only display errors *) - val t : t Sexp.Of_sexp.t + val t : t Dsexp.Of_sexp.t val all : (string * t) list end @@ -58,7 +58,7 @@ include S with type 'a field = 'a module Partial : S with type 'a field := 'a option -val t : t Sexp.Of_sexp.t +val t : t Dsexp.Of_sexp.t val merge : t -> Partial.t -> t diff --git a/src/context.ml b/src/context.ml index 6d55ae46..e0d87f79 100644 --- a/src/context.ml +++ b/src/context.ml @@ -452,7 +452,7 @@ let create_for_opam ?root ~env ~env_nodes ~targets ~profile ~switch ~name >>= fun s -> let vars = Usexp.parse_string ~fname:"" ~mode:Single s - |> Sexp.Of_sexp.(parse (list (pair string string)) Univ_map.empty) + |> Dsexp.Of_sexp.(parse (list (pair string string)) Univ_map.empty) |> Env.Map.of_list_multi |> Env.Map.mapi ~f:(fun var values -> match List.rev values with diff --git a/src/dune_env.mli b/src/dune_env.mli index afe45c3a..5afbdfb6 100644 --- a/src/dune_env.mli +++ b/src/dune_env.mli @@ -18,7 +18,7 @@ module Stanza : sig ; rules : (pattern * config) list } - val t : t Sexp.Of_sexp.t + val t : t Dsexp.Of_sexp.t end type stanza += diff --git a/src/dune_project.ml b/src/dune_project.ml index a5ac25d8..3d6d18bd 100644 --- a/src/dune_project.ml +++ b/src/dune_project.ml @@ -1,5 +1,5 @@ open Import -open Sexp.Of_sexp +open Dsexp.Of_sexp module Kind = struct type t = @@ -7,7 +7,7 @@ module Kind = struct | Jbuilder let sexp_of_t t = - Sexp.atom_or_quoted_string + Dsexp.atom_or_quoted_string (match t with | Dune -> "dune" | Jbuilder -> "jbuilder") @@ -22,8 +22,8 @@ module Name : sig val to_string_hum : t -> string - val named_of_sexp : t Sexp.Of_sexp.t - val sexp_of_t : t Sexp.To_sexp.t + val named_of_sexp : t Dsexp.Of_sexp.t + val sexp_of_t : t Dsexp.To_sexp.t val encode : t -> string val decode : string -> t @@ -59,9 +59,9 @@ end = struct | Anonymous p -> sprintf "" (Path.to_string_maybe_quoted p) let sexp_of_t = function - | Named s -> Sexp.To_sexp.string s + | Named s -> Dsexp.To_sexp.string s | Anonymous p -> - List [ Sexp.unsafe_atom_of_string "anonymous" + List [ Dsexp.unsafe_atom_of_string "anonymous" ; Path.sexp_of_t p ] @@ -85,11 +85,11 @@ end = struct None let named_of_sexp = - Sexp.Of_sexp.plain_string (fun ~loc s -> + Dsexp.Of_sexp.plain_string (fun ~loc s -> if validate s then Named s else - Sexp.Of_sexp.of_sexp_errorf loc "invalid project name") + Dsexp.Of_sexp.of_sexp_errorf loc "invalid project name") let encode = function | Named s -> s @@ -132,7 +132,7 @@ module Project_file = struct } let sexp_of_t { file; exists } = - Sexp.To_sexp.( + Dsexp.To_sexp.( record [ "file", Path.sexp_of_t file ; "exists", bool exists @@ -145,7 +145,7 @@ type t = ; root : Path.Local.t ; version : string option ; packages : Package.t Package.Name.Map.t - ; stanza_parser : Stanza.t list Sexp.Of_sexp.t + ; stanza_parser : Stanza.t list Dsexp.Of_sexp.t ; project_file : Project_file.t } @@ -202,14 +202,14 @@ let append_to_project_file t str = module Extension = struct type t = { syntax : Syntax.t - ; stanzas : Stanza.Parser.t list Sexp.Of_sexp.t + ; stanzas : Stanza.Parser.t list Dsexp.Of_sexp.t } type instance = { extension : t ; version : Syntax.Version.t ; loc : Loc.t - ; parse_args : Stanza.Parser.t list Sexp.Of_sexp.t -> Stanza.Parser.t list + ; parse_args : Stanza.Parser.t list Dsexp.Of_sexp.t -> Stanza.Parser.t list } let extensions = Hashtbl.create 32 @@ -242,7 +242,7 @@ module Extension = struct if f name then let version = Syntax.greatest_supported_version ext.syntax in let parse_args p = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in let dune_project_edited = ref false in parse (enter p) Univ_map.empty (List (Loc.of_pos __POS__, [])) |> List.map ~f:(fun (name, p) -> @@ -251,10 +251,10 @@ module Extension = struct if not !dune_project_edited then begin dune_project_edited := true; Project_file_edit.append project_file - (Sexp.to_string ~syntax:Dune - (List [ Sexp.atom "using" - ; Sexp.atom name - ; Sexp.atom (Syntax.Version.to_string version) + (Dsexp.to_string ~syntax:Dune + (List [ Dsexp.atom "using" + ; Dsexp.atom name + ; Dsexp.atom (Syntax.Version.to_string version) ])) end; p)) @@ -278,17 +278,17 @@ let key = Univ_map.Key.create ~name:"dune-project" (fun { name; root; version; project_file; kind ; stanza_parser = _; packages = _ } -> - Sexp.To_sexp.record + Dsexp.To_sexp.record [ "name", Name.sexp_of_t name ; "root", Path.Local.sexp_of_t root - ; "version", Sexp.To_sexp.(option string) version + ; "version", Dsexp.To_sexp.(option string) version ; "project_file", Project_file.sexp_of_t project_file ; "kind", Kind.sexp_of_t kind ]) -let set t = Sexp.Of_sexp.set key t +let set t = Dsexp.Of_sexp.set key t let get_exn () = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in get key >>| function | Some t -> t | None -> @@ -310,7 +310,7 @@ let anonymous = lazy ( ; root = get_local_path Path.root ; version = None ; stanza_parser = - Sexp.Of_sexp.(set_many parsing_context (sum lang.data)) + Dsexp.Of_sexp.(set_many parsing_context (sum lang.data)) ; project_file = { file = Path.relative Path.root filename; exists = false } }) @@ -375,14 +375,14 @@ let parse ~dir ~lang ~packages ~file = (lang.data :: List.map extensions ~f:(fun (ext : Extension.instance) -> ext.parse_args - (Sexp.Of_sexp.set_many parsing_context ext.extension.stanzas))) + (Dsexp.Of_sexp.set_many parsing_context ext.extension.stanzas))) in { kind = Dune ; name ; root = get_local_path dir ; version ; packages - ; stanza_parser = Sexp.Of_sexp.(set_many parsing_context (sum stanzas)) + ; stanza_parser = Dsexp.Of_sexp.(set_many parsing_context (sum stanzas)) ; project_file }) @@ -399,7 +399,7 @@ let make_jbuilder_project ~dir packages = ; version = None ; packages ; stanza_parser = - Sexp.Of_sexp.(set_many parsing_context (sum lang.data)) + Dsexp.Of_sexp.(set_many parsing_context (sum lang.data)) ; project_file = { file = Path.relative dir filename; exists = false } } diff --git a/src/dune_project.mli b/src/dune_project.mli index 2b073f2f..9380772d 100644 --- a/src/dune_project.mli +++ b/src/dune_project.mli @@ -22,7 +22,7 @@ module Name : sig (** Convert to a string that is suitable for human readable messages *) val to_string_hum : t -> string - val sexp_of_t : t -> Sexp.t + val sexp_of_t : t -> Dsexp.t (** Convert to/from an encoded string that is suitable to use in filenames *) val encode : t -> string @@ -41,7 +41,7 @@ val packages : t -> Package.t Package.Name.Map.t val version : t -> string option val name : t -> Name.t val root : t -> Path.Local.t -val stanza_parser : t -> Stanza.t list Sexp.Of_sexp.t +val stanza_parser : t -> Stanza.t list Dsexp.Of_sexp.t module Lang : sig (** [register id stanzas_parser] register a new language. Users will @@ -62,7 +62,7 @@ module Extension : sig in their [dune-project] file. [parser] is used to describe what [] might be. *) - val register : Syntax.t -> Stanza.Parser.t list Sexp.Of_sexp.t -> unit + val register : Syntax.t -> Stanza.Parser.t list Dsexp.Of_sexp.t -> unit end (** Load a project description from the following directory. [files] @@ -86,5 +86,5 @@ val ensure_project_file_exists : t -> unit val append_to_project_file : t -> string -> unit (** Set the project we are currently parsing dune files for *) -val set : t -> ('a, 'k) Sexp.Of_sexp.parser -> ('a, 'k) Sexp.Of_sexp.parser -val get_exn : unit -> (t, 'k) Sexp.Of_sexp.parser +val set : t -> ('a, 'k) Dsexp.Of_sexp.parser -> ('a, 'k) Dsexp.Of_sexp.parser +val get_exn : unit -> (t, 'k) Dsexp.Of_sexp.parser diff --git a/src/file_tree.ml b/src/file_tree.ml index 6cdab804..4824fbec 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -10,14 +10,14 @@ module Dune_file = struct | _ -> assert false let lexer = function - | Dune -> Sexp.Lexer.token - | Jbuild -> Sexp.Lexer.jbuild_token + | Dune -> Dsexp.Lexer.token + | Jbuild -> Dsexp.Lexer.jbuild_token end module Plain = struct type t = { path : Path.t - ; mutable sexps : Sexp.Ast.t list + ; mutable sexps : Dsexp.Ast.t list } end @@ -39,7 +39,7 @@ module Dune_file = struct let extract_ignored_subdirs = let stanza = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in let sub_dir = plain_string (fun ~loc dn -> if Filename.dirname dn <> Filename.current_dir_name || @@ -58,9 +58,9 @@ module Dune_file = struct fun sexps -> let ignored_subdirs, sexps = List.partition_map sexps ~f:(fun sexp -> - match (sexp : Sexp.Ast.t) with + match (sexp : Dsexp.Ast.t) with | List (_, (Atom (_, A "ignored_subdirs") :: _)) -> - Left (Sexp.Of_sexp.parse stanza Univ_map.empty sexp) + Left (Dsexp.Of_sexp.parse stanza Univ_map.empty sexp) | _ -> Right sexp) in let ignored_subdirs = diff --git a/src/inline_tests.ml b/src/inline_tests.ml index 55d07341..dd94b04e 100644 --- a/src/inline_tests.ml +++ b/src/inline_tests.ml @@ -80,7 +80,7 @@ module Backend = struct } let to_sexp t = - let open Sexp.To_sexp in + let open Dsexp.To_sexp in let lib x = string (Lib.name x) in let f x = string (Lib.name x.lib) in ((1, 0), diff --git a/src/install.ml b/src/install.ml index 1609b704..44b17622 100644 --- a/src/install.ml +++ b/src/install.ml @@ -59,7 +59,7 @@ module Section = struct | _ -> None let t = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in enum [ "lib" , Lib ; "lib_root" , Lib_root diff --git a/src/install.mli b/src/install.mli index 2ce0920a..5c653a05 100644 --- a/src/install.mli +++ b/src/install.mli @@ -19,7 +19,7 @@ module Section : sig | Man | Misc - val t : t Sexp.Of_sexp.t + val t : t Dsexp.Of_sexp.t (** [true] iff the executable bit should be set for files installed in this location. *) diff --git a/src/installed_dune_file.ml b/src/installed_dune_file.ml index 43fd6e83..1bf8f8ae 100644 --- a/src/installed_dune_file.ml +++ b/src/installed_dune_file.ml @@ -3,7 +3,7 @@ open Import let parse_sub_systems ~parsing_context sexps = List.filter_map sexps ~f:(fun sexp -> let name, ver, data = - Sexp.Of_sexp.(parse (triple string (located Syntax.Version.t) raw) + Dsexp.Of_sexp.(parse (triple string (located Syntax.Version.t) raw) parsing_context) sexp in match Sub_system_name.get name with @@ -12,7 +12,7 @@ let parse_sub_systems ~parsing_context sexps = correspond to plugins that are not in use in the current workspace. *) None - | Some name -> Some (name, (Sexp.Ast.loc sexp, ver, data))) + | Some name -> Some (name, (Dsexp.Ast.loc sexp, ver, data))) |> Sub_system_name.Map.of_list |> (function | Ok x -> x @@ -32,10 +32,10 @@ let parse_sub_systems ~parsing_context sexps = | (_, _) -> Univ_map.add parsing_context (Syntax.key M.syntax) (snd version) in - M.T (Sexp.Of_sexp.parse M.parse parsing_context data)) + M.T (Dsexp.Of_sexp.parse M.parse parsing_context data)) let of_sexp = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in let version = plain_string (fun ~loc -> function | "1" -> (0, 0) @@ -64,40 +64,40 @@ let load fname = which point we can decide what lexer to use for the reset of the file. *) let state = ref 0 in - let lexer = ref Sexp.Lexer.token in + let lexer = ref Dsexp.Lexer.token in let lexer lb = - let token : Sexp.Lexer.Token.t = !lexer lb in + let token : Dsexp.Lexer.Token.t = !lexer lb in (match !state, token with | 0, Lparen -> state := 1 | 1, Atom (A "dune") -> state := 2 - | 2, Atom (A "1") -> state := 3; lexer := Sexp.Lexer.jbuild_token - | 2, Atom (A "2") -> state := 3; lexer := Sexp.Lexer.token + | 2, Atom (A "1") -> state := 3; lexer := Dsexp.Lexer.jbuild_token + | 2, Atom (A "2") -> state := 3; lexer := Dsexp.Lexer.token | 2, Atom (A version) -> - Loc.fail (Sexp.Loc.of_lexbuf lexbuf) "Unsupported version %S" version + Loc.fail (Dsexp.Loc.of_lexbuf lexbuf) "Unsupported version %S" version | 3, _ -> () | _ -> - Loc.fail (Sexp.Loc.of_lexbuf lexbuf) + Loc.fail (Dsexp.Loc.of_lexbuf lexbuf) "This .dune file looks invalid, it should \ contain a S-expression of the form (dune x.y ..)" ); token in - Sexp.Of_sexp.parse of_sexp Univ_map.empty - (Sexp.Parser.parse ~lexer ~mode:Single lexbuf)) + Dsexp.Of_sexp.parse of_sexp Univ_map.empty + (Dsexp.Parser.parse ~lexer ~mode:Single lexbuf)) let gen ~(dune_version : Syntax.Version.t) confs = let sexps = Sub_system_name.Map.to_list confs |> List.map ~f:(fun (name, (ver, conf)) -> let (module M) = Dune_file.Sub_system_info.get name in - Sexp.List [ Sexp.atom (Sub_system_name.to_string name) + Dsexp.List [ Dsexp.atom (Sub_system_name.to_string name) ; Syntax.Version.sexp_of_t ver ; conf ]) in - Sexp.List - [ Sexp.unsafe_atom_of_string "dune" - ; Sexp.unsafe_atom_of_string + Dsexp.List + [ Dsexp.unsafe_atom_of_string "dune" + ; Dsexp.unsafe_atom_of_string (match dune_version with | (0, 0) -> "1" | (x, _) when x >= 1 -> "2" diff --git a/src/mode.ml b/src/mode.ml index fef3d670..1c5094f1 100644 --- a/src/mode.ml +++ b/src/mode.ml @@ -5,7 +5,7 @@ type t = Byte | Native let all = [Byte; Native] let t = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in enum [ "byte" , Byte ; "native" , Native @@ -73,7 +73,7 @@ module Dict = struct ; native = List.mem Native ~set:l } - let t = Sexp.Of_sexp.(map (list t) ~f:of_list) + let t = Dsexp.Of_sexp.(map (list t) ~f:of_list) let is_empty t = not (t.byte || t.native) diff --git a/src/mode.mli b/src/mode.mli index d87542ca..1a8cefb1 100644 --- a/src/mode.mli +++ b/src/mode.mli @@ -2,7 +2,7 @@ open! Import type t = Byte | Native -val t : t Sexp.Of_sexp.t +val t : t Dsexp.Of_sexp.t val all : t list @@ -35,7 +35,7 @@ module Dict : sig module Set : sig type nonrec t = bool t - val t : t Sexp.Of_sexp.t + val t : t Dsexp.Of_sexp.t val all : t val is_empty : t -> bool val to_list : t -> mode list diff --git a/src/ordered_set_lang.ml b/src/ordered_set_lang.ml index 604a53a5..df28d964 100644 --- a/src/ordered_set_lang.ml +++ b/src/ordered_set_lang.ml @@ -19,7 +19,7 @@ end type 'ast generic = { ast : 'ast ; loc : Loc.t option - ; context : Univ_map.t (* Parsing context for Sexp.Of_sexp.parse *) + ; context : Univ_map.t (* Parsing context for Dsexp.Of_sexp.parse *) } type ast_expanded = (Loc.t * string, Ast.expanded) Ast.t @@ -235,14 +235,14 @@ let field ?(default=standard) ?check name = let t = match check with | None -> t - | Some x -> Sexp.Of_sexp.(>>>) x t + | Some x -> Dsexp.Of_sexp.(>>>) x t in - Sexp.Of_sexp.field name t ~default + Dsexp.Of_sexp.field name t ~default module Unexpanded = struct type ast = (String_with_vars.t, Ast.unexpanded) Ast.t type t = ast generic - let t : t Sexp.Of_sexp.t = + let t : t Dsexp.Of_sexp.t = let open Stanza.Of_sexp in let%map context = get_all and (loc, ast) = @@ -275,9 +275,9 @@ module Unexpanded = struct let t = match check with | None -> t - | Some x -> Sexp.Of_sexp.(>>>) x t + | Some x -> Dsexp.Of_sexp.(>>>) x t in - Sexp.Of_sexp.field name t ~default + Dsexp.Of_sexp.field name t ~default let files t ~f = let rec loop acc (ast : ast) = diff --git a/src/ordered_set_lang.mli b/src/ordered_set_lang.mli index bb561ca6..865177d8 100644 --- a/src/ordered_set_lang.mli +++ b/src/ordered_set_lang.mli @@ -4,7 +4,7 @@ open Import type t -val t : t Sexp.Of_sexp.t +val t : t Dsexp.Of_sexp.t (** Return the location of the set. [loc standard] returns [None] *) val loc : t -> Loc.t option @@ -68,9 +68,9 @@ val is_standard : t -> bool val field : ?default:t - -> ?check:unit Sexp.Of_sexp.t + -> ?check:unit Dsexp.Of_sexp.t -> string - -> t Sexp.Of_sexp.fields_parser + -> t Dsexp.Of_sexp.fields_parser module Unexpanded : sig type expanded = t @@ -81,9 +81,9 @@ module Unexpanded : sig val field : ?default:t - -> ?check:unit Sexp.Of_sexp.t + -> ?check:unit Dsexp.Of_sexp.t -> string - -> t Sexp.Of_sexp.fields_parser + -> t Dsexp.Of_sexp.fields_parser val has_special_forms : t -> bool @@ -91,7 +91,7 @@ module Unexpanded : sig val files : t -> f:(String_with_vars.t -> Path.t) - -> Sexp.syntax * Path.Set.t + -> Dsexp.syntax * Path.Set.t (** Expand [t] using with the given file contents. [file_contents] is a map from filenames to their parsed contents. Every [(:include fn)] in [t] is replaced by @@ -99,7 +99,7 @@ module Unexpanded : sig val expand : t -> dir:Path.t - -> files_contents:Sexp.Ast.t Path.Map.t + -> files_contents:Dsexp.Ast.t Path.Map.t -> f:(String_with_vars.t -> Value.t list) -> expanded diff --git a/src/package.ml b/src/package.ml index af79aae1..6695554c 100644 --- a/src/package.ml +++ b/src/package.ml @@ -15,7 +15,7 @@ module Name = struct let pp fmt t = Format.pp_print_string fmt (to_string t) - let t = Sexp.Of_sexp.(map string ~f:of_string) + let t = Dsexp.Of_sexp.(map string ~f:of_string) module Infix = Comparable.Operators(T) end diff --git a/src/package.mli b/src/package.mli index 35ee0768..1b1709c6 100644 --- a/src/package.mli +++ b/src/package.mli @@ -13,7 +13,7 @@ module Name : sig include Interned.S with type t := t - val t : t Sexp.Of_sexp.t + val t : t Dsexp.Of_sexp.t module Infix : Comparable.OPS with type t = t end diff --git a/src/preprocessing.ml b/src/preprocessing.ml index 81f2c7b0..9fa7d146 100644 --- a/src/preprocessing.ml +++ b/src/preprocessing.ml @@ -194,7 +194,7 @@ module Jbuild_driver = struct in Sexp.parse_string ~mode:Single ~fname:"" info ~lexer:Sexp.Lexer.jbuild_token - |> Sexp.Of_sexp.parse Driver.Info.parse parsing_context + |> Dsexp.Of_sexp.parse Driver.Info.parse parsing_context in (Pp.of_string name, { info diff --git a/src/promotion.ml b/src/promotion.ml index 00c2255c..99a60f12 100644 --- a/src/promotion.ml +++ b/src/promotion.ml @@ -7,23 +7,23 @@ module File = struct } (* XXX these sexp converters will be useful for the dump command *) - let _t = - let open Sexp.Of_sexp in - peek_exn >>= function - | List (_, [_; Atom (_, A "as"); _]) -> - enter - (let%map src = Path.t - and () = junk - and dst = Path.t - in - { src; dst }) - | sexp -> - Sexp.Of_sexp.of_sexp_errorf (Sexp.Ast.loc sexp) - "( as ) expected" + (* let _t = + * let open Dsexp.Of_sexp in + * peek_exn >>= function + * | List (_, [_; Atom (_, A "as"); _]) -> + * enter + * (let % map src = Path.t + * and () = junk + * and dst = Path.t + * in + * { src; dst }) + * | sexp -> + * Dsexp.Of_sexp.of_sexp_errorf (Sexp.Ast.loc sexp) + * "( as ) expected" *) - let _sexp_of_t { src; dst } = - Sexp.List [Path.sexp_of_t src; Sexp.unsafe_atom_of_string "as"; - Path.sexp_of_t dst] + (* let _sexp_of_t { src; dst } = + * Sexp.List [Path.sexp_of_t src; Sexp.unsafe_atom_of_string "as"; + * Path.sexp_of_t dst] *) let db : t list ref = ref [] diff --git a/src/report_error.ml b/src/report_error.ml index 7832aa8d..fde677d8 100644 --- a/src/report_error.ml +++ b/src/report_error.ml @@ -44,7 +44,7 @@ let report_with_backtrace exn = in let pp ppf = Format.fprintf ppf "@{Error@}: %s\n" msg in { p with loc = Some loc; pp } - | Sexp.Of_sexp.Of_sexp (loc, msg, hint') -> + | Dsexp.Of_sexp.Of_sexp (loc, msg, hint') -> let loc = { loc with start = { loc.start with pos_fname = !map_fname loc.start.pos_fname } @@ -53,7 +53,7 @@ let report_with_backtrace exn = let pp ppf = Format.fprintf ppf "@{Error@}: %s%s\n" msg (match hint' with | None -> "" - | Some { Sexp.Of_sexp. on; candidates } -> + | Some { Dsexp.Of_sexp. on; candidates } -> hint on candidates) in { p with loc = Some loc; pp } diff --git a/src/stanza.ml b/src/stanza.ml index c59d2d6c..45fd931c 100644 --- a/src/stanza.ml +++ b/src/stanza.ml @@ -3,7 +3,7 @@ open Stdune type t = .. module Parser = struct - type nonrec t = string * t list Sexp.Of_sexp.t + type nonrec t = string * t list Dsexp.Of_sexp.t end let syntax = @@ -13,7 +13,7 @@ let syntax = ] module File_kind = struct - type t = Sexp.syntax = Jbuild | Dune + type t = Dsexp.syntax = Jbuild | Dune let of_syntax = function | (0, _) -> Jbuild @@ -21,11 +21,11 @@ module File_kind = struct end let file_kind () = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in Syntax.get_exn syntax >>| File_kind.of_syntax module Of_sexp = struct - include Sexp.Of_sexp + include Dsexp.Of_sexp exception Parens_no_longer_necessary of Loc.t @@ -88,7 +88,7 @@ module Of_sexp = struct match Univ_map.find parsing_context (Syntax.key syntax) with | Some (0, _) -> let last = Option.value_exn (List.last entries) in - Loc.warn (Sexp.Ast.loc last) + Loc.warn (Dsexp.Ast.loc last) "Field %S is present several times, previous occurrences are ignored." name | _ -> diff --git a/src/stanza.mli b/src/stanza.mli index f8b7249c..fefdb1fe 100644 --- a/src/stanza.mli +++ b/src/stanza.mli @@ -9,7 +9,7 @@ module Parser : sig Each stanza in a configuration file might produce several values of type [t], hence the [t list] here. *) - type nonrec t = string * t list Sexp.Of_sexp.t + type nonrec t = string * t list Dsexp.Of_sexp.t end (** Syntax identifier for the Dune language. [(0, X)] correspond to @@ -18,21 +18,21 @@ end val syntax : Syntax.t module File_kind : sig - type t = Sexp.syntax = Jbuild | Dune + type t = Dsexp.syntax = Jbuild | Dune val of_syntax : Syntax.Version.t -> t end (** Whether we are parsing a [jbuild] or [dune] file. *) -val file_kind : unit -> (File_kind.t, _) Sexp.Of_sexp.parser +val file_kind : unit -> (File_kind.t, _) Dsexp.Of_sexp.parser -(** Overlay for [Sexp.Of_sexp] where lists and records don't require +(** Overlay for [Dsexp.Of_sexp] where lists and records don't require an extra level of parentheses in Dune files. Additionally, [field_xxx] functions only warn about duplicated fields in jbuild files, for backward compatibility. *) module Of_sexp : sig - include module type of struct include Sexp.Of_sexp end + include module type of struct include Dsexp.Of_sexp end val record : 'a fields_parser -> 'a t val list : 'a t -> 'a list t diff --git a/src/stdune/path.ml b/src/stdune/path.ml index 3683a9b1..cf66df35 100644 --- a/src/stdune/path.ml +++ b/src/stdune/path.ml @@ -34,10 +34,10 @@ let explode_path = module External : sig type t + include Dsexp.Sexpable with type t := t + val compare : t -> t -> Ordering.t val compare_val : t -> t -> Ordering.t - val t : t Sexp.Of_sexp.t - val sexp_of_t : t Sexp.To_sexp.t val to_string : t -> string val of_string : string -> t val relative : t -> string -> t @@ -72,9 +72,9 @@ end = struct make t let sexp_of_t t = Sexp.To_sexp.string (to_string t) - let t = Sexp.Of_sexp.plain_string (fun ~loc t -> + let t = Dsexp.Of_sexp.plain_string (fun ~loc t -> if Filename.is_relative t then - Sexp.Of_sexp.of_sexp_errorf loc "Absolute path expected" + Dsexp.Of_sexp.of_sexp_errorf loc "Absolute path expected" else of_string t) @@ -130,8 +130,7 @@ end module Local : sig type t - val t : t Sexp.Of_sexp.t - val sexp_of_t : t Sexp.To_sexp.t + include Dsexp.Sexpable with type t := t val root : t val is_root : t -> bool val compare : t -> t -> Ordering.t @@ -292,7 +291,7 @@ end = struct relative root s ?error_loc let t = - Sexp.Of_sexp.plain_string (fun ~loc:error_loc s -> + Dsexp.Of_sexp.plain_string (fun ~loc:error_loc s -> of_string s ~error_loc) let rec mkdir_p t = @@ -608,7 +607,7 @@ let of_string ?error_loc s = make_local_path (Local.of_string s ?error_loc) let t = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in if_list ~then_: (sum diff --git a/src/stdune/path.mli b/src/stdune/path.mli index 4e2c1c0a..1196551c 100644 --- a/src/stdune/path.mli +++ b/src/stdune/path.mli @@ -26,8 +26,7 @@ end type t -val t : t Sexp.Of_sexp.t -val sexp_of_t : t Sexp.To_sexp.t +include Dsexp.Sexpable with type t := t val compare : t -> t -> Ordering.t (** a directory is smaller than its descendants *) diff --git a/src/stdune/sexp.mli b/src/stdune/sexp.mli new file mode 100644 index 00000000..e9401001 --- /dev/null +++ b/src/stdune/sexp.mli @@ -0,0 +1,10 @@ +include module type of struct include Usexp end with module Loc := Usexp.Loc + +module To_sexp : sig + type sexp = t + include Sexp_intf.Combinators with type 'a t = 'a -> t + + val record : (string * sexp) list -> sexp + + val unknown : _ t +end with type sexp := t diff --git a/src/string_with_vars.ml b/src/string_with_vars.ml index f41d580f..652f14a1 100644 --- a/src/string_with_vars.ml +++ b/src/string_with_vars.ml @@ -95,7 +95,7 @@ end = struct end let t = - let open Sexp.Of_sexp in + let open Dsexp.Of_sexp in let jbuild = raw >>| function | Template _ as t -> @@ -104,14 +104,14 @@ let t = ] | Atom(loc, A s) -> Jbuild.parse s ~loc ~quoted:false | Quoted_string (loc, s) -> Jbuild.parse s ~loc ~quoted:true - | List (loc, _) -> Sexp.Of_sexp.of_sexp_error loc "Atom expected" + | List (loc, _) -> Dsexp.Of_sexp.of_sexp_error loc "Atom expected" in let dune = raw >>| function | Template t -> t | Atom(loc, A s) -> literal ~quoted:false ~loc s | Quoted_string (loc, s) -> literal ~quoted:true ~loc s - | List (loc, _) -> Sexp.Of_sexp.of_sexp_error loc "Unexpected list" + | List (loc, _) -> Dsexp.Of_sexp.of_sexp_error loc "Unexpected list" in let template_parser = Stanza.Of_sexp.switch_file_kind ~jbuild ~dune in let%map syntax_version = Syntax.get_exn Stanza.syntax @@ -203,7 +203,7 @@ module Var = struct let to_string = string_of_var - let sexp_of_t t = Sexp.atom (to_string t) + let sexp_of_t t = Dsexp.atom (to_string t) let with_name t ~name = { t with name } diff --git a/src/string_with_vars.mli b/src/string_with_vars.mli index 4a3736bd..fdd23e47 100644 --- a/src/string_with_vars.mli +++ b/src/string_with_vars.mli @@ -8,7 +8,7 @@ open Import type t (** A sequence of text and variables. *) -val t : t Sexp.Of_sexp.t +val t : t Dsexp.Of_sexp.t (** [t ast] takes an [ast] sexp and returns a string-with-vars. This function distinguishes between unquoted variables — such as ${@} — and quoted variables — such as "${@}". *) diff --git a/src/syntax.ml b/src/syntax.ml index aaa25212..343c979a 100644 --- a/src/syntax.ml +++ b/src/syntax.ml @@ -18,8 +18,8 @@ module Version = struct let sexp_of_t t = Sexp.unsafe_atom_of_string (to_string t) - let t : t Sexp.Of_sexp.t = - let open Sexp.Of_sexp in + let t : t Dsexp.Of_sexp.t = + let open Dsexp.Of_sexp in raw >>| function | Atom (loc, A s) -> begin try @@ -123,7 +123,7 @@ let greatest_supported_version t = let key t = t.key -open Sexp.Of_sexp +open Dsexp.Of_sexp let set t ver parser = set t.key ver parser diff --git a/src/versioned_file.mli b/src/versioned_file.mli index 6d8833c6..2b7cceec 100644 --- a/src/versioned_file.mli +++ b/src/versioned_file.mli @@ -30,14 +30,14 @@ module type S = sig (** [load fn ~f] loads a versioned file. It parses the first line, looks up the language, checks that the version is supported and parses the rest of the file with [f]. *) - val load : Path.t -> f:(Lang.Instance.t -> 'a Sexp.Of_sexp.t) -> 'a + val load : Path.t -> f:(Lang.Instance.t -> 'a Dsexp.Of_sexp.t) -> 'a (** Parse the contents of a versioned file after the first line has been read. *) val parse_contents : Lexing.lexbuf -> Dune_lexer.first_line - -> f:(Lang.Instance.t -> 'a Sexp.Of_sexp.t) + -> f:(Lang.Instance.t -> 'a Dsexp.Of_sexp.t) -> 'a end diff --git a/src/workspace.ml b/src/workspace.ml index 8ccc0a9a..bea16325 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -122,7 +122,7 @@ module Context = struct (* jbuild-workspace files *) (peek_exn >>= function | List (_, List _ :: _) -> - Sexp.Of_sexp.record (Opam.t ~profile ~x) >>| fun x -> Opam x + Dsexp.Of_sexp.record (Opam.t ~profile ~x) >>| fun x -> Opam x | _ -> t ~profile ~x) ~dune:(t ~profile ~x) diff --git a/test/unit-tests/dune_file.mlt b/test/unit-tests/dune_file.mlt index ecf75c77..4bd28a6f 100644 --- a/test/unit-tests/dune_file.mlt +++ b/test/unit-tests/dune_file.mlt @@ -9,7 +9,7 @@ let sexp_pp = Sexp.pp Dune;; (* Dune_file.Executables.Link_mode.t *) let test s = - Sexp.Of_sexp.parse Dune_file.Executables.Link_mode.t Univ_map.empty + Dsexp.Of_sexp.parse Dune_file.Executables.Link_mode.t Univ_map.empty (Sexp.parse_string ~fname:"" ~mode:Sexp.Parser.Mode.Single s) [%%expect{| val sexp_pp : Format.formatter -> Usexp.t -> unit = diff --git a/test/unit-tests/sexp.mlt b/test/unit-tests/sexp.mlt index 7776cec6..196612cc 100644 --- a/test/unit-tests/sexp.mlt +++ b/test/unit-tests/sexp.mlt @@ -1,6 +1,6 @@ (* -*- tuareg -*- *) open Stdune;; -open Sexp.Of_sexp;; +open Dsexp.Of_sexp;; let print_loc ppf (_ : Sexp.Loc.t) = Format.pp_print_string ppf "";; #install_printer print_loc;;