From 66cb521749672586fd5b1182b14e3c5d44829616 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 3 Sep 2021 17:44:44 +0200 Subject: Extract representation in dedicated library --- src/lib/dune | 2 +- src/lib/reader.ml | 2 +- src/lib/repr/default.ml | 58 +++++++++++++++++++++++++++++++++++++++++++++++ src/lib/repr/default.mli | 1 + src/lib/repr/dune | 4 ++++ src/lib/sounds/repr.ml | 58 ----------------------------------------------- src/lib/sounds/repr.mli | 1 - src/lib/sounds/sounds.ml | 1 - src/lib/sounds/sounds.mli | 1 - 9 files changed, 65 insertions(+), 63 deletions(-) create mode 100644 src/lib/repr/default.ml create mode 100644 src/lib/repr/default.mli create mode 100644 src/lib/repr/dune delete mode 100644 src/lib/sounds/repr.ml delete mode 100644 src/lib/sounds/repr.mli (limited to 'src') diff --git a/src/lib/dune b/src/lib/dune index 89f3ddf..b290672 100644 --- a/src/lib/dune +++ b/src/lib/dune @@ -2,7 +2,7 @@ (name translator ) - (libraries menhirLib sounds modifiers) + (libraries menhirLib sounds modifiers repr) ) (menhir diff --git a/src/lib/reader.ml b/src/lib/reader.ml index 45ea69e..9a8e840 100644 --- a/src/lib/reader.ml +++ b/src/lib/reader.ml @@ -7,7 +7,7 @@ let sound_to_string = fun t -> let buff = Buffer.create 16 in List.iter t - ~f:(fun f -> Buffer.add_string buff (Sounds.repr (module Sounds.Repr) f)); + ~f:(fun f -> Buffer.add_string buff (Sounds.repr (module Repr.Default) f)); Buffer.contents buff let succeed (res : Sounds.t list) = diff --git a/src/lib/repr/default.ml b/src/lib/repr/default.ml new file mode 100644 index 0000000..72cf95d --- /dev/null +++ b/src/lib/repr/default.ml @@ -0,0 +1,58 @@ +type t = string + +let none = "" + +let a = "a" +and a_nasal = "@" + +and e_opened = "E" +and e_closed = "e" +and schwa = "°" + +and eu = "9" + +and o = "o" +and o_nasal = "§" + +and i = "i" +and i_nasal = "5" +and y = "y" +and y_nasal = "1" + +and u = "u" + +and p = "p" +and b = "b" +and t = "t" +and d = "d" + +and k = "k" +and g = "g" + +and f = "f" +and v = "v" + +and ch = "S" +and j = "Z" + +and s = "s" +and z = "z" + +and m = "m" +and n = "n" + +and l = "L" +and r = "R" + +and semi_voyel_w = "w" +and semi_voyel_y = "j" + +let muted + : t -> t + = fun t -> + Printf.sprintf "(%s)" t + +let diphtongue + : t -> t -> t + = fun t1 t2 -> + Printf.sprintf "[%s%s]" t1 t2 diff --git a/src/lib/repr/default.mli b/src/lib/repr/default.mli new file mode 100644 index 0000000..27a84bb --- /dev/null +++ b/src/lib/repr/default.mli @@ -0,0 +1 @@ +include Sounds.Sig.REPR with type t = String.t diff --git a/src/lib/repr/dune b/src/lib/repr/dune new file mode 100644 index 0000000..c853440 --- /dev/null +++ b/src/lib/repr/dune @@ -0,0 +1,4 @@ +(library + (name repr) + (libraries sounds) + ) diff --git a/src/lib/sounds/repr.ml b/src/lib/sounds/repr.ml deleted file mode 100644 index 72cf95d..0000000 --- a/src/lib/sounds/repr.ml +++ /dev/null @@ -1,58 +0,0 @@ -type t = string - -let none = "" - -let a = "a" -and a_nasal = "@" - -and e_opened = "E" -and e_closed = "e" -and schwa = "°" - -and eu = "9" - -and o = "o" -and o_nasal = "§" - -and i = "i" -and i_nasal = "5" -and y = "y" -and y_nasal = "1" - -and u = "u" - -and p = "p" -and b = "b" -and t = "t" -and d = "d" - -and k = "k" -and g = "g" - -and f = "f" -and v = "v" - -and ch = "S" -and j = "Z" - -and s = "s" -and z = "z" - -and m = "m" -and n = "n" - -and l = "L" -and r = "R" - -and semi_voyel_w = "w" -and semi_voyel_y = "j" - -let muted - : t -> t - = fun t -> - Printf.sprintf "(%s)" t - -let diphtongue - : t -> t -> t - = fun t1 t2 -> - Printf.sprintf "[%s%s]" t1 t2 diff --git a/src/lib/sounds/repr.mli b/src/lib/sounds/repr.mli deleted file mode 100644 index 7e2e035..0000000 --- a/src/lib/sounds/repr.mli +++ /dev/null @@ -1 +0,0 @@ -include Sig.REPR with type t = String.t diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml index e5f5d29..088485a 100644 --- a/src/lib/sounds/sounds.ml +++ b/src/lib/sounds/sounds.ml @@ -1,5 +1,4 @@ module Sig = Sig -module Repr = Repr type kind = | None diff --git a/src/lib/sounds/sounds.mli b/src/lib/sounds/sounds.mli index 8a07db3..8c11488 100644 --- a/src/lib/sounds/sounds.mli +++ b/src/lib/sounds/sounds.mli @@ -1,5 +1,4 @@ module Sig = Sig -module Repr = Repr type t val muted : t -> t -- cgit v1.2.3