summaryrefslogtreecommitdiff
path: root/src/lib/repr
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-09-10 20:50:40 +0200
committerSébastien Dailly <sebastien@chimrod.com>2021-09-10 20:50:40 +0200
commit040c74ea186f195b8579960d2a74418c38cd9b76 (patch)
tree2bb882c2dc7c18b39bf27187119534e2bd96d302 /src/lib/repr
parent1ba97f613c25926f4007fda9e38131fbb8961173 (diff)
Added js code
Diffstat (limited to 'src/lib/repr')
-rw-r--r--src/lib/repr/default.ml2
-rw-r--r--src/lib/repr/tengwar.ml83
2 files changed, 34 insertions, 51 deletions
diff --git a/src/lib/repr/default.ml b/src/lib/repr/default.ml
index 22a023f..9daa4fb 100644
--- a/src/lib/repr/default.ml
+++ b/src/lib/repr/default.ml
@@ -4,6 +4,8 @@ type t = string
let none = ""
+let space s = s
+
let a = "a"
and a_nasal = "@"
diff --git a/src/lib/repr/tengwar.ml b/src/lib/repr/tengwar.ml
index 4fc224b..d291a8b 100644
--- a/src/lib/repr/tengwar.ml
+++ b/src/lib/repr/tengwar.ml
@@ -35,6 +35,8 @@ and t =
let none = Nothing
+let space s = Repr s
+
let a = Voyel
{ opened = true
; position = `Above
@@ -106,53 +108,6 @@ and u = Voyel
| Pos3 -> "J"
| Pos4 -> "M" }
-and a_nasal = Nasal
- (fun f -> match f with
- | Consonant c -> begin match c.primary, c.position, c.category with
- | true, Pos1, _ -> "{#"
- | true, _, _ -> "[E"
- | false, _, I -> "5#"
- | false, _, II -> "t#"
- | false, _, III -> "g#"
- end
- | _ -> "5#"
-
- )
-
-and o_nasal = Nasal
- (fun f -> match f with
- | Consonant c -> begin match c.primary, c.position, c.category with
- | true, Pos1, _ -> "{^"
- | true, _, _ -> "[Y"
- | false, _, I -> "5^"
- | false, _, II -> "t^"
- | false, _, III -> "g^"
- end
- | _ -> "5^"
- )
-
-and i_nasal = Nasal
- (fun f -> match f with
- | Consonant c -> begin match c.primary, c.position, c.category with
- | true, Pos1, _ -> "{$"
- | true, _, _ -> "[T"
- | false, _, I -> "5$"
- | false, _, II -> "t$"
- | false, _, III -> "g$"
- end
- | _ -> "5$")
-
-and y_nasal = Nasal
- (fun f -> match f with
- | Consonant c -> begin match c.primary, c.position, c.category with
- | true, Pos1, _ -> "{Ø"
- | true, _, _ -> "[Ù"
- | false, _, I -> "5Ø"
- | false, _, II -> "tØ"
- | false, _, III -> "gØ"
- end
- | _ -> "5Ø")
-
and p = Consonant
{ position = Pos2
; muted = Some "y"
@@ -293,6 +248,32 @@ and semi_voyel_u = Consonant
; primary = false
; repr = "]" }
+let nasal v =
+ let Voyel letter = v [@@warning "-8"]in
+ Nasal
+ ( fun f ->
+ let Consonant c = n [@@warning "-8"] in
+ let default = c.repr ^ letter.app c.position in
+
+ match f with
+ | Consonant c -> begin match c.category with
+ | I -> default
+ | II ->
+ let Consonant c = m [@@warning "-8"] in
+ c.repr ^ letter.app c.position
+ | III ->
+ let Consonant c = gn [@@warning "-8"] in
+ c.repr ^ letter.app c.position
+ end
+ | _ -> default
+ )
+
+let a_nasal = nasal a
+and o_nasal = nasal o
+and i_nasal = nasal i
+and y_nasal = nasal y
+
+
let diphtongue
: t -> t -> t
= fun t1 t2 -> match t1, t2 with
@@ -328,7 +309,7 @@ let muted
and portant =
{ position = Pos4
; muted = None
- ; category = III
+ ; category = I
; primary = false
; repr = "`" }
@@ -349,7 +330,7 @@ let fold
| Some Voyel ( {position = `Below; _ } as v) ->
Buffer.add_string buff (v.app Pos1)
| Some Nasal n ->
- Buffer.add_string buff ("`" ^ (n (Consonant portant)))
+ Buffer.add_string buff (n (Consonant portant))
| Some Repr r ->
Buffer.add_string buff r
| Some Consonant c ->
@@ -366,13 +347,13 @@ let fold
Buffer.add_string buff ((v.app Pos1)^ c.repr);
_fold None tl
| Some Nasal n, Consonant c ->
- Buffer.add_string buff (c.repr ^ (n hd));
+ Buffer.add_string buff ((n hd) ^ c.repr);
_fold None tl
| Some Voyel v, _ ->
Buffer.add_string buff ("`" ^ (v.app portant.position));
_fold (Some hd) tl
| Some Nasal n, _ ->
- Buffer.add_string buff ("`" ^ (n (Consonant portant)));
+ Buffer.add_string buff (n (Consonant portant));
_fold (Some hd) tl
| Some Repr r, _ ->
Buffer.add_string buff r;