summaryrefslogtreecommitdiff
path: root/examples/tutorial/semantics/BaseEng.gf
blob: 582c2e279eb99ea54f5b529b01ac9dee73752530 (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
53
54
55
56
57
--# -path=.:prelude

concrete BaseEng of Base = open Prelude in {

flags lexer=literals ; unlexer=text ;

-- English concrete syntax; greatly simplified - just for demo purposes

lin 
  PredAP  = infixSS "is" ;

  ComplA2 = cc2 ;

  ModCN   = cc2 ;

  ConjS  c = infixSS c.s ;
  ConjAP c = infixSS c.s ;
  ConjNP c = infixSS c.s ;

  UsePN a = a ;
  Every = prefixSS "every" ;
  Some  = prefixSS "some" ;
  None  = prefixSS "no" ;

  And = ss "and" ;
  Or  = ss "or" ;

  UseInt n = n ;

  Number = ss "number" ;

  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") ;
 
  Sum     = prefixSS ["the sum of"] ;
  Product = prefixSS ["the product of"] ;
  GCD     = prefixSS ["the greatest common divisor of"] ;

  WhatIs = prefixSS ["what is"] ;
  WhichAre cn ap = ss ("which" ++ cn.s ++ "is" ++ ap.s) ; ---- are
  QuestS s = s ; ---- inversion

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

  Value np = np ;
  Many list = list ;

  BasePN = infixSS "and" ;
  ConsPN = infixSS "," ;
  
}