summaryrefslogtreecommitdiff
path: root/old-examples/query/DatabaseEng.gf
blob: 6af49067888f83927712394971ca6453eb8cccd7 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
--# -path=.:prelude

concrete DatabaseEng of Database = open Prelude in {

-- english query language

flags lexer=literals ; unlexer=text ;

-- concrete syntax; greatly simplified - just for test purposes

lin 
  QueryS s = s ;
  QueryQ q = q ;

  PredA1 np a = prefixSS "is" (cc2 np a) ;

  WhichA1 n a = ss ("which" ++ n.s ++ "are" ++ a.s) ;
  WhichA2 n q a = ss ("which" ++ n.s ++ "are" ++ q.s ++ a.s) ;

  ComplA2     = cc2 ;

  Every A  = ss ("every" ++ A.s) ;
  Some A   = ss ("some" ++ A.s) ;
  UseInt n = n ;

  Number = ss "numbers" ;

  Even   = ss "even" ;
  Odd    = ss "odd" ;
  Prime  = ss "prime" ;
  Equal  = ss ("equal" ++ "to") ;
  Greater = ss ("greater" ++ "than") ;
  Smaller = ss ("smaller" ++ "than") ;
  Divisible = ss ("divisible" ++ "by") ;
 
-- replies

lin
  Yes = ss "yes" ;
  No = ss "no" ;

  None = ss "none" ;
  List xs = xs ;
  One n = n ;
  Cons = cc2 ;

-- general moves

lin 
  Quit = ss "quit" ;
  Bye = ss "bye" ;
}