-
Notifications
You must be signed in to change notification settings - Fork 6
/
Core.cf
56 lines (44 loc) · 1.42 KB
/
Core.cf
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
--- Input file to BNF Converter
--- This describes the labelled BNF Grammar of
--- Mini-TT concrete syntax
-- Expressions
ELam. Exp1 ::= "\\" Patt1 "." Exp1 ;
ESet. Exp3 ::= "U" ;
EPi. Exp1 ::= "Pi" Patt1 ":" Exp1 "." Exp1 ;
ESig. Exp1 ::= "Sig" Patt1 ":" Exp1 "." Exp1 ;
EOne. Exp3 ::= "1";
Eunit. Exp3 ::= "0";
EPair. Exp ::= Exp1 "," Exp ;
ECon. Exp2 ::= "$" Ident Exp3;
EData. Exp1 ::= DataTk "(" [Summand] ")" ;
ECase. Exp1 ::= CaseTk "(" [Branch] ")" ;
EFst. Exp3 ::= Exp3 ".1" ;
ESnd. Exp3 ::= Exp3 ".2" ;
EApp. Exp2 ::= Exp2 Exp3 ;
EVar. Exp3 ::= Ident ;
EVoid. Exp3 ::= "Void" ;
EDec. Exp1 ::= Decl ";" Exp1 ;
EPN. Exp3 ::= "PN" ;
-- syntax sugars
eArrow. Exp1 ::= Exp2 "->" Exp1 ;
eTimes. Exp1 ::= Exp2 "*" Exp1 ;
define eArrow a b = EPi Punit a b ;
define eTimes a b = ESig Punit a b ;
coercions Exp 3 ;
-- declarations
Def. Decl ::= "let" Patt1 ":" Exp1 "=" Exp1 ;
Drec. Decl ::= "letrec" Patt1 ":" Exp1 "=" Exp1 ;
-- patterns
PPair. Patt ::= Patt1 "," Patt ;
Punit. Patt1 ::= "_" ;
PVar. Patt1 ::= Ident ;
coercions Patt 1 ;
Summand. Summand ::= Ident Exp3;
separator Summand "|" ;
Branch. Branch ::= Ident "->" Exp1 ;
separator Branch "|" ;
comment "--" ;
comment "{-" "-}" ;
separator nonempty Ident "" ;
position token CaseTk {"fun"} ;
position token DataTk {"Sum"} ;