(* See [1] for the theory behind the analysis [1] https://fr.m.wiktionary.org/wiki/Annexe:Prononciation/fran%C3%A7ais#Structure_syllabique *) %{ module P = Process %} %start main %% occlusiv: | P { Sounds.p } | B { Sounds.b } | T { Sounds.t } | D { Sounds.d } | K { Sounds.k } | G { Sounds.g } fricativ: | S { Sounds.s } | SZ { Sounds.sz } | Z { Sounds.z } | F { Sounds.f } | V { Sounds.v } | X { Sounds.ch } | J { Sounds.j } obstruent: | occlusiv { $1 } | fricativ { $1 } liquid: | L { Sounds.l } | L L { Sounds.l } | R { Sounds.r } nasal: | N { Sounds.n } | M { Sounds.m } consonant: | occlusiv { $1 } | fricativ { $1 } | liquid { $1 } | nasal { $1 } semi_voyel: | Y { Sounds.semi_voyel_y } | W { Sounds.semi_voyel_w } opening_consonant: | occlusiv { $1, None } | fricativ { $1, None } | nasal { $1, None } | liquid { $1, None } | obstruent liquid { $1, Some $2 } | occlusiv fricativ { $1, Some $2 } | consonant semi_voyel{ $1, Some $2 } | semi_voyel { $1, None } (* Each voyel as two associated sounds, depending there is a followng sound or not *) voyels: | A { Sounds.a , Sounds.a } | A I { Sounds.voyel_ai , Sounds.voyel_ai } | E I { Sounds.e `Opened , Sounds.e `Opened } | I { Sounds.i , Sounds.i } | E { Sounds.e `Opened , Sounds.schwa () } | E_ACUTE E? { Sounds.e `Closed , Sounds.e `Closed } | E_AGRAVE { Sounds.e `Opened , Sounds.e `Opened } | E U { Sounds.eu , Sounds.eu } | O { Sounds.o , Sounds.o } | U { Sounds.voyel_y , Sounds.voyel_y } | OU { Sounds.voyel_u , Sounds.voyel_u } | W A { Sounds.diphtongue Sounds.semi_voyel_w Sounds.a, Sounds.diphtongue Sounds.semi_voyel_w Sounds.a} | W I { Sounds.diphtongue Sounds.semi_voyel_w Sounds.i, Sounds.diphtongue Sounds.semi_voyel_w Sounds.i} | I E { Sounds.diphtongue Sounds.i (Sounds.e `Opened), Sounds.diphtongue Sounds.i (Sounds.e `Opened)} ending_consonant: | B { Some (Sounds.b ) } | T { None } | K { Some (Sounds.k)} | liquid { Some $1 } | nasal { Some $1 } consonant_group: | f = fricativ o = opening_consonant { { ending = None ; opening = f::(fst o)::[] ; following = snd o } } | o = opening_consonant { { ending = None ; opening = [ fst o ] ; following = snd o } } | e = ending_consonant Sep? o = opening_consonant { { ending = Some e ; opening = [ fst o ] ; following = snd o } } | e = ending_consonant Sep? f = fricativ o = opening_consonant { { ending = Some e ; opening = f::[ fst o ] ; following = snd o } } syllable: | c = consonant_group? v = voyels Sep? { (v, c) } syllables: | { [] } | ss = syllables s = syllable { s::ss } word: | Sep? syllables consonant_group? EOL { P.rebuild $3 $2 } main: | word { $1 }