summaryrefslogtreecommitdiff
path: root/src/lib/parser.mly
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-08-23 14:37:53 +0200
committerSébastien Dailly <sebastien@chimrod.com>2021-08-23 14:37:53 +0200
commit546afdcf2148087f3a90b69c23ea756550f64433 (patch)
treeac56c71393aacf0fade729e98eeecb1e87a88534 /src/lib/parser.mly
Initial commit
Diffstat (limited to 'src/lib/parser.mly')
-rw-r--r--src/lib/parser.mly118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/lib/parser.mly b/src/lib/parser.mly
new file mode 100644
index 0000000..acb8e25
--- /dev/null
+++ b/src/lib/parser.mly
@@ -0,0 +1,118 @@
+(*
+
+See [1] for the theory behind the analysis
+
+
+[1] https://fr.m.wiktionary.org/wiki/Annexe:Prononciation/fran%C3%A7ais#Structure_syllabique
+
+
+ *)
+%parameter<T:Sounds.T>
+
+
+
+%{
+
+ module P = Process.M(T)
+
+%}
+%start<T.t List.t> main
+
+%%
+
+occlusiv:
+ | P { T.p }
+ | B { T.b }
+
+ | T { T.t }
+ | D { T.none }
+
+ | C { T.k }
+ | K { T.k }
+ | G { T.none }
+
+fricativ:
+ | S { T.s () }
+ | SS { T.s () }
+
+ | F { T.f }
+
+ | C H { T.ch () }
+
+obstruent:
+ | occlusiv { $1 }
+ | fricativ { $1 }
+
+liquid:
+ | L { T.l () }
+ | R { T.r () }
+
+nasal:
+ | N { T.n () }
+
+opening_consonant:
+ | occlusiv { $1, None }
+ | fricativ { $1, None }
+ | nasal { $1, None }
+ | liquid { $1, None }
+ | obstruent liquid { $1, Some $2 }
+ | occlusiv fricativ { $1, Some $2 }
+
+(* Each voyel as two associated sounds, depending there is a followng sound or
+ not *)
+voyels:
+ | A { T.a `Opened , T.a `Opened }
+ | A I { T.e `Opened, T.e `Opened }
+ | I { T.i `Opened , T.i `Opened }
+ | E { T.schwa () , T.schwa () }
+ | E_ACUTE E? { T.e `Closed , T.e `Closed }
+ | E U { T.eu `Opened , T.eu `Opened }
+ | O { T.o `Opened , T.o `Opened }
+
+nasal_voyels:
+ | A N { T.a' () , T.a' () }
+ %prec Low
+
+ending_consonant:
+ | S { Some (T.s ()) }
+ | T { None }
+ | R { Some (T.r ()) }
+ | nasal { Some $1 }
+
+ending_word:
+ | X { Some (T.muted (T.s ())) }
+ | S { Some (T.muted (T.s ())) }
+ | R { Some (T.muted (T.r ())) }
+ | T { Some (T.muted T.t) }
+
+consonant_group:
+ | opening_consonant
+ {
+ { ending = None
+ ; opening = [ fst $1 ]
+ ; following = snd $1 }
+ }
+ | ending_consonant
+ opening_consonant
+ {
+ { ending = Some $1
+ ; opening = [ fst $2 ]
+ ; following = snd $2 }
+ }
+
+syllable:
+ | c = consonant_group?
+ v = voyels
+ { (v, c) }
+
+
+syllables:
+ | { [] }
+ | ss = syllables s = syllable { s::ss }
+
+
+word:
+ | syllables ending_word? EOL { P.rebuild $2 $1 }
+
+main:
+ | word { $1 }