diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/modifiers/nasal.ml | 4 | ||||
| -rw-r--r-- | src/lib/parser.mly | 6 | ||||
| -rw-r--r-- | src/lib/prononciation.mly | 115 | ||||
| -rw-r--r-- | src/lib/reader.ml | 1 | ||||
| -rw-r--r-- | src/lib/sounds/sounds.ml | 180 | ||||
| -rw-r--r-- | src/lib/tokens.mly | 2 | 
6 files changed, 200 insertions, 108 deletions
| diff --git a/src/lib/modifiers/nasal.ml b/src/lib/modifiers/nasal.ml index fbaa35d..8fdc60c 100644 --- a/src/lib/modifiers/nasal.ml +++ b/src/lib/modifiers/nasal.ml @@ -1,3 +1,5 @@ +(* Remove the ending consonant, and transform the voyel into +   the nasal form  *)  let transform    : (module Sounds.T with type t = 'a) ->  'a Sig.consonants option -> 'a Sig.t -> 'a Sig.t    = fun (type el) m c init -> @@ -28,8 +30,6 @@ let process      match ending, is_voyel, opening with      | Some ending, _, _ when T.is_nasal ending ->        transform m c init -    (* Remove the ending consonant, and transform the voyel into -       the nasal form  *)      | None, false, Some (opening::tl) when T.is_nasal opening ->        (* If there is no voyel here, transform the opening consonant as an           ending consonant for the next syllabus *) diff --git a/src/lib/parser.mly b/src/lib/parser.mly index 68809fc..6bef7bf 100644 --- a/src/lib/parser.mly +++ b/src/lib/parser.mly @@ -82,12 +82,12 @@ voyels:    | E               { T.e  `Opened , T.schwa () }    | E_ACUTE E?      { T.e  `Closed , T.e  `Closed }    | E_AGRAVE        { T.e  `Opened , T.e  `Opened } -  | E U             { T.eu `Opened , T.eu `Opened } -  | O               { T.o  `Opened , T.o  `Opened } +  | E U             { T.eu         , T.eu         } +  | O               { T.o          , T.o          }    | U               { T.voyel_y     , T.voyel_y   }    | OU              { T.voyel_u     , T.voyel_u   }    | W A             { T.diphtongue T.semi_voyel_w T.a, T.diphtongue T.semi_voyel_w T.a} -  | W I             { T.diphtongue T.semi_voyel_w T.i, T.diphtongue T.semi_voyel_w T.a} +  | W I             { T.diphtongue T.semi_voyel_w T.i, T.diphtongue T.semi_voyel_w T.i}    | I E             { T.diphtongue T.i (T.e `Opened), T.diphtongue T.i (T.e `Opened)}  nasal_voyels: diff --git a/src/lib/prononciation.mly b/src/lib/prononciation.mly index 6fe0d5f..09124a6 100644 --- a/src/lib/prononciation.mly +++ b/src/lib/prononciation.mly @@ -27,60 +27,65 @@ voyel:  letters: -  |                 { [] } -  | letters voyel  { $2 :: $1 } -  | letters Space   { Space :: $1 } -  | letters Sep     { Sep :: $1 } - -  | letters B       { B :: $1 } -  | letters C       { K :: $1 } -  | letters C H     { X :: $1 } -  | letters C I     { I :: S :: $1 } -  | letters C E     { E :: S :: $1 } -  | letters C U I   { I :: K :: $1 } -  | letters C U E   { E :: K :: $1 } -  | letters D       { D :: $1 } -  | letters D D     { D :: $1 } -  | letters F       { F :: $1 } -  | letters G       { G :: $1 } -  | letters G I     { I :: J :: $1 } -  | letters G E     { E :: J :: $1 } -  | letters G U I   { I :: G :: $1 } -  | letters G U E   { E :: G :: $1 } -  | letters H       { Sep :: $1 } - -  | letters J       { J :: $1 } -  | letters K       { K :: $1 } -  | letters E L L   { L :: E_AGRAVE :: $1 } -  | letters E L     { L :: E :: $1 } -  | letters I L L   { Y :: I :: $1 } -  | letters I L     { L :: I :: $1 } -  | letters L       { L :: $1 } -  | letters M       { M :: $1 } -  | letters M M     { M :: $1 } -  | letters N       { N :: $1 } -  | letters N N     { N :: $1 } - -  | letters O I N   { N :: I :: W :: $1 } -  | letters O I     { A :: W :: $1 } - -  | letters P       { P :: $1 } -  | letters P H     { F :: $1 } - -  | letters Q U     { K :: $1 } - -  | letters R       { R :: $1 } -  | letters S S     { S :: $1 } -  | letters S H     { X :: $1 } -  | letters S       { SZ :: $1 } -  | letters T       { T :: $1 } - -  | letters V       { V :: $1 } -  | letters W       { W :: $1 } -  | letters X       { S :: K :: $1 } -  | letters Y       { Y :: $1 } - -  | letters Z       { Z :: $1 } +  | voyel  { $1 :: [] } +  | Space   { Space :: [] } +  | Sep     { Sep :: [] } + +  | B       { B :: [] } +  | C       { K :: [] } +  | C H     { X :: [] } +  | C I     { S :: I :: [] } +  | C E     { S :: E :: [] } +  | C U     { K :: U :: [] } +  | C U I   { K :: I :: [] } +  | C U E   { K :: E :: [] } +  | D       { D :: [] } +  | D D     { D :: [] } +  | F       { F :: [] } +  | G       { G :: [] } +  | G I     { J :: I :: [] } +  | G E     { J :: E :: [] } +  | G U     { G :: U :: [] } +  | G U I   { G :: I :: [] } +  | G U E   { G :: E :: [] } +  | H       { Sep :: [] } + +  | J       { J :: [] } +  | K       { K :: [] } +  | E L     { E :: L :: [] } +  | E L L   { E_AGRAVE :: L :: [] } +  | I L     { I :: L :: [] } +  | I L L   { I :: Y :: [] } +  | L       { L :: [] } +  | M       { M :: [] } +  | M M     { M :: [] } +  | N       { N :: [] } +  | N N     { N :: [] } + +  | O I     { W :: A :: [] } +  | O I N   { W :: I :: N :: [] } + +  | P       { P :: [] } +  | P H     { F :: [] } + +  | Q       { K :: [] } +  | Q U     { K :: [] } + +  | R       { R :: [] } +  | S       { SZ :: [] } +  | S S     { S :: [] } +  | S H     { X :: [] } +  | T       { T :: [] } + +  | V       { V :: [] } +  | W       { W :: [] } +  | X       { K :: S :: [] } +  | Y       { Y :: [] } + +  | Z       { Z :: [] } + +ending:  +  | EOL %prec Low            { EOL::[] }  main:  -  | letters EOL     { EOL::$1 } +  | append(flatten(letters*), ending)     { $1 } diff --git a/src/lib/reader.ml b/src/lib/reader.ml index 20dc9cc..f705b90 100644 --- a/src/lib/reader.ml +++ b/src/lib/reader.ml @@ -59,7 +59,6 @@ let process (line : string) =    let lexbuf = Lexing.from_string line in    let content =      Prononciation.main Lexer.letter lexbuf -    |> List.rev      |> build_processor in    try      loop content (Parser.Incremental.main lexbuf.lex_curr_p) diff --git a/src/lib/sounds/sounds.ml b/src/lib/sounds/sounds.ml index 6c3cad9..85db338 100644 --- a/src/lib/sounds/sounds.ml +++ b/src/lib/sounds/sounds.ml @@ -5,12 +5,26 @@ module type T = sig    val a : t    val e : [`Closed | `Opened] -> t -  val eu : [`Closed | `Opened] -> t +  val eu : t -  val o : [`Closed | `Opened] -> t +  val o : t    val schwa : unit -> t + +  (** This is an empty sound. + +      It can be used to replace any element in a syllabus *) +  val none: t + +  (** This is the voyel i like in "ici" +      When nazalized, the voyel become [in] like in "ainsi" *)    val i : t + +  (** This is the sound ou like in "ouvrier" +      When nazalized, the voyel does not change *)    val voyel_u : t + +  (** This is the sound u like in "unis" +      When nazalized, the voyel becom [un] like in "brun" *)    val voyel_y : t    (** Create a diphtongue from a semi-voyel and a voyel *) @@ -18,8 +32,6 @@ module type T = sig    val nasal: t -> t option -  val none: t -    val p: t    val b: t    val t: t @@ -29,9 +41,10 @@ module type T = sig    val f: t    val v: t    val s: t +  val z: t    val sz: t    val ch: t -  val z: t +  (* val j: t *)    val n: t    val m: t @@ -54,7 +67,7 @@ module T = struct    type code =      | None -    | SZ +    | SZ (* This is a possible Z if followed by a voyel *)      | Voyel_A      | Voyel_E      | Voyel_I @@ -63,6 +76,20 @@ module T = struct      | Voyel_Y (* U like in Unique *)      | SemiVoyel_W      | SemiVoyel_Y +    | Consonant_P +    | Consonant_B +    | Consonant_T +    | Consonant_D +    | Consonant_K +    | Consonant_G +    | Consonant_F +    | Consonant_V +    | Consonant_S +    | Consonant_Z +    | Consonant_M +    | Consonant_N +    | Consonant_L +    | Consonant_R      | Diphtonge of t * t    and t = @@ -139,88 +166,135 @@ module S = struct    let diphtongue v1 v2 =      { voyel with -      repr = (v1.repr) ^ (v2.repr) -    ; code = Diphtonge (v1, v2) +      code = Diphtonge (v1, v2) +    ; repr = "[" ^ (v1.repr) ^ (v2.repr) ^ "]"      }    let code t = t.code    let a = -    { voyel with repr = Repr.a ; code = Voyel_A } +    { voyel with +      code = Voyel_A +    ; repr = Repr.a +    }    let e = function      | `Closed -> { voyel with repr = "e" ; code = Voyel_E }      | `Opened -> { voyel with repr = "E" ; code = Voyel_E } -  let eu = function -    | `Closed -> { voyel with repr = "2" } -    | `Opened -> { voyel with repr = "9" } +  let eu = +    { voyel with repr = "9" }    let schwa () = -    { voyel with repr = "°" } +    { voyel with +      code = Voyel_E +    ; repr = "°" } -  let o _ = -    { voyel with repr = Repr.o ; code = Voyel_O } +  let o = +    { voyel with +      repr = Repr.o +    ; code = Voyel_O }    let i = -    { voyel with repr = Repr.i ; code = Voyel_I } +    { voyel with +      repr = Repr.i +    ; code = Voyel_I }    let voyel_y = -    { voyel with repr = Repr.y ; code = Voyel_Y } +    { voyel with +      repr = Repr.y +    ; code = Voyel_Y }    let voyel_u = -    { voyel with repr = Repr.u ; code = Voyel_U } +    { voyel with +      repr = Repr.u +    ; code = Voyel_U }    let p = -    { none with repr = Repr.p ; mutable_ = false } +    { none with +      code = Consonant_P +    ; repr = Repr.p +    ; mutable_ = false }    let b = -    { none with repr = Repr.b ; mutable_ = false } +    { none with +      code = Consonant_B +    ; repr = Repr.b +    ; mutable_ = false +    }    let t = -    { none with repr = Repr.t } +    { none with +      code = Consonant_T +    ; repr = Repr.t +    }    let d = -    { none with repr = Repr.d } +    { none with +      code = Consonant_D +    ; repr = Repr.d }    let k = -    { none with repr = Repr.k ; mutable_ = false } +    { none with +      code = Consonant_K +    ; repr = Repr.k +    ; mutable_ = false }    let g = -    { none with repr = Repr.g } +    { none with +      code = Consonant_G +    ; repr = Repr.g }    let f = -    { none with repr = Repr.f } +    { none with +      code = Consonant_F +    ; repr = Repr.f }    let v = -    { none with repr = Repr.v } +    { none with +      code = Consonant_V +    ; repr = Repr.v }    let s = -    { none with repr = Repr.s } - -  let sz = -    { s with code = SZ } +    { none with +      code = Consonant_S +    ; repr = Repr.s }    let ch =      { none with        repr = Repr.ch      ; mutable_ = false } +  let sz = +    { s with code = SZ } +    let z = -    { none with repr = Repr.z } +    { none with +      code = Consonant_Z +    ; repr = Repr.z }    let n = -    { none with repr = Repr.n ; nasal = true } +    { none with +      code = Consonant_N +    ; repr = Repr.n +    ; nasal = true }    let m = -    { none with repr = Repr.m ; nasal = true } +    { none with +      code = Consonant_M +    ; repr = Repr.m +    ; nasal = true }    let l = -    { none with repr = Repr.l } +    { none with +      code = Consonant_L +    ; repr = Repr.l }    let r = -    { none with repr = Repr.r } +    { none with +      code = Consonant_R +    ; repr = Repr.r }    let semi_voyel_w =      { none with @@ -233,7 +307,9 @@ module S = struct      ; code = SemiVoyel_Y}    let nasal t = +      match t.code with +    | Voyel_E -> Some { t with repr = Repr.a_nasal ; nasal = true }      | Voyel_A -> Some { t with repr = Repr.a_nasal ; nasal = true }      | Voyel_O -> Some { t with repr = Repr.o_nasal ; nasal = true }      | Voyel_I -> Some { t with repr = Repr.i_nasal ; nasal = true } @@ -246,17 +322,10 @@ module S = struct            Some (              diphtongue                semi_voyel_w -              { t with repr = Repr.i_nasal ; nasal = true } ) -        | (SemiVoyel_W, Voyel_A) -> -          (* The only case we could have the nasalisation of such diphtongue, is -             the case O I, N -> wich is transformed into O, I N *) -          Some ( -            diphtongue -              semi_voyel_w -              { t with repr = Repr.i_nasal ; nasal = true } ) +              { i with repr = Repr.i_nasal ; nasal = true } )          | (Voyel_I, Voyel_E) ->            (* The only case we could have the nasalisation of such diphtongue, is -             the case O I, N -> wich is transformed into O, I N *) +             the case I E, N -> wich is transformed into I, E N *)            Some (              diphtongue                i @@ -276,8 +345,9 @@ module S = struct      : t -> Repr.t      = fun letter ->        match letter.code, letter.nasal with +        | None, _ -> "" -      | SZ, _ -> "" +        | Voyel_A, false -> Repr.a        | Voyel_A, true  -> Repr.a_nasal        | Voyel_E, _ -> "" @@ -288,10 +358,28 @@ module S = struct        | Voyel_U, _  -> Repr.u        | Voyel_Y, false -> Repr.y        | Voyel_Y, true -> Repr.y_nasal +        | SemiVoyel_W, _ -> Repr.semi_voyel_w        | SemiVoyel_Y, _ -> Repr.semi_voyel_y + +      | Consonant_P, _ -> Repr.p +      | Consonant_B, _ -> Repr.b +      | Consonant_T, _ -> Repr.t +      | Consonant_D, _ -> Repr.d +      | Consonant_K, _ -> Repr.k +      | Consonant_G, _ -> Repr.g +      | Consonant_F, _ -> Repr.f +      | Consonant_V, _ -> Repr.v +      | SZ, _ +      | Consonant_S, _ -> Repr.s +      | Consonant_Z, _ -> Repr.z + +      | Consonant_M, _ -> Repr.m +      | Consonant_N, _ -> Repr.n +      | Consonant_L, _ -> Repr.l +      | Consonant_R, _ -> Repr.r        | Diphtonge (l1, l2), _ -> -        (repr l1) ^ (repr l2) +        "["  ^ (repr l1) ^ (repr l2) ^ "]"  end  include S diff --git a/src/lib/tokens.mly b/src/lib/tokens.mly index d70781a..0eb442e 100644 --- a/src/lib/tokens.mly +++ b/src/lib/tokens.mly @@ -34,7 +34,7 @@  %token EOL  %nonassoc Low - +%left R  %right High  %% | 
