forked from GitHub/comp-syntax-gu-mlt
intro to Lab2 from today's lecture
This commit is contained in:
15
lab2/grammar/intro/MicroLangEng.gf
Normal file
15
lab2/grammar/intro/MicroLangEng.gf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
--# -path=.:../abstract
|
||||||
|
|
||||||
|
concrete MicroLangEng of MicroLang =
|
||||||
|
open MicroResEng
|
||||||
|
in {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
N = Noun ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
animal_N = mkN "animal" ;
|
||||||
|
apple_N = mkN "apple" ;
|
||||||
|
baby_N = mkN "baby" ;
|
||||||
|
woman_N = mkN "woman" "women" ;
|
||||||
|
}
|
||||||
44
lab2/grammar/intro/MicroResEng.gf
Normal file
44
lab2/grammar/intro/MicroResEng.gf
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
-- live-coded MicroResEng for Lab 2
|
||||||
|
|
||||||
|
resource MicroResEng = {
|
||||||
|
|
||||||
|
param
|
||||||
|
Number = Sg | Pl ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
-- phonological patterns
|
||||||
|
sibilant : pattern Str
|
||||||
|
= #("s" | "x" | "ch" | "sh" | "z") ;
|
||||||
|
vowel : pattern Str
|
||||||
|
= #("a" | "e" | "i" | "o" | "u") ;
|
||||||
|
|
||||||
|
-- the type of nouns
|
||||||
|
Noun : Type = {s : Number => Str} ;
|
||||||
|
|
||||||
|
-- worst-case paradigm
|
||||||
|
mkNoun : (sg, pl : Str) -> Noun
|
||||||
|
= \sg, pl -> {s = table {Sg => sg ; Pl => pl}} ;
|
||||||
|
|
||||||
|
-- regular paradigm
|
||||||
|
regNoun : (sg : Str) -> Noun
|
||||||
|
= \sg -> mkNoun sg (sg + "s") ;
|
||||||
|
|
||||||
|
-- smart paradigm
|
||||||
|
smartNoun : (sg : Str) -> Noun
|
||||||
|
= \sg -> case sg of {
|
||||||
|
x + #vowel + "y" => regNoun sg ;
|
||||||
|
x + "y" => mkNoun sg (x + "ies") ;
|
||||||
|
x + #sibilant => mkNoun sg (sg + "es") ;
|
||||||
|
_ => regNoun sg
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- overloaded paradigm for lexicographers
|
||||||
|
mkN = overload {
|
||||||
|
mkN : (sg : Str) -> Noun = smartNoun ;
|
||||||
|
mkN : (sg, pl : Str) -> Noun = mkNoun ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user