-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiniResEng.gf
99 lines (74 loc) · 2.04 KB
/
MiniResEng.gf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
resource MiniResEng = open Prelude in {
param
Number = Sg | Pl ;
Case = Nom | Acc ;
Person = Per1 | Per2 | Per3 ;
Agreement = Agr Number Person ;
VForm = Inf | PresSg3 ;
oper
Noun : Type = {s : Number => Str} ;
mkNoun : Str -> Str -> Noun = \sg,pl -> {
s = table {Sg => sg ; Pl => pl}
} ;
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
-- smart paradigm
smartNoun : Str -> Noun = \sg -> case sg of {
_ + ("ay"|"ey"|"oy"|"uy") => regNoun sg ;
x + "y" => mkNoun sg (x + "ies") ;
_ + ("ch"|"sh"|"s"|"o") => mkNoun sg (sg + "es") ;
_ => regNoun sg
} ;
mkN = overload {
mkN : Str -> Noun = smartNoun ;
mkN : Str -> Str -> Noun = mkNoun ;
} ;
ProperName : Type = {s : Str} ;
mkPN : Str -> ProperName = \s -> {s = s} ;
Adjective : Type = {s : Str} ;
mkA : Str -> Adjective = \s -> {s = s} ;
Verb : Type = {s : VForm => Str} ;
mkVerb : (inf,pres : Str) -> Verb = \inf,pres -> {
s = table {
Inf => inf ;
PresSg3 => pres
}
} ;
smartVerb : Str -> Verb = \inf ->
mkVerb inf ((mkN inf).s ! Pl) ;
mkV = overload {
mkV : Str -> Verb = smartVerb ;
mkV : (inf,pres : Str) -> Verb = mkVerb ;
} ;
Verb2 : Type = Verb ** {c : Str} ;
mkV2 = overload {
mkV2 : Str -> Verb2 = \s -> mkV s ** {c = []} ;
mkV2 : Str -> Str -> Verb2 = \s,p -> mkV s ** {c = p} ;
mkV2 : Verb -> Verb2 = \v -> v ** {c = []} ;
mkV2 : Verb -> Str -> Verb2 = \v,p -> v ** {c = p} ;
} ;
Adverb : Type = {s : Str} ;
mkAdv : Str -> Adverb = \s -> {s = s} ;
be_GVerb : GVerb = {
s = table {
PresSg1 => "am" ;
PresPl => "are" ;
VF vf => (mkVerb "be" "is").s ! vf
} ;
isAux = True
} ;
GVerb : Type = {
s : GVForm => Str ;
isAux : Bool
} ;
param
GVForm = VF VForm | PresSg1 | PresPl ;
oper
verb2gverb : Verb -> GVerb = \v -> {s =
table {
PresSg1 => v.s ! Inf ;
PresPl => v.s ! Inf ;
VF vf => v.s ! vf
} ;
isAux = False
} ;
}