-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_token.mly
83 lines (63 loc) · 2.36 KB
/
parser_token.mly
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
75
76
77
78
79
80
81
82
83
%{
open Ast.Raw
let locate = Location.locate
let relocate = Location.relocate
let dummy_locate = Location.dummy_locate
let mkPi_binding (_startpos,x,k) k' =
Pi(Some x.Location.content, k.Location.content, k')
let rec mkPi_bindings bs t = match bs with
| [] -> t
| b :: bs -> mkPi_binding b (mkPi_bindings bs t)
let mkArrow k k' = Pi(None, k, k')
let mkLam_binding (_startpos,x,k) t = locate (Lam(x, k, t))
let rec mkLam_bindings bs t endpos = match bs with
| [] -> t
| (startpos, _, _) as b :: bs ->
mkLam_binding b (mkLam_bindings bs t endpos) startpos endpos
let mkForall_binding (_startpos,x,k) t = locate (BaseForall(x, k, t))
let rec mkForall_bindings bs t endpos = match bs with
| [] -> t
| (startpos, _, _) as b :: bs ->
mkForall_binding b (mkForall_bindings bs t endpos) startpos endpos
let mkExists_binding (_startpos,x,k) t = locate (BaseExists(x, k, t))
let rec mkExists_bindings bs t endpos = match bs with
| [] -> t
| (startpos, _, _) as b :: bs ->
mkExists_binding b (mkExists_bindings bs t endpos) startpos endpos
let mkTeLam_binding (x,tau) t = locate (TeLam(x, tau, t))
let mkTeGen_binding (_startpos,x,k) t = locate (TeGen(x, k, t))
let rec mkTeGen_bindings bs t endpos = match bs with
| [] -> t
| (startpos, _, _) as b :: bs ->
mkTeGen_binding b (mkTeGen_bindings bs t endpos) startpos endpos
type mixed_binding =
| TeBind of Lexing.position * string Location.located * typ
| TyBind of
Lexing.position * string Location.located * (typ kind) Location.located
let rec mkTe_mixed_bindings b e endpos = match b with
| [] -> e
| TeBind(startpos, x, t) :: b ->
mkTeLam_binding (x, t) (mkTe_mixed_bindings b e endpos) startpos endpos
| TyBind(startpos, a, k) :: b ->
mkTeGen_binding (startpos, a, k)
(mkTe_mixed_bindings b e endpos) startpos endpos
let rec mkTy_mixed_bindings b e endpos = match b with
| [] -> e
| TeBind(startpos, _x, t) :: b ->
locate (BaseArrow (t, mkTy_mixed_bindings b e endpos)) startpos endpos
| TyBind(startpos, a, k) :: b ->
mkForall_binding (startpos, a, k)
(mkTy_mixed_bindings b e endpos) startpos endpos
%}
%token EOF
%token IMPORT EXPORT
%token STAR DBLARROW
%token LPAR RPAR DBLCOLON FORALL EXISTS COMMA ARROW
%token LET IN REC UPLAMBDA LAMBDA
%token SIGMA NU OPEN
%token LANGLE RANGLE DOT
%token SINGLE PI
%token COLON RBRACE LBRACE EQ RBRACKET LBRACKET
%token VAL TYPE AS
%token <string> ID
%%