-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_parser.cmyacc
198 lines (164 loc) · 4.93 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
sml
name MakeParser
terminal LOWER_IDENT of string
terminal UPPER_IDENT of string
terminal QUOTE_IDENT of string
terminal NUMBER of int
terminal CAP_TYPE
terminal FUN
terminal IN
terminal LET
terminal SEALS
terminal LINK
terminal WITH
terminal VAL
terminal TYPE
terminal UNIT
terminal MODULE
terminal NEW
terminal EXT
terminal BOOL
terminal INT
terminal TRUE
terminal FALSE
terminal MATCH
terminal DATA
terminal IMPORT
terminal EXPORT
terminal LPAREN
terminal RPAREN
terminal LBRACK
terminal RBRACK
terminal LBRACE
terminal RBRACE
terminal COLON
terminal RARROW precr 20
terminal RDARROW
terminal STAR
terminal EQUAL
terminal DOT
terminal COMMA
terminal MINUS
terminal PLUS
terminal UNDERSCORE
terminal BAR
nonterminal Module : module =
1:ModuleProj => module_id
NEW 1:ModuleProj => mnew
LINK 1:ModVar EQUAL 2:Module WITH 3:Module => mlink
LINK 1:ModVar EQUAL 2:Module SEALS 3:Module => mseal
LINK 1:Module WITH 2:Module => mlink_novar
LINK 1:Module SEALS 2:Module => mseal_novar
nonterminal ModuleProj : module =
1:ModuleAtom => module_id
1:ModuleProj DOT 2:Label => mproj
nonterminal ModuleAtom : module =
LPAREN 1:Module RPAREN => module_id
1:ModVar => mvar
LBRACE RBRACE => empty_module
LBRACK VAL 1:Exp RBRACK => exp_export
LBRACK VAL COLON 1:Type RBRACK => exp_import
LBRACK TYPE 1:Type RBRACK => type_export
LBRACK TYPE COLON 1:Kind RBRACK => type_import
LBRACK UNIT 1:Module RBRACK => unit_export
LBRACK UNIT COLON 1:USig RBRACK => unit_import
LBRACE 1:Dec RBRACE => module_id
nonterminal Dec : module =
MODULE 1:Label EQUAL 2:Module => minj
TYPE 1:Label EQUAL 2:Type => mtype_binding
TYPE 1:Label COLON 2:Kind => mtype_spec
VAL 1:Label EQUAL 2:Exp => mval_binding
VAL 1:Label COLON 2:Type => mval_spec
UNIT 1:Label EQUAL 2:Module => munit_binding
UNIT 1:Label COLON 2:USig => munit_spec
DATA 1:Label COLON 2:Type => mdata_spec
DATA 1:Label EQUAL 2:Type => mdata_binding
nonterminal USig : usig =
1:ModuleProj IMPORT LPAREN 2:Paths RPAREN => usig_import
1:ModuleProj EXPORT LPAREN 2:Paths RPAREN => usig_export
nonterminal Paths : paths =
1:Path => paths1
1:Path COMMA 2:Paths => paths_cons
nonterminal Path : path =
1:Label => path_label
1:Label DOT 2:Path => path_cons
nonterminal ModVar : modvar =
1:UPPER_IDENT => mvar_upper
1:LOWER_IDENT => mvar_lower
nonterminal Label : label =
1:UPPER_IDENT => label_upper
1:LOWER_IDENT => label_lower
nonterminal Exp : exp =
1:ExpApp => exp_id
FUN 1:Params1 RARROW 2:Exp => eabs
1:Con 2:ExpAtom COLON 3:Type => econ
nonterminal ExpApp : exp =
1:ExpAtom => exp_id
EXT 1:ModuleProj => emodule
1:ExpApp 2:ExpAtom => eapp
MATCH 1:Exp RDARROW LBRACE OptBar 2:Branch 3:Branches RBRACE => ematch
nonterminal ExpAtom : exp =
TRUE => etrue
FALSE => efalse
1:NUMBER => eint
1:LOWER_IDENT => evar
LPAREN RPAREN => eunit
LPAREN 1:ExpTuple RPAREN => etuple
nonterminal ExpTuple : exps =
1:Exp => exps1
1:Exp COMMA 2:ExpTuple => exps_cons
nonterminal Params1 : params =
1:Param => params1
1:Param 2:Params1 => params_cons
nonterminal Param : param =
LPAREN 1:Pat COLON 2:Type RPAREN => param1
nonterminal Pat : pattern =
1:PatAtom => pattern_id
1:Con 2:PatAtom => pcon
nonterminal PatAtom : pattern =
1:LOWER_IDENT => pvar
UNDERSCORE => pwildcard
LPAREN RPAREN => punit
LPAREN 1:PatTuple RPAREN => ptuple
TRUE => ptrue
FALSE => pfalse
nonterminal PatTuple : patterns =
1:Pat => patterns1
1:Pat COMMA 2:PatTuple => patterns_cons
nonterminal OptBar : none =
/* empty */ => none_id
BAR => none_id
nonterminal Branch : branch =
1:Pat RDARROW 2:Exp => branch1
nonterminal Branches : branches =
/* empty */ => branches_nil
BAR 1:Branch 2:Branches => branches_cons
nonterminal Type : ty =
1:TypeTuple => ttuple
FUN LPAREN 1:TVar COLON 2:Kind RPAREN RARROW 3:Type => tabs
1:Type RARROW 2:Type => tarrow
nonterminal TypeTuple : types =
1:TypeApp => ttuple1
1:TypeApp STAR 2:TypeTuple => ttuple_cons
nonterminal TypeApp : ty =
1:TypeAtom => type_id
EXT 1:ModuleProj => tmodule
1:TypeApp 2:TypeAtom => tapp
nonterminal TypeAtom : ty =
LPAREN 1:Type RPAREN => type_id
1:TVar => tvar
BOOL => tbool
INT => tint
UNIT => tunit
LBRACK 1:Sum RBRACK => tsum
nonterminal TVar : type_var =
1:QUOTE_IDENT => quote_tvar
nonterminal Sum : sum =
1:Con COLON 2:Type => sum1
1:Con COLON 2:Type COMMA 3:Sum => sum_cons
nonterminal Con : con =
1:UPPER_IDENT => con_upper
nonterminal Kind : kind =
CAP_TYPE => kbase
1:Kind RARROW 2:Kind => karrow
start Module