summaryrefslogtreecommitdiff
path: root/examples/regulus/toy0/no-resource/Toy0_eng.gf
blob: ed8fe806310f3f6fbcad160a3a69a660bf82f8ef (plain)
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
-- 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"
      }
    } ;