-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_parser.cmyacc
204 lines (172 loc) · 6.2 KB
/
make_parser.cmyacc
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
sml
name MakeParser
terminal LOWER_IDENT of string
terminal UPPER_IDENT of string
terminal QUOTE_IDENT of string
terminal NUMBER of int
terminal ONE
terminal CAP_TYPE
terminal CAP_EXT
terminal CAP_PI
terminal CAP_SIGMA
terminal S
terminal FUN
terminal FST
terminal SND
terminal FORALL
terminal EXIST
terminal POLY
terminal PACK
terminal UNPACK
terminal AS
terminal IN
terminal FIX
terminal LET
terminal CIRC
terminal RET
terminal BIND
terminal BOOL
terminal INT
terminal IF
terminal THEN
terminal ELSE
terminal LPAREN
terminal RPAREN
terminal LBRACK
terminal RBRACK
terminal LWHITEPAREN
terminal RWHITEPAREN
terminal LWHITEANGLE
terminal RWHITEANGLE
terminal COLON
terminal SEAL
terminal RARROW precr 20
terminal LARROW
terminal STAR precr 30
terminal EQUAL
terminal SLASH
terminal DOT
terminal COMMA
nonterminal Program : program =
1:Module => program_module
nonterminal Module : module =
1:ModuleApp => module_app
CIRC 1:LaxModule => mcirc
FUN 1:ModuleParams RARROW 2:Module => mabs
LET 1:LOWER_IDENT EQUAL 2:Term IN 3:Module => mlet
LET 1:TVarSlOpt 2:UPPER_IDENT EQUAL 3:Module IN 4:Module => mletmodule
nonterminal ModuleParams : module_params =
/* empty */ => empty_module_params
LPAREN 1:TVarSlOpt 2:UPPER_IDENT COLON 3:Sig RPAREN 4:ModuleParams => cons_module_params
nonterminal ModuleApp : module =
1:ModuleAtom => module_atom
1:ModuleApp 2:ModuleAtom => mapp
FST 1:ModuleAtom => mfst
SND 1:ModuleAtom => msnd
nonterminal ModuleAtom : module =
LPAREN 1:Module RPAREN => module_paren
1:UPPER_IDENT => mvar
LPAREN RPAREN => mstar
LWHITEPAREN 1:Type RWHITEPAREN => mstatic
LWHITEANGLE 1:Term RWHITEANGLE => mdynamic
LPAREN 1:Module COMMA 2:Module RPAREN => mpair
nonterminal LaxModule : lax_module =
RET 1:Module => lret
1:ModuleApp SEAL 2:Sig => lseal
BIND 1:TVarSlOpt 2:UPPER_IDENT LARROW 3:Module IN 4:LaxModule => lbind
UNPACK LBRACK 1:TVar COMMA 2:LOWER_IDENT RBRACK EQUAL 3:Term IN 4:LaxModule => lunpack
nonterminal Sig : sign =
1:SigBin => sig_id
CAP_PI 1:TVar COLON 2:Sig DOT 3:Sig => sarrow
CAP_SIGMA 1:TVar COLON 2:Sig DOT 3:Sig => sprod
nonterminal SigBin : sign =
1:SigApp => sig_id
1:SigBin RARROW 2:SigBin => sarrow_degenerate
1:SigBin STAR 2:SigBin => sprod_degenerate
nonterminal SigApp : sign =
1:SigAtom => sig_id
CIRC 1:PosSigApp => smonad
nonterminal SigAtom : sign =
ONE => sunit
LPAREN 1:Sig RPAREN => sig_id
LWHITEPAREN 1:Kind RWHITEPAREN => sstatic
LWHITEANGLE 1:Type RWHITEANGLE => sdynamic
nonterminal Exists : existentials =
/* empty */ => exists_nil
EXIST 1:TVar COLON 2:Kind DOT 3:Exists => exists_cons
nonterminal PosSigApp : pos_sig =
1:SigApp => pdown /* We omit explicit down-shift. */
LPAREN EXIST 1:TVar COLON 2:Kind DOT 3:Exists 4:Sig RPAREN => pexist
nonterminal TVar : tvar =
1:QUOTE_IDENT => quote_ident
nonterminal TVarSlOpt : tvar_opt =
/* empty */ => tvar_none
1:TVar SLASH => tvar_some
nonterminal Type : tycon =
1:TypeBin => type_bin
FUN 1:TypeParams RARROW 2:Type => tabs
FORALL 1:TVar COLON 2:Kind DOT 3:Type => tforall
1:Exist => texist
nonterminal TypeParams : type_params =
/* empty */ => empty_type_params
LPAREN 1:TVar COLON 2:Kind RPAREN 3:TypeParams => cons_type_params
nonterminal Exist : existential =
EXIST 1:TVar COLON 2:Kind DOT 3:Type => exist
nonterminal TypeBin : tycon =
1:TypeApp => type_app
1:TypeBin RARROW 2:TypeBin => tarrow
1:TypeBin STAR 2:TypeBin => tprod
nonterminal TypeApp : tycon =
1:TypeAtom => type_atom
1:TypeApp 2:TypeAtom => tapp
FST 1:TypeAtom => tfst
SND 1:TypeAtom => tsnd
nonterminal TypeAtom : tycon =
LPAREN 1:Type RPAREN => type_paren
1:TVar => tvar_
LPAREN RPAREN => tstar
LPAREN 1:Type COMMA 2:Type RPAREN => tpair
ONE => tunit
BOOL => tbool
INT => tint
nonterminal Kind : kind =
1:KindBin => kind_id
S LPAREN 1:Type RPAREN => ksingleton
CAP_PI 1:TVar COLON 2:Kind DOT 3:Kind => karrow
CAP_SIGMA 1:TVar COLON 2:Kind DOT 3:Kind => kprod
nonterminal KindBin : kind =
1:KindAtom => kind_id
1:KindBin RARROW 2:KindBin => karrow_degenerate
1:KindBin STAR 2:KindBin => kprod_degenerate
nonterminal KindAtom : kind =
ONE => kunit
CAP_TYPE => ktype
LPAREN 1:Kind RPAREN => kind_id
nonterminal Term : term =
1:TermApp => term_id
FUN 1:TermParams RARROW 2:Term => eabs
POLY LPAREN 1:TVar COLON 2:Kind RPAREN RARROW 3:Term => egen
PACK LBRACK 1:Type COMMA 2:Term RBRACK AS 3:Exist => epack
LET 1:LOWER_IDENT EQUAL 2:Term IN 3:Term => elet
LET 1:TVarSlOpt 2:UPPER_IDENT EQUAL 3:LaxModule IN 4:Term => eletlax
IF 1:Term THEN 2:Term ELSE 3:Term => eif
UNPACK LBRACK 1:TVar COMMA 2:LOWER_IDENT RBRACK EQUAL 3:Term IN 4:Term => eunpack
nonterminal TermParams : term_params =
/* empty */ => empty_term_params
LPAREN 1:LOWER_IDENT COLON 2:Type RPAREN 3:TermParams => cons_term_params
nonterminal TermApp : term =
1:TermAtom => term_id
1:TermApp 2:TermAtom => eapp
FST 1:TermAtom => efst
SND 1:TermAtom => esnd
1:TermApp LBRACK 2:Type RBRACK => einst
FIX LBRACK 1:Type RBRACK 2:TermAtom => efix
CAP_EXT 1:ModuleAtom => eext
nonterminal TermAtom : term =
LPAREN 1:Term RPAREN => term_id
1:LOWER_IDENT => evar
LPAREN RPAREN => estar
LPAREN 1:Term COMMA 2:Term RPAREN => epair
1:NUMBER => enum
ONE => eone
start Program