diff --git a/src/stdune/sexp.ml b/src/stdune/sexp.ml index 694452e0..e945cd85 100644 --- a/src/stdune/sexp.ml +++ b/src/stdune/sexp.ml @@ -296,13 +296,13 @@ module Of_sexp = struct let string = plain_string (fun ~loc:_ x -> x) let int = basic "Integer" (fun s -> - match int_of_string (s Atom.Dune) with + match int_of_string s with | x -> Ok x | exception _ -> Result.Error ()) let float = basic "Float" (fun s -> - match float_of_string (s Atom.Dune) with + match float_of_string s with | x -> Ok x | exception _ -> Result.Error ()) diff --git a/src/usexp/atom.ml b/src/usexp/atom.ml index 0935d0b8..80c24213 100644 --- a/src/usexp/atom.ml +++ b/src/usexp/atom.ml @@ -29,8 +29,9 @@ let is_valid_jbuild str = not (loop (len - 1)) let of_string s = A s +let to_string (A s) = s -let to_string (A t) syntax = +let print (A t) syntax = match syntax with | Jbuild -> if is_valid_jbuild t then diff --git a/src/usexp/atom.mli b/src/usexp/atom.mli index 2036a159..3922f43c 100644 --- a/src/usexp/atom.mli +++ b/src/usexp/atom.mli @@ -5,8 +5,9 @@ type syntax = Jbuild | Dune val is_valid_dune : string -> bool val of_string : string -> t +val to_string : t -> string -val to_string : t -> syntax -> string +val print : t -> syntax -> string val of_int : int -> t val of_float : float -> t diff --git a/src/usexp/usexp.ml b/src/usexp/usexp.ml index ce9fca58..e7d4a1e1 100644 --- a/src/usexp/usexp.ml +++ b/src/usexp/usexp.ml @@ -90,13 +90,13 @@ let quoted s = Bytes.unsafe_to_string s' let rec to_string = function - | Atom a -> Atom.to_string a Atom.Dune + | Atom a -> Atom.print a Atom.Dune | Quoted_string s -> quoted s | List l -> Printf.sprintf "(%s)" (List.map l ~f:to_string |> String.concat ~sep:" ") let rec pp ppf = function | Atom s -> - Format.pp_print_string ppf (Atom.to_string s Atom.Dune) + Format.pp_print_string ppf (Atom.print s Atom.Dune) | Quoted_string s -> Format.pp_print_string ppf (quoted s) | List [] -> @@ -137,7 +137,7 @@ let pp_print_quoted_string ppf s = Format.pp_print_string ppf (quoted s) let rec pp_split_strings ppf = function - | Atom s -> Format.pp_print_string ppf (Atom.to_string s Atom.Dune) + | Atom s -> Format.pp_print_string ppf (Atom.print s Atom.Dune) | Quoted_string s -> pp_print_quoted_string ppf s | List [] -> Format.pp_print_string ppf "()" diff --git a/src/usexp/usexp.mli b/src/usexp/usexp.mli index 398ab39a..12b05e76 100644 --- a/src/usexp/usexp.mli +++ b/src/usexp/usexp.mli @@ -12,8 +12,7 @@ module Atom : sig val is_valid_dune : string -> bool val of_string : string -> t - - val to_string : t -> syntax -> string + val to_string : t -> string val of_int : int -> t val of_float : float -> t