diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-25 16:54:35 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-25 16:54:35 +0000 |
| commit | e9e80fc389365e24d4300d7d5390c7d833a96c50 (patch) | |
| tree | f0b58473adaa670bd8fc52ada419d8cad470ee03 /old-examples/regulus | |
| parent | b96b36f43de3e2f8b58d5f539daa6f6d47f25870 (diff) | |
changed names of resource-1.3; added a note on homepage on release
Diffstat (limited to 'old-examples/regulus')
28 files changed, 724 insertions, 0 deletions
diff --git a/old-examples/regulus/README b/old-examples/regulus/README new file mode 100644 index 000000000..b3659c5e2 --- /dev/null +++ b/old-examples/regulus/README @@ -0,0 +1,24 @@ +AR 10 June 2007. + +Grammars from the book + + Manny Rayner, Beth and Hockey, and Pierrette Bouillon. + Putting Linguistics into Speech Recognition + The Regulus Grammar Compiler. + CSLI 2006. + +The goal is to help compare grammar writing in GF with Regulus. + +To compile a grammar X.gf into Nuance/GSL: + + gf + > i X.gf + > pg -printer=gsl + +The GSL format does not return semantics, but some others do, e.g. + + -printer=jsgf_sisr_old Java Speech Grammar Format with semantic tags in + SISR WD 20030401 format + -printer=srgs_abnf_sisr_old SRGS ABNF format, with semantic tags in + SISR WD 20030401 format + diff --git a/old-examples/regulus/toy0/Toy0.gf b/old-examples/regulus/toy0/Toy0.gf new file mode 100644 index 000000000..b1e2d6a40 --- /dev/null +++ b/old-examples/regulus/toy0/Toy0.gf @@ -0,0 +1,15 @@ +-- toy0 grammar from Chapter 2 of the Regulus book +abstract Toy0 = { + + flags startcat=NP ; + + cat + NP ; + Noun ; + Spec ; + + fun + SpecNoun : Spec -> Noun -> NP ; + One, Two : Spec ; + Felis, Canis : Noun ; +} diff --git a/old-examples/regulus/toy0/Toy0Eng.gf b/old-examples/regulus/toy0/Toy0Eng.gf new file mode 100644 index 000000000..edfe520e4 --- /dev/null +++ b/old-examples/regulus/toy0/Toy0Eng.gf @@ -0,0 +1,5 @@ +--# -path=.:present:prelude + +concrete Toy0Eng of Toy0 = Toy0I with + (Syntax = SyntaxEng), + (Lexicon = LexiconEng) ; diff --git a/old-examples/regulus/toy0/Toy0Fin.gf b/old-examples/regulus/toy0/Toy0Fin.gf new file mode 100644 index 000000000..f550e751e --- /dev/null +++ b/old-examples/regulus/toy0/Toy0Fin.gf @@ -0,0 +1,5 @@ +--# -path=.:present:prelude + +concrete Toy0Fin of Toy0 = Toy0I with + (Syntax = SyntaxFin), + (Lexicon = LexiconFin) ; diff --git a/old-examples/regulus/toy0/Toy0Fre.gf b/old-examples/regulus/toy0/Toy0Fre.gf new file mode 100644 index 000000000..513e9b390 --- /dev/null +++ b/old-examples/regulus/toy0/Toy0Fre.gf @@ -0,0 +1,5 @@ +--# -path=.:present:prelude + +concrete Toy0Fre of Toy0 = Toy0I with + (Syntax = SyntaxFre), + (Lexicon = LexiconFre) ; diff --git a/old-examples/regulus/toy0/Toy0I.gf b/old-examples/regulus/toy0/Toy0I.gf new file mode 100644 index 000000000..efb6e730a --- /dev/null +++ b/old-examples/regulus/toy0/Toy0I.gf @@ -0,0 +1,18 @@ +incomplete concrete Toy0I of Toy0 = open Syntax, Lexicon in { + +lincat + Spec = Det ; + Noun = N ; + NP = Utt ; + +lin + SpecNoun spec noun = mkUtt (mkNP spec noun) ; + + One = mkDet n1_Numeral ; + Two = mkDet n2_Numeral ; + + Felis = cat_N ; + Canis = dog_N ; + +} + diff --git a/old-examples/regulus/toy0/Toy0Swe.gf b/old-examples/regulus/toy0/Toy0Swe.gf new file mode 100644 index 000000000..5de273d00 --- /dev/null +++ b/old-examples/regulus/toy0/Toy0Swe.gf @@ -0,0 +1,5 @@ +--# -path=.:present:prelude + +concrete Toy0Swe of Toy0 = Toy0I with + (Syntax = SyntaxSwe), + (Lexicon = LexiconSwe) ; diff --git a/old-examples/regulus/toy0/example-based/Toy0.gf b/old-examples/regulus/toy0/example-based/Toy0.gf new file mode 100644 index 000000000..b1e2d6a40 --- /dev/null +++ b/old-examples/regulus/toy0/example-based/Toy0.gf @@ -0,0 +1,15 @@ +-- toy0 grammar from Chapter 2 of the Regulus book +abstract Toy0 = { + + flags startcat=NP ; + + cat + NP ; + Noun ; + Spec ; + + fun + SpecNoun : Spec -> Noun -> NP ; + One, Two : Spec ; + Felis, Canis : Noun ; +} diff --git a/old-examples/regulus/toy0/example-based/Toy0Ger.gf b/old-examples/regulus/toy0/example-based/Toy0Ger.gf new file mode 100644 index 000000000..7355cbfac --- /dev/null +++ b/old-examples/regulus/toy0/example-based/Toy0Ger.gf @@ -0,0 +1,6 @@ +--# -path=.:present:prelude + +concrete Toy0Ger of Toy0 = Toy0I with + (Grammar = GrammarGer), + (Lexicon = LexiconGer) ; + diff --git a/old-examples/regulus/toy0/example-based/Toy0I.gfe b/old-examples/regulus/toy0/example-based/Toy0I.gfe new file mode 100644 index 000000000..4589bf4b6 --- /dev/null +++ b/old-examples/regulus/toy0/example-based/Toy0I.gfe @@ -0,0 +1,23 @@ +--# -resource=present/LangEng.gfc +--# -path=.:present:prelude + +-- to compile: gf -examples Toy0I.gfe + +incomplete concrete Toy0I of Toy0 = open Grammar, Lexicon in { + +lincat + Spec = Det ; + Noun = N ; + NP = Utt ; + +lin + SpecNoun every_Det house_N = in Utt "every house" ; + + One = in Det "one" ; + Two = in Det "two" ; + + Felis = in N "cat" ; + Canis = in N "dog" ; + +} + diff --git a/old-examples/regulus/toy0/no-functor/Toy0.gf b/old-examples/regulus/toy0/no-functor/Toy0.gf new file mode 100644 index 000000000..b1e2d6a40 --- /dev/null +++ b/old-examples/regulus/toy0/no-functor/Toy0.gf @@ -0,0 +1,15 @@ +-- toy0 grammar from Chapter 2 of the Regulus book +abstract Toy0 = { + + flags startcat=NP ; + + cat + NP ; + Noun ; + Spec ; + + fun + SpecNoun : Spec -> Noun -> NP ; + One, Two : Spec ; + Felis, Canis : Noun ; +} diff --git a/old-examples/regulus/toy0/no-functor/Toy0Eng.gf b/old-examples/regulus/toy0/no-functor/Toy0Eng.gf new file mode 100644 index 000000000..3bd6613a3 --- /dev/null +++ b/old-examples/regulus/toy0/no-functor/Toy0Eng.gf @@ -0,0 +1,16 @@ +--# -path=.:present:api:prelude +concrete Toy0Eng of Toy0 = + open SyntaxEng, ParadigmsEng in { + + flags language=en_US ; + + lincat + Spec = Det ; Noun = N ; NP = Utt ; + + lin + SpecNoun s n = mkUtt (mkNP s n) ; + One = mkDet one_Quant ; + Two = mkDet n2_Numeral ; + Felis = mkN "cat" ; + Canis = mkN "dog" ; +} diff --git a/old-examples/regulus/toy0/no-functor/Toy0Fin.gf b/old-examples/regulus/toy0/no-functor/Toy0Fin.gf new file mode 100644 index 000000000..4ebbf6f36 --- /dev/null +++ b/old-examples/regulus/toy0/no-functor/Toy0Fin.gf @@ -0,0 +1,16 @@ +--# -path=.:present:prelude + +concrete Toy0Fin of Toy0 = open SyntaxFin, ParadigmsFin in { + +lincat + Spec = Det ; + Noun = N ; + NP = Utt ; +lin + SpecNoun spec noun = mkUtt (SyntaxFin.mkNP spec noun) ; + + One = mkDet one_Quant ; + Two = mkDet (mkNum n2_Numeral) ; + Felis = mkN "kissa" ; + Canis = mkN "koira" ; +} diff --git a/old-examples/regulus/toy0/no-resource/Toy0.gf b/old-examples/regulus/toy0/no-resource/Toy0.gf new file mode 100644 index 000000000..b1e2d6a40 --- /dev/null +++ b/old-examples/regulus/toy0/no-resource/Toy0.gf @@ -0,0 +1,15 @@ +-- toy0 grammar from Chapter 2 of the Regulus book +abstract Toy0 = { + + flags startcat=NP ; + + cat + NP ; + Noun ; + Spec ; + + fun + SpecNoun : Spec -> Noun -> NP ; + One, Two : Spec ; + Felis, Canis : Noun ; +} diff --git a/old-examples/regulus/toy0/no-resource/Toy0Eng.gf b/old-examples/regulus/toy0/no-resource/Toy0Eng.gf new file mode 100644 index 000000000..977fb09c5 --- /dev/null +++ b/old-examples/regulus/toy0/no-resource/Toy0Eng.gf @@ -0,0 +1,27 @@ +concrete Toy0Eng of Toy0 = { + +param + Number = Sg | Pl ; + +lincat + Spec = {s : Str ; n : Number} ; + Noun = {s : Number => Str} ; + NP = {s : Str} ; + +lin + SpecNoun spec noun = {s = spec.s ++ noun.s ! spec.n} ; + + One = {s = "one" ; n = Sg} ; + Two = {s = "two" ; n = Pl} ; + + Felis = regNoun "cat" ; + Canis = regNoun "dog" ; + +oper + regNoun : Str -> {s : Number => Str} = \s -> { + s = table { + Sg => s ; + Pl => s + "s" + } + } ; +} diff --git a/old-examples/regulus/toy0/no-resource/Toy0Fre.gf b/old-examples/regulus/toy0/no-resource/Toy0Fre.gf new file mode 100644 index 000000000..c5267ae18 --- /dev/null +++ b/old-examples/regulus/toy0/no-resource/Toy0Fre.gf @@ -0,0 +1,29 @@ +concrete Toy0Fre of Toy0 = { + +param + Number = Sg | Pl ; + Gender = Masc | Fem ; + +lincat + Spec = {s : Gender => Str ; n : Number} ; + Noun = {s : Number => Str ; g : Gender} ; + NP = {s : Str} ; + +lin + SpecNoun spec noun = {s = spec.s ! noun.g ++ noun.s ! spec.n} ; + + One = {s = table {Fem => "une" ; _ => "un"} ; n = Sg} ; + Two = {s = \\_ => "deux" ; n = Pl} ; + + Felis = mkNoun "chat" Masc ; + Canis = mkNoun "chien" Masc ; + +oper + mkNoun : Str -> Gender -> {s : Number => Str ; g : Gender} = \s,g -> { + s = table { + Sg => s ; + Pl => s + "s" + } ; + g = g + } ; +} diff --git a/old-examples/regulus/toy0/no-resource/Toy0Ger.gf b/old-examples/regulus/toy0/no-resource/Toy0Ger.gf new file mode 100644 index 000000000..091790f94 --- /dev/null +++ b/old-examples/regulus/toy0/no-resource/Toy0Ger.gf @@ -0,0 +1,29 @@ +concrete Toy0Ger of Toy0 = { + +param + Number = Sg | Pl ; + Gender = Masc | Fem | Neutr ; + +lincat + Spec = {s : Gender => Str ; n : Number} ; + Noun = {s : Number => Str ; g : Gender} ; + NP = {s : Str} ; + +lin + SpecNoun spec noun = {s = spec.s ! noun.g ++ noun.s ! spec.n} ; + + One = {s = table {Fem => "eine" ; _ => "ein"} ; n = Sg} ; + Two = {s = \\_ => "zwei" ; n = Pl} ; + + Felis = mkNoun "Katze" "Katzen" Fem ; + Canis = mkNoun "Hund" "Hünde" Masc ; + +oper + mkNoun : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = \s,p,g -> { + s = table { + Sg => s ; + Pl => p + } ; + g = g + } ; +} diff --git a/old-examples/regulus/toy0/no-resource/Toy0_eng.gf b/old-examples/regulus/toy0/no-resource/Toy0_eng.gf new file mode 100644 index 000000000..ed8fe8063 --- /dev/null +++ b/old-examples/regulus/toy0/no-resource/Toy0_eng.gf @@ -0,0 +1,39 @@ +-- grammar from Chapter 2 of the Regulus book + +flags startcat=MAIN ; + +cat + MAIN ; NP ; Noun ; Spec ; + +fun + Main : NP -> MAIN ; + SpecNoun : Spec -> Noun -> NP ; + + One, Two : Spec ; + Felis, Canis : Noun ; + +param + Number = Sg | Pl ; + +lincat + Spec = {s : Str ; n : Number} ; + Noun = {s : Number => Str} ; + MAIN,NP = {s : Str} ; + +lin + Main np = np ; + SpecNoun spec noun = {s = spec.s ++ noun.s ! spec.n} ; + + One = {s = "one" ; n = Sg} ; + Two = {s = "two" ; n = Pl} ; + + Felis = regNoun "cat" ; + Canis = regNoun "dog" ; + +oper + regNoun : Str -> {s : Number => Str} = \s -> { + s = table { + Sg => s ; + Pl => s + "s" + } + } ; diff --git a/old-examples/regulus/toy0/toy0.gfprobs b/old-examples/regulus/toy0/toy0.gfprobs new file mode 100644 index 000000000..7c97562e2 --- /dev/null +++ b/old-examples/regulus/toy0/toy0.gfprobs @@ -0,0 +1 @@ +--# prob Felis 0.9 diff --git a/old-examples/regulus/toy1/LexToy1.gf b/old-examples/regulus/toy1/LexToy1.gf new file mode 100644 index 000000000..d48e43a3b --- /dev/null +++ b/old-examples/regulus/toy1/LexToy1.gf @@ -0,0 +1,12 @@ +interface LexToy1 = open Syntax in { + +oper + dim_V2 : V2 ; + fan_N : N ; + kitchen_N : N ; + light_N : N ; + livingRoom_N : N ; + switchOff_V2 : V2 ; + switchOn_V2 : V2 ; + +}
\ No newline at end of file diff --git a/old-examples/regulus/toy1/LexToy1Swe.gf b/old-examples/regulus/toy1/LexToy1Swe.gf new file mode 100644 index 000000000..3930a4728 --- /dev/null +++ b/old-examples/regulus/toy1/LexToy1Swe.gf @@ -0,0 +1,12 @@ +instance LexToy1Swe of LexToy1 = open SyntaxSwe, ParadigmsSwe in { + +oper + dim_V2 = mkV2 "dämpa" ; + fan_N = mkN "fläkt" ; + kitchen_N = mkN "kök" neutrum ; + light_N = mkN "lampa" ; + livingRoom_N = mkN "vardagsrum" "vardagsrummet" "vardagsrum" "vardagsrummen" ; + switchOff_V2 = mkV2 "släcker" ; + switchOn_V2 = mkV2 "tänder" ; + +} diff --git a/old-examples/regulus/toy1/Toy1.gf b/old-examples/regulus/toy1/Toy1.gf new file mode 100644 index 000000000..49bd320c1 --- /dev/null +++ b/old-examples/regulus/toy1/Toy1.gf @@ -0,0 +1,47 @@ +abstract Toy1 = { + +flags startcat = Utterance ; + +cat + Utterance ; + Command ; + Question ; + Kind ; + Action Kind ; + Device Kind ; + Location ; + + Switchable Kind ; + Dimmable Kind ; + Statelike (k : Kind) (Action k) ; + +fun + UCommand : Command -> Utterance ; + UQuestion : Question -> Utterance ; + + CAction : (k : Kind) -> Action k -> Device k -> Command ; + QAction : (k : Kind) -> (a : Action k) -> Statelike k a -> Device k -> Question ; + + DKindOne : (k : Kind) -> Device k ; + DKindMany : (k : Kind) -> Device k ; + DLoc : (k : Kind) -> Device k -> Location -> Device k ; + + light, fan : Kind ; + + switchOn, switchOff : (k : Kind) -> Switchable k -> Action k ; + + dim : (k : Kind) -> Dimmable k -> Action k ; + + kitchen, livingRoom : Location ; + +-- proof objects + + switchable_light : Switchable light ; + switchable_fan : Switchable fan ; + dimmable_light : Dimmable light ; + + statelike_switchOn : (k : Kind) -> (s : Switchable k) -> Statelike k (switchOn k s) ; + statelike_switchOff : (k : Kind) -> (s : Switchable k) -> Statelike k (switchOff k s) ; + +} + diff --git a/old-examples/regulus/toy1/Toy1Eng.gf b/old-examples/regulus/toy1/Toy1Eng.gf new file mode 100644 index 000000000..384e50060 --- /dev/null +++ b/old-examples/regulus/toy1/Toy1Eng.gf @@ -0,0 +1,84 @@ +--# -path=.:prelude + +concrete Toy1Eng of Toy1 = open Prelude in { + +-- grammar Toy1 from the Regulus book + +flags startcat = Utterance ; + +param + Number = Sg | Pl ; + VForm = VImp | VPart ; + +lincat + Utterance = SS ; + Command = SS ; + Question = SS ; + Kind = {s : Number => Str} ; + Action = {s : VForm => Str ; part : Str} ; + Device = {s : Str ; n : Number} ; + Location = SS ; + +lin + UCommand c = c ; + UQuestion q = q ; + + CAction _ act dev = ss (act.s ! VImp ++ bothWays act.part dev.s) ; + QAction _ act st dev = ss (be dev.n ++ dev.s ++ act.s ! VPart ++ act.part ++ st.s) ; + + DKindOne k = { + s = "the" ++ k.s ! Sg ; + n = Sg + } ; + DKindMany k = { + s = "the" ++ k.s ! Pl ; + n = Pl + } ; + DLoc _ dev loc = { + s = dev.s ++ "in" ++ "the" ++ loc.s ; + n = dev.n + } ; + + light = mkNoun "light" ; + fan = mkNoun "fan" ; + + switchOn _ _ = mkVerb "switch" "swithced" "on" ; + switchOff _ _ = mkVerb "switch" "swithced" "off" ; + + dim _ _ = mkVerb "dim" "dimmed" [] ; + + kitchen = ss "kitchen" ; + livingRoom = ss ["living room"] ; + +oper + mkNoun : Str -> {s : Number => Str} = \dog -> { + s = table { + Sg => dog ; + Pl => dog + "s" + } + } ; + + mkVerb : (_,_,_ : Str) -> {s : VForm => Str ; part : Str} = \go,gone,away -> { + s = table { + VImp => go ; + VPart => gone + } ; + part = away + } ; + + be : Number -> Str = \n -> case n of { + Sg => "is" ; + Pl => "are" + } ; + + hidden : SS = ss [] ; +lin + switchable_light = hidden ; + switchable_fan = hidden ; + dimmable_light = hidden ; + + statelike_switchOn _ _ = hidden ; + statelike_switchOff _ _ = hidden ; + +} + diff --git a/old-examples/regulus/toy1/Toy1Fre.gf b/old-examples/regulus/toy1/Toy1Fre.gf new file mode 100644 index 000000000..c5d903519 --- /dev/null +++ b/old-examples/regulus/toy1/Toy1Fre.gf @@ -0,0 +1,95 @@ +--# -path=.:prelude + +concrete Toy1Fre of Toy1 = open Prelude in { + +-- grammar Toy1 from the Regulus book + +flags startcat = Utterance ; + +param + Number = Sg | Pl ; + Gender = Masc | Fem ; + VForm = VInf | VPart Gender Number ; + +lincat + Utterance = SS ; + Command = SS ; + Question = SS ; + Kind = {s : Number => Str ; g : Gender} ; + Action = {s : VForm => Str} ; + Device = {s : Str ; g : Gender ; n : Number} ; + Location = {s : Number => Str ; g : Gender} ; + +lin + UCommand c = c ; + UQuestion q = q ; + + CAction _ act dev = ss (act.s ! VInf ++ dev.s) ; + QAction _ act st dev = + ss (dev.s ++ est dev.g dev.n ++ act.s ! VPart dev.g dev.n ++ st.s) ; + + DKindOne k = { + s = defArt k.g ++ k.s ! Sg ; + g = k.g ; + n = Sg + } ; + DKindMany k = { + s = "les" ++ k.s ! Pl ; + g = k.g ; + n = Pl + } ; + DLoc _ dev loc = { + s = dev.s ++ "dans" ++ defArt loc.g ++ loc.s ! Sg ; + g = dev.g ; + n = dev.n + } ; + + light = mkNoun "lampe" Fem ; + fan = mkNoun "ventilateur" Masc ; + + switchOn _ _ = mkVerb "allumer" "allumé" ; + switchOff _ _ = mkVerb "éteindre" "éteint" ; + + dim _ _ = mkVerb "baisser" "baissé" ; + + kitchen = mkNoun "cuisine" Fem ; + livingRoom = mkNoun "salon" Masc ; + +oper + mkNoun : Str -> Gender -> {s : Number => Str ; g : Gender} = \dog,g -> { + s = table { + Sg => dog ; + Pl => dog + "s" + } ; + g = g + } ; + + mkVerb : (_,_ : Str) -> {s : VForm => Str} = \venir,venu -> { + s = table { + VInf => venir ; + VPart Masc Sg => venu ; + VPart Masc Pl => venu + "s" ; + VPart Fem Sg => venu + "e" ; + VPart Fem Pl => venu + "es" + } + } ; + + est : Gender -> Number -> Str = \g,n -> case <g,n> of { + <Masc,Sg> => "est-il" ; + <Fem, Sg> => "est-elle" ; + <Masc,Pl> => "sont-ils" ; + <Fem, Pl> => "sont-elles" + } ; + + defArt : Gender -> Str = \g -> case g of {Masc => "le" ; Fem => "la"} ; + +lin + switchable_light = ss [] ; + switchable_fan = ss [] ; + dimmable_light = ss [] ; + + statelike_switchOn _ _ = ss [] ; + statelike_switchOff _ _ = ss [] ; + +} + diff --git a/old-examples/regulus/toy1/Toy1I.gf b/old-examples/regulus/toy1/Toy1I.gf new file mode 100644 index 000000000..eb7a9db7a --- /dev/null +++ b/old-examples/regulus/toy1/Toy1I.gf @@ -0,0 +1,50 @@ +--# -path=.:present:prelude + +incomplete concrete Toy1I of Toy1 = open Syntax, LexToy1, Prelude in { + +-- grammar Toy1 from the Regulus book + +flags startcat = Utterance ; + +lincat + Utterance = Utt ; + Command = Imp ; + Question = QS ; + Kind = N ; + Action = V2 ; + Device = NP ; + Location = N ; + +lin + UCommand c = mkUtt politeImpForm c ; + UQuestion q = mkUtt q ; + + CAction _ act dev = mkImp act dev ; + QAction _ act st dev = + mkQS anteriorAnt (mkQCl (mkCl dev (passiveVP act))) ; ---- show empty proof + + DKindOne k = mkNP defSgDet k ; + DKindMany k = mkNP defPlDet k ; + DLoc _ dev loc = mkNP dev (mkAdv in_Prep (mkNP defSgDet loc)) ; + + light = light_N ; + fan = fan_N ; + + switchOn _ _ = switchOn_V2 ; + switchOff _ _ = switchOff_V2 ; + + dim _ _ = dim_V2 ; + + kitchen = kitchen_N ; + livingRoom = livingRoom_N ; + +lin + switchable_light = ss [] ; + switchable_fan = ss [] ; + dimmable_light = ss [] ; + + statelike_switchOn _ _ = ss [] ; + statelike_switchOff _ _ = ss [] ; + + +} diff --git a/old-examples/regulus/toy1/Toy1Swe.gf b/old-examples/regulus/toy1/Toy1Swe.gf new file mode 100644 index 000000000..0e23994c8 --- /dev/null +++ b/old-examples/regulus/toy1/Toy1Swe.gf @@ -0,0 +1,5 @@ +--# -path=.:alltenses:prelude + +concrete Toy1Swe of Toy1 = Toy1I with + (Syntax = SyntaxSwe), + (LexToy1 = LexToy1Swe) ; diff --git a/old-examples/regulus/toy1/Toy1a.gf b/old-examples/regulus/toy1/Toy1a.gf new file mode 100644 index 000000000..cab51455b --- /dev/null +++ b/old-examples/regulus/toy1/Toy1a.gf @@ -0,0 +1,35 @@ +abstract Toy1a = { + +flags startcat = Utterance ; + +cat + Utterance ; + Command ; + Question ; + Kind ; + Action Kind ; + Device Kind ; + Location ; + +fun + UCommand : Command -> Utterance ; + UQuestion : Question -> Utterance ; + + CAction : (k : Kind) -> Action k -> Device k -> Command ; + QAction : (k : Kind) -> Action k -> Device k -> Question ; + + DKindOne : (k : Kind) -> Device k ; + DKindMany : (k : Kind) -> Device k ; + DLoc : (k : Kind) -> Device k -> Location -> Device k ; + + light, fan : Kind ; + + switchOn, switchOff : (k : Kind) -> Action k ; + + dim : Action light ; + + kitchen, livingRoom : Location ; + + +} + diff --git a/old-examples/regulus/toy1/Toy1aEng.gf b/old-examples/regulus/toy1/Toy1aEng.gf new file mode 100644 index 000000000..d0748cc82 --- /dev/null +++ b/old-examples/regulus/toy1/Toy1aEng.gf @@ -0,0 +1,76 @@ +--# -path=.:prelude + +concrete Toy1aEng of Toy1a = open Prelude in { + +-- grammar Toy1 from the Regulus book + +flags startcat = Utterance ; + +param + Number = Sg | Pl ; + VForm = VImp | VPart ; + +lincat + Utterance = SS ; + Command = SS ; + Question = SS ; + Kind = {s : Number => Str} ; + Action = {s : VForm => Str ; part : Str} ; + Device = {s : Str ; n : Number} ; + Location = SS ; + +lin + UCommand c = c ; + UQuestion q = q ; + + CAction _ act dev = ss (act.s ! VImp ++ bothWays act.part dev.s) ; + QAction _ act dev = ss (be dev.n ++ dev.s ++ act.s ! VPart ++ act.part) ; + + DKindOne k = { + s = "the" ++ k.s ! Sg ; + n = Sg + } ; + DKindMany k = { + s = "the" ++ k.s ! Pl ; + n = Pl + } ; + DLoc _ dev loc = { + s = dev.s ++ "in" ++ "the" ++ loc.s ; + n = dev.n + } ; + + light = mkNoun "light" ; + fan = mkNoun "fan" ; + + switchOn _ = mkVerb "switch" "switched" "on" ; + switchOff _ = mkVerb "switch" "switched" "off" ; + + dim = mkVerb "dim" "dimmed" [] ; + + kitchen = ss "kitchen" ; + livingRoom = ss ["living room"] ; + +oper + mkNoun : Str -> {s : Number => Str} = \dog -> { + s = table { + Sg => dog ; + Pl => dog + "s" + } + } ; + + mkVerb : (_,_,_ : Str) -> {s : VForm => Str ; part : Str} = \go,gone,away -> { + s = table { + VImp => go ; + VPart => gone + } ; + part = away + } ; + + be : Number -> Str = \n -> case n of { + Sg => "is" ; + Pl => "are" + } ; + + +} + |
