-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grammar.cf
74 lines (65 loc) · 1.94 KB
/
Grammar.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
entrypoints Defs;
comment "--";
comment "{-" "-}";
layout "let";
layout stop "in";
layout toplevel;
Defs. Defs ::= [Def];
Def. Def ::= PIdent [Arg] "=" Expr;
DefType. Def ::= PIdent ":" Expr;
separator Def ";";
Let. Expr ::= "let" "{" [Def] "}" "in" Expr;
Lam. Expr ::= PLam [Binder] "->" Expr;
Arr. Expr1 ::= Expr2 "->" Expr1;
Pi. Expr1 ::= [TypedVar] "->" Expr1;
Prod. Expr2 ::= Expr3 "*" Expr2;
Sigma. Expr2 ::= [TypedVar] "*" Expr2;
Over. Expr3 ::= Expr4 "|" Expr3;
Id. Expr4 ::= Expr5 "=" Expr5;
Pair. Expr5 ::= Expr5 "," Expr6;
Pmap. Expr6 ::= Expr6 "<*>" Expr7;
App. Expr7 ::= Expr7 Expr8;
Var. Expr8 ::= Arg;
Nat. Expr8 ::= PNat;
Suc. Expr8 ::= PSuc;
Rec. Expr8 ::= PR;
Idp. Expr8 ::= PIdp;
Coe. Expr8 ::= PCoe;
Proj1. Expr8 ::= PProjl;
Proj2. Expr8 ::= PProjr;
Pcon. Expr8 ::= Ppcon;
Iso. Expr8 ::= PIso;
NatConst. Expr8 ::= PInt;
Universe. Expr8 ::= U;
_. Expr ::= Expr1;
_. Expr1 ::= Expr2;
_. Expr2 ::= Expr3;
_. Expr3 ::= Expr4;
_. Expr4 ::= Expr5;
_. Expr5 ::= Expr6;
_. Expr6 ::= Expr7;
_. Expr7 ::= Expr8;
Paren. Expr8 ::= PPar Expr ")";
Arg. Arg ::= PIdent;
NoArg. Arg ::= Pus;
terminator Arg "";
-- Like Arg, but cannot be empty
Binder. Binder ::= Arg;
separator nonempty Binder "";
TypedVar. TypedVar ::= PPar Expr ":" Expr ")";
terminator nonempty TypedVar "";
position token U ('T' 'y' 'p' 'e' digit*);
position token PLam '\\';
position token PPar '(';
position token PInt digit+;
position token PIdp 'i' 'd' 'p';
position token PR 'R';
position token PSuc 's' 'u' 'c';
position token PNat 'N' 'a' 't';
position token Pus '_';
position token PCoe 'c' 'o' 'e';
position token Ppcon 'p' 'c' 'o' 'n';
position token PProjl 'p' 'r' 'o' 'j' '1';
position token PProjr 'p' 'r' 'o' 'j' '2';
position token PIso 'i' 's' 'o';
position token PIdent (letter(letter|digit|'\''|'_')*);