diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-09-12 21:03:00 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-09-12 21:03:00 +0000 |
| commit | c9f8961a9ed5c33524619309171aba1b587ad7c2 (patch) | |
| tree | b11ab55379d53b027ac528e1c49bbef4c4e52a3a /examples/tutorial/smart/SmartEng.gf | |
| parent | fff6afd438ec49cf32f9a384b98e6f9a7859d65c (diff) | |
last adjustments of examples before course
Diffstat (limited to 'examples/tutorial/smart/SmartEng.gf')
| -rw-r--r-- | examples/tutorial/smart/SmartEng.gf | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/examples/tutorial/smart/SmartEng.gf b/examples/tutorial/smart/SmartEng.gf new file mode 100644 index 000000000..384e50060 --- /dev/null +++ b/examples/tutorial/smart/SmartEng.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 ; + +} + |
