yukigo-haskell-parser 0.1.3 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +3 -3
- package/CHANGELOG.md +51 -9
- package/README.md +5 -5
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/parser/grammar.cjs +397 -0
- package/dist/parser/grammar.cjs.map +1 -0
- package/dist/parser/grammar.d.cts +38 -0
- package/dist/parser/lexer.d.ts +2 -1
- package/dist/parser/lexer.js +6 -1
- package/dist/parser/lexer.js.map +1 -1
- package/dist/prelude.js +279 -279
- package/dist/typechecker/DeclarationCollector.d.ts +2 -0
- package/dist/typechecker/DeclarationCollector.js +6 -5
- package/dist/typechecker/DeclarationCollector.js.map +1 -1
- package/dist/typechecker/TypeBuilder.js +9 -7
- package/dist/typechecker/TypeBuilder.js.map +1 -1
- package/dist/typechecker/checker.d.ts +9 -4
- package/dist/typechecker/checker.js +66 -94
- package/dist/typechecker/checker.js.map +1 -1
- package/dist/typechecker/core.js +8 -7
- package/dist/typechecker/core.js.map +1 -1
- package/dist/typechecker/inference.d.ts +4 -1
- package/dist/typechecker/inference.js +39 -19
- package/dist/typechecker/inference.js.map +1 -1
- package/dist/utils/helpers.d.ts +3 -0
- package/dist/utils/helpers.js +5 -0
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/types.d.ts +12 -3
- package/dist/utils/types.js +34 -22
- package/dist/utils/types.js.map +1 -1
- package/package.json +6 -9
- package/src/index.ts +223 -192
- package/src/parser/{grammar.ts → grammar.cjs} +191 -223
- package/src/parser/grammar.d.ts +3 -0
- package/src/parser/grammar.ne +521 -518
- package/src/parser/lexer.ts +357 -353
- package/src/prelude.ts +281 -281
- package/src/typechecker/DeclarationCollector.ts +160 -157
- package/src/typechecker/TypeBuilder.ts +153 -150
- package/src/typechecker/checker.ts +487 -501
- package/src/typechecker/core.ts +195 -192
- package/src/typechecker/inference.ts +1442 -1421
- package/src/utils/helpers.ts +34 -29
- package/src/utils/types.ts +75 -63
- package/tests/hspec.spec.ts +95 -92
- package/tests/lexer.spec.ts +175 -175
- package/tests/parser.spec.ts +838 -829
- package/tests/prelude.spec.ts +17 -17
- package/tests/typechecker.spec.ts +326 -327
- package/tsconfig.build.json +16 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +29 -26
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/parser/grammar.d.ts +0 -28
- package/dist/parser/grammar.js +0 -393
- package/dist/parser/grammar.js.map +0 -1
package/src/parser/grammar.ne
CHANGED
|
@@ -1,519 +1,522 @@
|
|
|
1
|
-
@{%
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
TypeCast,
|
|
5
|
-
Application,
|
|
6
|
-
ConsExpression,
|
|
7
|
-
StringOperation,
|
|
8
|
-
LogicalBinaryOperation,
|
|
9
|
-
ComparisonOperation,
|
|
10
|
-
ArithmeticBinaryOperation,
|
|
11
|
-
Print,
|
|
12
|
-
ListBinaryOperation,
|
|
13
|
-
ListUnaryOperation,
|
|
14
|
-
ArithmeticUnaryOperation,
|
|
15
|
-
LogicalUnaryOperation,
|
|
16
|
-
Case,
|
|
17
|
-
SymbolPrimitive,
|
|
18
|
-
ListPrimitive,
|
|
19
|
-
Switch,
|
|
20
|
-
CompositionExpression,
|
|
21
|
-
Lambda,
|
|
22
|
-
TupleExpression,
|
|
23
|
-
DataExpression,
|
|
24
|
-
Function,
|
|
25
|
-
FieldExpression,
|
|
26
|
-
If,
|
|
27
|
-
Record,
|
|
28
|
-
Constructor,
|
|
29
|
-
Field,
|
|
30
|
-
ListComprehension,
|
|
31
|
-
Generator,
|
|
32
|
-
RangeExpression,
|
|
33
|
-
TypeSignature,
|
|
34
|
-
Return,
|
|
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
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
@lexer HSLexer
|
|
82
|
-
|
|
83
|
-
program -> declaration (";" declaration):* ";":? {% (d) => [d[0], ...d[1].map(x => x[1])].flat(Infinity) %}
|
|
84
|
-
|
|
85
|
-
declaration -> (function_declaration
|
|
86
|
-
| function_signature
|
|
87
|
-
| type_declaration
|
|
88
|
-
| data_declaration
|
|
89
|
-
| typeclass_declaration
|
|
90
|
-
| instance_declaration
|
|
91
|
-
| apply_operator
|
|
92
|
-
| test_declaration
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"describe" expression "do" %lbracket test_body %rbracket {% (d) => new TestGroup(d[1], new Sequence(d[
|
|
106
|
-
| "
|
|
107
|
-
| "it" expression "do" %lbracket test_body %rbracket {% (d) => new Test(d[1], new Sequence(d[
|
|
108
|
-
| "
|
|
109
|
-
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
expression "shouldBe" expression {% (d) => new Assert(new BooleanPrimitive(false), new Equality(d[
|
|
117
|
-
| expression "
|
|
118
|
-
| expression "shouldNotBe" expression {% (d) => new Assert(new BooleanPrimitive(true), new Equality(d[
|
|
119
|
-
| expression "
|
|
120
|
-
| expression "shouldSatisfy" expression {% (d) => new Assert(new BooleanPrimitive(false), new Truth(new Application(d[
|
|
121
|
-
| expression "
|
|
122
|
-
| expression "shouldThrow" expression {% (d) => new Assert(new BooleanPrimitive(false), new Failure(d[0], d[
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
apply_operator
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
bind_expression
|
|
138
|
-
logical_expression "
|
|
139
|
-
| logical_expression
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
logical_expression
|
|
144
|
-
comparison "
|
|
145
|
-
| comparison
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
cons_expression
|
|
155
|
-
concatenation
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
concatenation
|
|
159
|
-
addition
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
addition
|
|
164
|
-
addition "
|
|
165
|
-
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
multiplication
|
|
170
|
-
multiplication "
|
|
171
|
-
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
power
|
|
176
|
-
unary_negation "
|
|
177
|
-
| unary_negation "
|
|
178
|
-
| unary_negation
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
unary_negation
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
index_access
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
composition_expression
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
infix_operator_expression
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
| "
|
|
212
|
-
| "
|
|
213
|
-
| "
|
|
214
|
-
| "
|
|
215
|
-
| "
|
|
216
|
-
| "
|
|
217
|
-
| "
|
|
218
|
-
| "
|
|
219
|
-
| "
|
|
220
|
-
| "
|
|
221
|
-
| "
|
|
222
|
-
| "
|
|
223
|
-
| "
|
|
224
|
-
| "
|
|
225
|
-
| "
|
|
226
|
-
| "
|
|
227
|
-
| "
|
|
228
|
-
| "
|
|
229
|
-
| ".
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
|
|
|
251
|
-
|
|
|
252
|
-
|
|
|
253
|
-
|
|
|
254
|
-
|
|
|
255
|
-
|
|
|
256
|
-
|
|
|
257
|
-
| "
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
constr
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
bindings_list
|
|
348
|
-
function_declaration
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
return new Equation(d[0],
|
|
358
|
-
|
|
359
|
-
| params %assign return_expression where_clause:? {%
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
"
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
|
397
|
-
|
|
|
398
|
-
|
|
399
|
-
|
|
|
400
|
-
|
|
401
|
-
wildcard_pattern
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
#
|
|
419
|
-
#
|
|
420
|
-
#
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (
|
|
461
|
-
return d[2];
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
simple_type
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
| "
|
|
503
|
-
| "
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
1
|
+
@{%
|
|
2
|
+
const { HaskellLayoutLexer } = require("./lexer.js")
|
|
3
|
+
const {
|
|
4
|
+
TypeCast,
|
|
5
|
+
Application,
|
|
6
|
+
ConsExpression,
|
|
7
|
+
StringOperation,
|
|
8
|
+
LogicalBinaryOperation,
|
|
9
|
+
ComparisonOperation,
|
|
10
|
+
ArithmeticBinaryOperation,
|
|
11
|
+
Print,
|
|
12
|
+
ListBinaryOperation,
|
|
13
|
+
ListUnaryOperation,
|
|
14
|
+
ArithmeticUnaryOperation,
|
|
15
|
+
LogicalUnaryOperation,
|
|
16
|
+
Case,
|
|
17
|
+
SymbolPrimitive,
|
|
18
|
+
ListPrimitive,
|
|
19
|
+
Switch,
|
|
20
|
+
CompositionExpression,
|
|
21
|
+
Lambda,
|
|
22
|
+
TupleExpression,
|
|
23
|
+
DataExpression,
|
|
24
|
+
Function,
|
|
25
|
+
FieldExpression,
|
|
26
|
+
If,
|
|
27
|
+
Record,
|
|
28
|
+
Constructor,
|
|
29
|
+
Field,
|
|
30
|
+
ListComprehension,
|
|
31
|
+
Generator,
|
|
32
|
+
RangeExpression,
|
|
33
|
+
TypeSignature,
|
|
34
|
+
Return,
|
|
35
|
+
GuardedExpression,
|
|
36
|
+
Guard,
|
|
37
|
+
Equation,
|
|
38
|
+
Raise,
|
|
39
|
+
UnguardedBody,
|
|
40
|
+
Sequence,
|
|
41
|
+
Otherwise,
|
|
42
|
+
WildcardPattern,
|
|
43
|
+
ConsPattern,
|
|
44
|
+
VariablePattern,
|
|
45
|
+
LiteralPattern,
|
|
46
|
+
AsPattern,
|
|
47
|
+
ConstructorPattern,
|
|
48
|
+
ListPattern,
|
|
49
|
+
TuplePattern,
|
|
50
|
+
TypeAlias,
|
|
51
|
+
ParameterizedType,
|
|
52
|
+
Constraint,
|
|
53
|
+
TypeApplication,
|
|
54
|
+
LetInExpression,
|
|
55
|
+
SimpleType,
|
|
56
|
+
ListType,
|
|
57
|
+
TupleType,
|
|
58
|
+
TypeClass,
|
|
59
|
+
Instance,
|
|
60
|
+
NumberPrimitive,
|
|
61
|
+
CharPrimitive,
|
|
62
|
+
StringPrimitive,
|
|
63
|
+
BooleanPrimitive,
|
|
64
|
+
SourceLocation,
|
|
65
|
+
TestGroup,
|
|
66
|
+
Test,
|
|
67
|
+
Assert,
|
|
68
|
+
Equality,
|
|
69
|
+
Truth,
|
|
70
|
+
Failure
|
|
71
|
+
} = require("yukigo-ast");
|
|
72
|
+
|
|
73
|
+
const filter = d => {
|
|
74
|
+
return d.filter((token) => token !== null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const loc = (token) => new SourceLocation(token.line, token.col);
|
|
78
|
+
const HSLexer = new HaskellLayoutLexer();
|
|
79
|
+
|
|
80
|
+
%}
|
|
81
|
+
@lexer HSLexer
|
|
82
|
+
|
|
83
|
+
program -> declaration (";" declaration):* ";":? {% (d) => [d[0], ...d[1].map(x => x[1])].flat(Infinity) %}
|
|
84
|
+
|
|
85
|
+
declaration -> (function_declaration
|
|
86
|
+
| function_signature
|
|
87
|
+
| type_declaration
|
|
88
|
+
| data_declaration
|
|
89
|
+
| typeclass_declaration
|
|
90
|
+
| instance_declaration
|
|
91
|
+
| apply_operator
|
|
92
|
+
| test_declaration) {% (d) => d[0][0] %}
|
|
93
|
+
|
|
94
|
+
expression ->
|
|
95
|
+
(type_cast
|
|
96
|
+
| letin_expression
|
|
97
|
+
| if_expression
|
|
98
|
+
| case_expression
|
|
99
|
+
| test_declaration) {% (d) => d[0][0] %}
|
|
100
|
+
|
|
101
|
+
# Test rules
|
|
102
|
+
|
|
103
|
+
test_declaration ->
|
|
104
|
+
"describe" expression "do" %lbracket test_body %rbracket {% (d) => new TestGroup(d[1], new Sequence(d[4])) %}
|
|
105
|
+
| "describe" expression "$" "do" %lbracket test_body %rbracket {% (d) => new TestGroup(d[1], new Sequence(d[5])) %}
|
|
106
|
+
| "it" expression "do" %lbracket test_body %rbracket {% (d) => new Test(d[1], new Sequence(d[4])) %}
|
|
107
|
+
| "it" expression "$" "do" %lbracket test_body %rbracket {% (d) => new Test(d[1], new Sequence(d[5])) %}
|
|
108
|
+
| "let" %lbracket function_declaration %rbracket {% (d) => d[2] %}
|
|
109
|
+
| assertion {% id %}
|
|
110
|
+
|
|
111
|
+
test_body ->
|
|
112
|
+
test_declaration (";" test_declaration):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
113
|
+
|
|
114
|
+
assertion ->
|
|
115
|
+
expression "shouldBe" expression {% (d) => new Assert(new BooleanPrimitive(false), new Equality(d[2], d[0])) %}
|
|
116
|
+
| expression "`" "shouldBe" "`" expression {% (d) => new Assert(new BooleanPrimitive(false), new Equality(d[4], d[0])) %}
|
|
117
|
+
| expression "shouldNotBe" expression {% (d) => new Assert(new BooleanPrimitive(true), new Equality(d[2], d[0])) %}
|
|
118
|
+
| expression "`" "shouldNotBe" "`" expression {% (d) => new Assert(new BooleanPrimitive(true), new Equality(d[4], d[0])) %}
|
|
119
|
+
| expression "shouldSatisfy" expression {% (d) => new Assert(new BooleanPrimitive(false), new Truth(new Application(d[2], d[0]))) %}
|
|
120
|
+
| expression "`" "shouldSatisfy" "`" expression {% (d) => new Assert(new BooleanPrimitive(false), new Truth(new Application(d[4], d[0]))) %}
|
|
121
|
+
| expression "shouldThrow" expression {% (d) => new Assert(new BooleanPrimitive(false), new Failure(d[0], d[2])) %}
|
|
122
|
+
| expression "`" "shouldThrow" "`" expression {% (d) => new Assert(new BooleanPrimitive(false), new Failure(d[0], d[4])) %}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
type_cast -> apply_operator "::" type {% (d) => new TypeCast(d[0], d[2]) %}
|
|
126
|
+
| apply_operator {% id %}
|
|
127
|
+
|
|
128
|
+
# Operation rules
|
|
129
|
+
|
|
130
|
+
# priority 0
|
|
131
|
+
apply_operator ->
|
|
132
|
+
bind_expression ("$" | "$!") apply_operator {% (d) => new Application(d[0], d[2]) %}
|
|
133
|
+
| bind_expression {% id %}
|
|
134
|
+
|
|
135
|
+
# priority 1
|
|
136
|
+
bind_expression ->
|
|
137
|
+
logical_expression ">>=" bind_expression {% (d) => new Application(new Application(new SymbolPrimitive("(>>=)"), d[0]), d[2]) %}
|
|
138
|
+
| logical_expression ">>" bind_expression {% (d) => new Application(new Application(new SymbolPrimitive("(>>)"), d[0]), d[2]) %}
|
|
139
|
+
| logical_expression {% id %}
|
|
140
|
+
|
|
141
|
+
# priority 3
|
|
142
|
+
logical_expression ->
|
|
143
|
+
comparison "&&" logical_expression {% (d) => new LogicalBinaryOperation("And", d[0], d[2]) %}
|
|
144
|
+
| comparison "||" logical_expression {% (d) => new LogicalBinaryOperation("Or", d[0], d[2]) %}
|
|
145
|
+
| comparison {% id %}
|
|
146
|
+
|
|
147
|
+
# priority 4
|
|
148
|
+
comparison ->
|
|
149
|
+
cons_expression comparison_operator cons_expression {% (d) => new ComparisonOperation(d[1], d[0], d[2]) %}
|
|
150
|
+
| cons_expression {% id %}
|
|
151
|
+
|
|
152
|
+
# priority 5
|
|
153
|
+
cons_expression ->
|
|
154
|
+
concatenation ":" cons_expression {% (d) => new ConsExpression(d[0], d[2]) %}
|
|
155
|
+
| concatenation {% id %}
|
|
156
|
+
|
|
157
|
+
concatenation ->
|
|
158
|
+
addition "++" concatenation {% (d) => new ListBinaryOperation("Concat", d[0], d[2]) %}
|
|
159
|
+
| addition {% id %}
|
|
160
|
+
|
|
161
|
+
# priority 6
|
|
162
|
+
addition ->
|
|
163
|
+
addition "+" multiplication {% (d) => new ArithmeticBinaryOperation("Plus", d[0], d[2]) %}
|
|
164
|
+
| addition "-" multiplication {% (d) => new ArithmeticBinaryOperation("Minus", d[0], d[2]) %}
|
|
165
|
+
| multiplication {% id %}
|
|
166
|
+
|
|
167
|
+
# priority 7
|
|
168
|
+
multiplication ->
|
|
169
|
+
multiplication "*" power {% (d) => new ArithmeticBinaryOperation("Multiply", d[0], d[2]) %}
|
|
170
|
+
| multiplication "/" power {% (d) => new ArithmeticBinaryOperation("Divide", d[0], d[2]) %}
|
|
171
|
+
| power {% id %}
|
|
172
|
+
|
|
173
|
+
# priority 8
|
|
174
|
+
power ->
|
|
175
|
+
unary_negation "**" power {% (d) => new ArithmeticBinaryOperation("Power", d[0], d[2]) %}
|
|
176
|
+
| unary_negation "^" power {% (d) => new ArithmeticBinaryOperation("Power", d[0], d[2]) %}
|
|
177
|
+
| unary_negation "^^" power {% (d) => new ArithmeticBinaryOperation("Power", d[0], d[2]) %}
|
|
178
|
+
| unary_negation {% id %}
|
|
179
|
+
|
|
180
|
+
unary_negation ->
|
|
181
|
+
"-" unary_negation {% (d) => new ArithmeticUnaryOperation("Negation", d[1]) %}
|
|
182
|
+
| index_access {% id %}
|
|
183
|
+
|
|
184
|
+
# priority 9
|
|
185
|
+
index_access ->
|
|
186
|
+
index_access "!!" composition_expression {% (d) => new ListBinaryOperation("GetAt", d[0], d[2]) %}
|
|
187
|
+
| composition_expression {% id %}
|
|
188
|
+
|
|
189
|
+
composition_expression ->
|
|
190
|
+
composition_expression "." infix_operator_expression {% (d) => new CompositionExpression(d[0], d[2]) %}
|
|
191
|
+
| infix_operator_expression {% id %}
|
|
192
|
+
|
|
193
|
+
infix_operator_expression ->
|
|
194
|
+
infix_operator_expression "`" variable "`" application {% (d) => new Application(new Application(d[2], d[0]), d[4]) %}
|
|
195
|
+
| application {% id %}
|
|
196
|
+
|
|
197
|
+
application ->
|
|
198
|
+
"error" primary {% d => new Raise(d[1]) %}
|
|
199
|
+
| primary primary:* {% (d) => {
|
|
200
|
+
if (d[1].length === 0) return d[0];
|
|
201
|
+
return d[1].reduce((left, right) => new Application(left, right), d[0]);
|
|
202
|
+
} %}
|
|
203
|
+
|
|
204
|
+
operator ->
|
|
205
|
+
operator_no_minus {% id %}
|
|
206
|
+
| "-" {% (d) => d[0].value %}
|
|
207
|
+
|
|
208
|
+
operator_no_minus ->
|
|
209
|
+
("=="
|
|
210
|
+
| "/="
|
|
211
|
+
| "<"
|
|
212
|
+
| ">"
|
|
213
|
+
| "<="
|
|
214
|
+
| "&&"
|
|
215
|
+
| "||"
|
|
216
|
+
| ">="
|
|
217
|
+
| "++"
|
|
218
|
+
| "+"
|
|
219
|
+
| ","
|
|
220
|
+
| "^^"
|
|
221
|
+
| "^"
|
|
222
|
+
| "**"
|
|
223
|
+
| "*"
|
|
224
|
+
| "!!"
|
|
225
|
+
| "/"
|
|
226
|
+
| "$"
|
|
227
|
+
| "$!"
|
|
228
|
+
| "."
|
|
229
|
+
| ":") {% (d) => d[0][0].value %}
|
|
230
|
+
|
|
231
|
+
left_section -> "(" expression operator ")" {% (d) => new Application(new SymbolPrimitive(d[2]), d[1]) %}
|
|
232
|
+
|
|
233
|
+
right_section -> "(" operator_no_minus expression ")" {% (d) => {
|
|
234
|
+
const flipBody = new SymbolPrimitive("flip");
|
|
235
|
+
const op = new SymbolPrimitive(d[1]);
|
|
236
|
+
const expr = d[2];
|
|
237
|
+
const flipAppliedToOp = new Application(flipBody, op);
|
|
238
|
+
return new Application(flipAppliedToOp, expr);
|
|
239
|
+
}
|
|
240
|
+
%}
|
|
241
|
+
|
|
242
|
+
operator_section -> "(" operator ")" {% (d) => new SymbolPrimitive(d[1]) %}
|
|
243
|
+
|
|
244
|
+
primary ->
|
|
245
|
+
primitive {% id %}
|
|
246
|
+
| variable {% id %}
|
|
247
|
+
| constr {% id %}
|
|
248
|
+
| tuple_expression {% id %}
|
|
249
|
+
| left_section {% id %}
|
|
250
|
+
| right_section {% id %}
|
|
251
|
+
| operator_section {% id %}
|
|
252
|
+
| list_literal {% id %}
|
|
253
|
+
| lambda_expression {% id %}
|
|
254
|
+
| data_expression {% id %}
|
|
255
|
+
| list_comprehension {% id %}
|
|
256
|
+
| "(" expression ")" {% (d) => d[1] %}
|
|
257
|
+
| "[" range_expression "]" {% (d) => d[1] %}
|
|
258
|
+
# Expression rules
|
|
259
|
+
|
|
260
|
+
# List comprehension rules
|
|
261
|
+
list_comprehension ->
|
|
262
|
+
"[" expression "|" comprehension_clause_list "]" {% (d) => {
|
|
263
|
+
return new ListComprehension(d[1], d[3]);
|
|
264
|
+
} %}
|
|
265
|
+
|
|
266
|
+
comprehension_clause_list ->
|
|
267
|
+
comprehension_clause ("," comprehension_clause):* {% (d) => {
|
|
268
|
+
return [d[0], ...d[1].map((x) => x[1])];
|
|
269
|
+
} %}
|
|
270
|
+
|
|
271
|
+
comprehension_clause ->
|
|
272
|
+
variable "<-" expression {% (d) => new Generator(d[0], d[2]) %}
|
|
273
|
+
| expression {% id %}
|
|
274
|
+
|
|
275
|
+
lambda_expression ->
|
|
276
|
+
"(" "\\" parameter_list "->" expression ")" {% (d) => new Lambda(d[2], d[4]) %}
|
|
277
|
+
|
|
278
|
+
tuple_expression -> "(" expression ("," expression):+ ")" {% (d) => new TupleExpression([d[1], ...d[2].map(x => x[1])]) %}
|
|
279
|
+
|
|
280
|
+
data_expression -> constr %lbracket fields_expressions %rbracket {% (d) => new DataExpression(d[0], d[2]) %}
|
|
281
|
+
|
|
282
|
+
fields_expressions -> field_exp ("," field_exp):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
283
|
+
|
|
284
|
+
field_exp -> variable "=" expression {% (d) => new FieldExpression(d[0], d[2]) %}
|
|
285
|
+
|
|
286
|
+
if_expression -> "if" expression "then" expression "else" expression {% (d) => new If(d[1], d[3], d[5]) %}
|
|
287
|
+
|
|
288
|
+
letin_expression -> "let" "{" bindings_list:? "}" "in" expression {% (d) => new LetInExpression(new Sequence(d[2] ?? []), d[5]) %}
|
|
289
|
+
|
|
290
|
+
case_expression -> "case" expression "of" "{" case_arms "}" {% (d) => new Switch(d[1], d[4]) %}
|
|
291
|
+
|
|
292
|
+
case_arms -> case_arm (";" case_arm):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
293
|
+
|
|
294
|
+
case_arm -> pattern "->" expression {% (d) => new Case(d[0], d[2]) %}
|
|
295
|
+
|
|
296
|
+
# Type class rules
|
|
297
|
+
|
|
298
|
+
typeclass_declaration -> "class" constr variable "where" %lbracket typeclass_body %rbracket {% (d) => new TypeClass(d[1], d[2], d[5]) %}
|
|
299
|
+
|
|
300
|
+
typeclass_body -> function_signature (";" function_signature):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
301
|
+
|
|
302
|
+
instance_declaration -> "instance" constr type "where" %lbracket instance_body %rbracket {% (d) => new Instance(d[1], d[2], d[5]) %}
|
|
303
|
+
|
|
304
|
+
instance_body -> (function_declaration | function_signature) (";" (function_declaration | function_signature)):* ";":? {% (d) => [d[0][0], ...d[1].map(x => x[1][0])] %}
|
|
305
|
+
|
|
306
|
+
# Data rules
|
|
307
|
+
|
|
308
|
+
data_declaration -> "data" constr type_variable:* "=" constructor_def ("|" constructor_def):* deriving_clause:? {%
|
|
309
|
+
(d) => new Record(d[1], [d[4], ...d[5].map(x => x[1])], d[6])
|
|
310
|
+
%}
|
|
311
|
+
|
|
312
|
+
deriving_clause ->
|
|
313
|
+
"deriving" deriving_spec {% (d) => d[1] %}
|
|
314
|
+
|
|
315
|
+
deriving_spec ->
|
|
316
|
+
"(" deriving_classes ")" {% (d) => d[1] %}
|
|
317
|
+
| constr {% (d) => [d[0]] %}
|
|
318
|
+
|
|
319
|
+
deriving_classes ->
|
|
320
|
+
constr ("," constr):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
321
|
+
|
|
322
|
+
constructor_def ->
|
|
323
|
+
constr %lbracket field_list %rbracket {% (d) => new Constructor(d[0], d[2]) %}
|
|
324
|
+
| constr simple_type:* {% (d) => new Constructor(d[0], d[1].map(x => new Field(undefined, x))) %}
|
|
325
|
+
|
|
326
|
+
field_list -> field ("," field):* {% (d) => [d[0], ...d[1].map(x => x[1])]%}
|
|
327
|
+
|
|
328
|
+
field -> variable "::" type {% (d) => new Field(d[0], d[2]) %}
|
|
329
|
+
|
|
330
|
+
# Function rules
|
|
331
|
+
|
|
332
|
+
op_name -> "(" operator ")" {% d => new SymbolPrimitive(d[1]) %}
|
|
333
|
+
|
|
334
|
+
binding_name ->
|
|
335
|
+
op_name {% id %}
|
|
336
|
+
| variable {% id %}
|
|
337
|
+
|
|
338
|
+
function_signature -> binding_name "::" type {% (d) => new TypeSignature(d[0], d[2]) %}
|
|
339
|
+
|
|
340
|
+
function_declaration -> binding_name equation {% (d) => new Function(d[0], [d[1]]) %}
|
|
341
|
+
|
|
342
|
+
return_expression -> expression {% d => new Return(d[0]) %}
|
|
343
|
+
|
|
344
|
+
where_clause -> "where" "{" bindings_list "}" {% d => d[2] %}
|
|
345
|
+
|
|
346
|
+
bindings_list ->
|
|
347
|
+
function_declaration ";" bindings_list {% d => [d[0], ...d[2]] %}
|
|
348
|
+
| function_declaration {% d => [d[0]] %}
|
|
349
|
+
|
|
350
|
+
equation ->
|
|
351
|
+
params guarded_rhs where_clause:? {% (d) => {
|
|
352
|
+
const guardsExpr = new GuardedExpression(d[1]);
|
|
353
|
+
const locals = d[2] || [];
|
|
354
|
+
const returnExpr = new Return(guardsExpr);
|
|
355
|
+
const sequence = new Sequence([...locals, returnExpr]);
|
|
356
|
+
|
|
357
|
+
return new Equation(d[0], new UnguardedBody(sequence), returnExpr);
|
|
358
|
+
} %}
|
|
359
|
+
| params %assign return_expression where_clause:? {% (d) => {
|
|
360
|
+
const locals = d[3] || [];
|
|
361
|
+
return new Equation(d[0], new UnguardedBody(new Sequence([...locals, d[2]])), d[2]);
|
|
362
|
+
} %}
|
|
363
|
+
|
|
364
|
+
params -> parameter_list:? {% (d) => d[0] || [] %}
|
|
365
|
+
|
|
366
|
+
guarded_rhs -> guarded_branch:+ {% (d) => d[0] %}
|
|
367
|
+
|
|
368
|
+
guarded_branch ->
|
|
369
|
+
"|" condition "=" expression {% (d) => new Guard(d[1], d[3]) %}
|
|
370
|
+
|
|
371
|
+
condition ->
|
|
372
|
+
"otherwise" {% d => new Otherwise() %}
|
|
373
|
+
| expression {% d => d[0] %}
|
|
374
|
+
|
|
375
|
+
parameter_list -> pattern:+ {% id %}
|
|
376
|
+
|
|
377
|
+
# Patterns
|
|
378
|
+
|
|
379
|
+
pattern -> cons_pattern {% id %}
|
|
380
|
+
|
|
381
|
+
cons_pattern ->
|
|
382
|
+
"(" cons_pattern (":" cons_pattern):+ ")" {%
|
|
383
|
+
(d) => {
|
|
384
|
+
const patterns = [d[1], ...d[2].map(item => item[1])];
|
|
385
|
+
return patterns.reduceRight((tail, head, index, arr) => {
|
|
386
|
+
if (index === arr.length - 1) return tail;
|
|
387
|
+
return new ConsPattern(head, tail);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
%}
|
|
391
|
+
| simple_pattern {% id %}
|
|
392
|
+
|
|
393
|
+
simple_pattern ->
|
|
394
|
+
(as_pattern
|
|
395
|
+
| constructor_pattern
|
|
396
|
+
| list_pattern
|
|
397
|
+
| tuple_pattern
|
|
398
|
+
#| record_pattern
|
|
399
|
+
| literal_pattern
|
|
400
|
+
| variable_pattern
|
|
401
|
+
| wildcard_pattern
|
|
402
|
+
| paren_pattern) {% (d) => d[0][0] %}
|
|
403
|
+
|
|
404
|
+
wildcard_pattern -> %anonymousVariable {% (d) => new WildcardPattern() %}
|
|
405
|
+
|
|
406
|
+
paren_pattern -> "(" pattern ")" {% (d) => d[1] %}
|
|
407
|
+
|
|
408
|
+
variable_pattern -> variable {% (d) => new VariablePattern(d[0]) %}
|
|
409
|
+
|
|
410
|
+
literal_pattern -> primitive {% (d) => new LiteralPattern(d[0]) %}
|
|
411
|
+
|
|
412
|
+
as_pattern -> (variable_pattern | wildcard_pattern) "@" pattern {% (d) => new AsPattern(d[0][0], d[2]) %}
|
|
413
|
+
|
|
414
|
+
constructor_pattern ->
|
|
415
|
+
"(" constr pattern:+ ")" {% (d) => new ConstructorPattern(d[1], d[2]) %}
|
|
416
|
+
| constr {% (d) => new ConstructorPattern(d[0], []) %}
|
|
417
|
+
|
|
418
|
+
# record_pattern ->
|
|
419
|
+
# constr:? _ %lbracket _ field_pattern_list _ %rbracket {% (d) => ({
|
|
420
|
+
# type: "RecordPattern",
|
|
421
|
+
# constructor: d[0] ? d[0].value : null,
|
|
422
|
+
# fields: d[4]
|
|
423
|
+
# }) %}
|
|
424
|
+
|
|
425
|
+
field_pattern_list -> field_pattern ("," field_pattern):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
426
|
+
|
|
427
|
+
field_pattern -> variable "=" pattern {% (d) => ({ field: d[0].value, pattern: d[2] }) %}
|
|
428
|
+
|
|
429
|
+
list_pattern -> "[" pattern_list:? "]" {% (d) => new ListPattern(d[1] || []) %}
|
|
430
|
+
|
|
431
|
+
pattern_list -> pattern ("," pattern):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
432
|
+
|
|
433
|
+
tuple_pattern -> "(" pattern ("," pattern):+ ")" {% (d) => new TuplePattern([d[1], ...d[2].map(x => x[1])]) %}
|
|
434
|
+
|
|
435
|
+
# Type rules
|
|
436
|
+
|
|
437
|
+
type_declaration -> "type" constr variable_list:? "=" type {% (d) => new TypeAlias(d[1], d[2] || [], d[4]) %}
|
|
438
|
+
|
|
439
|
+
variable_list -> variable variable:* {% (d) => [d[0].value, ...d[1]] %}
|
|
440
|
+
|
|
441
|
+
type -> function_type {% id %}
|
|
442
|
+
|
|
443
|
+
constrained_type -> constraint_list "=>" type {% (d) => new ParameterizedType([], d[2], d[0]) %}
|
|
444
|
+
|
|
445
|
+
context ->
|
|
446
|
+
constraint {% (d) => [d[0]] %}
|
|
447
|
+
| "(" constraint_list ")" {% (d) => d[1] %}
|
|
448
|
+
|
|
449
|
+
constraint_list ->
|
|
450
|
+
constraint ("," constraint):* {% (d) =>
|
|
451
|
+
[d[0], ...d[1].map(x => x[1])]
|
|
452
|
+
%}
|
|
453
|
+
|
|
454
|
+
constraint -> constr application_type:+ {% (d) => new Constraint(d[0].value, d[1]) %}
|
|
455
|
+
|
|
456
|
+
function_type ->
|
|
457
|
+
(context "=>"):? (application_type %typeArrow):* application_type {% (d) => {
|
|
458
|
+
const constraints = d[0] ? d[0][0] : [];
|
|
459
|
+
|
|
460
|
+
if (d[1].length > 0)
|
|
461
|
+
return new ParameterizedType(d[1].map(x => x[0]), d[2], constraints);
|
|
462
|
+
|
|
463
|
+
if (constraints.length === 0)
|
|
464
|
+
return d[2];
|
|
465
|
+
|
|
466
|
+
return new ParameterizedType([], d[2], constraints);
|
|
467
|
+
}
|
|
468
|
+
%}
|
|
469
|
+
|
|
470
|
+
application_type ->
|
|
471
|
+
simple_type application_type {% (d) => new TypeApplication(d[0], d[1]) %}
|
|
472
|
+
| simple_type {% id %}
|
|
473
|
+
|
|
474
|
+
simple_type ->
|
|
475
|
+
(type_variable | type_constructor) {% (d) => new SimpleType(d[0][0].value, []) %}
|
|
476
|
+
| "[" type "]" {% (d) => new ListType(d[1], []) %}
|
|
477
|
+
| "(" type ("," type):+ ")" {% (d) => new TupleType([d[1], ...d[2].map(x => x[1])], []) %}
|
|
478
|
+
| "(" type ")" {% (d) => d[1] %}
|
|
479
|
+
|
|
480
|
+
type_variable -> variable {% ([v]) => ({ value: v.value }) %}
|
|
481
|
+
type_constructor -> constr {% ([c]) => ({ value: c.value }) %}
|
|
482
|
+
|
|
483
|
+
# Misc rules
|
|
484
|
+
|
|
485
|
+
constr -> %constructor {% ([c]) => new SymbolPrimitive(c.value, loc(c)) %} # constr because js doesnt like rules called constructor
|
|
486
|
+
variable -> %variable {% ([v]) => new SymbolPrimitive(v.value, loc(v)) %}
|
|
487
|
+
|
|
488
|
+
list_literal ->
|
|
489
|
+
"[" "]" {% (_) => new ListPrimitive([]) %}
|
|
490
|
+
| "[" expression_list "]" {% (d) => new ListPrimitive(d[1]) %}
|
|
491
|
+
|
|
492
|
+
range_expression ->
|
|
493
|
+
expression ".." {% (d) => new RangeExpression(d[0]) %} # [start ..]
|
|
494
|
+
| expression ".." expression {% (d) => new RangeExpression(d[0], d[2]) %} # [start .. end]
|
|
495
|
+
| expression "," expression ".." {% (d) => new RangeExpression(d[0], undefined, d[2]) %} # [start, second ..]
|
|
496
|
+
| expression "," expression ".." expression {% (d) => new RangeExpression(d[0], d[4], d[2]) %} # [start, second .. end]
|
|
497
|
+
|
|
498
|
+
expression_list -> expression ("," expression):* {% (d) => [d[0], ...d[1].map(x => x[1])] %}
|
|
499
|
+
|
|
500
|
+
comparison_operator ->
|
|
501
|
+
"==" {% (d) => "Equal" %}
|
|
502
|
+
| "/=" {% (d) => "NotEqual" %}
|
|
503
|
+
| "<" {% (d) => "LessThan" %}
|
|
504
|
+
| ">" {% (d) => "GreaterThan" %}
|
|
505
|
+
| "<=" {% (d) => "LessOrEqualThan" %}
|
|
506
|
+
| ">=" {% (d) => "GreaterOrEqualThan" %}
|
|
507
|
+
|
|
508
|
+
primitive ->
|
|
509
|
+
%number {% ([n]) => new NumberPrimitive(Number(n.value), loc(n)) %}
|
|
510
|
+
| %char {% ([c]) => new CharPrimitive(c.value.slice(1, -1), loc(c)) %}
|
|
511
|
+
| %string {% ([s]) => {
|
|
512
|
+
let val = s.value.slice(1, -1);
|
|
513
|
+
// Haskell multiline string continuation: \ whitespace \
|
|
514
|
+
val = val.replace(/\\\s+\\/g, "");
|
|
515
|
+
// Standard escapes
|
|
516
|
+
val = val.replace(/\\n/g, "\n")
|
|
517
|
+
.replace(/\\t/g, "\t")
|
|
518
|
+
.replace(/\\"/g, "\"")
|
|
519
|
+
.replace(/\\\\/g, "\\");
|
|
520
|
+
return new StringPrimitive(val, loc(s));
|
|
521
|
+
} %}
|
|
519
522
|
| %bool {% ([b]) => new BooleanPrimitive(b.value === 'True' ? true : false, loc(b)) %}
|