diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-17 13:16:15 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-17 13:16:15 +0000 |
| commit | 23b8136af27b0baaa8fcb5272a613d5f2ee447fa (patch) | |
| tree | 2e7cd2930b7e8b6b0d911c00ec2d279b882f4893 /examples-3.0/tutorial/syntax/MorphoEng.gf | |
| parent | 7c097669d2c3934622c57f6e2f4ddee8826953d3 (diff) | |
started examples-3.0 with examples that are tested to work
Diffstat (limited to 'examples-3.0/tutorial/syntax/MorphoEng.gf')
| -rw-r--r-- | examples-3.0/tutorial/syntax/MorphoEng.gf | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/examples-3.0/tutorial/syntax/MorphoEng.gf b/examples-3.0/tutorial/syntax/MorphoEng.gf new file mode 100644 index 000000000..b2255d0d4 --- /dev/null +++ b/examples-3.0/tutorial/syntax/MorphoEng.gf @@ -0,0 +1,69 @@ +--# -path=.:prelude + +resource MorphoEng = open Prelude in { + + -- the lexicon construction API + + oper + mkN : overload { + mkN : (bus : Str) -> Noun ; + mkN : (man,men : Str) -> Noun ; + } ; + + mkA : (warm : Str) -> Adjective ; + + mkV : overload { + mkV : (kiss : Str) -> Verb ; + mkV : (do,does : Str) -> Verb ; + } ; + + mkV2 : overload { + mkV2 : (love : Verb) -> Verb2 ; + mkV2 : (talk : Verb) -> (about : Str) -> Verb2 ; + } ; + + -- grammar-internal definitions + + param + Number = Sg | Pl ; + + oper + Noun, Verb : Type = {s : Number => Str} ; + Adjective : Type = {s : Str} ; + Verb2 : Type = Verb ** {c : Str} ; + + mkN = overload { + mkN : (bus : Str) -> Noun = \s -> mkNoun s (add_s s) ; + mkN : (man,men : Str) -> Noun = mkNoun ; + } ; + + mkA : (warm : Str) -> Adjective = ss ; + + mkV = overload { + mkV : (kiss : Str) -> Verb = \s -> mkVerb s (add_s s) ; + mkV : (do,does : Str) -> Verb = mkVerb ; + } ; + + mkV2 = overload { + mkV2 : (love : Verb) -> Verb2 = \love -> love ** {c = []} ; + mkV2 : (talk : Verb) -> (about : Str) -> Verb2 = + \talk,about -> talk ** {c = about} ; + } ; + + add_s : Str -> Str = \w -> case w of { + _ + "oo" => w + "s" ; -- bamboo + _ + ("s" | "z" | "x" | "sh" | "o") => w + "es" ; -- bus, hero + _ + ("a" | "o" | "u" | "e") + "y" => w + "s" ; -- boy + x + "y" => x + "ies" ; -- fly + _ => w + "s" -- car + } ; + + mkNoun : Str -> Str -> Noun = \x,y -> { + s = table { + Sg => x ; + Pl => y + } + } ; + + mkVerb : Str -> Str -> Verb = \x,y -> mkNoun y x ; + } |
