@makano/rew 1.1.81 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/coffeescript/browser.js +144 -139
- package/lib/coffeescript/cake.js +132 -133
- package/lib/coffeescript/coffeescript.js +437 -381
- package/lib/coffeescript/command.js +806 -724
- package/lib/coffeescript/grammar.js +1908 -2474
- package/lib/coffeescript/helpers.js +509 -473
- package/lib/coffeescript/index.js +228 -215
- package/lib/coffeescript/lexer.js +2282 -1909
- package/lib/coffeescript/nodes.js +9782 -9202
- package/lib/coffeescript/optparse.js +255 -227
- package/lib/coffeescript/parser.js +20305 -1265
- package/lib/coffeescript/register.js +107 -87
- package/lib/coffeescript/repl.js +307 -284
- package/lib/coffeescript/rewriter.js +1389 -1079
- package/lib/coffeescript/scope.js +176 -172
- package/lib/coffeescript/sourcemap.js +242 -227
- package/lib/rew/cli/cli.js +312 -239
- package/lib/rew/cli/log.js +27 -27
- package/lib/rew/cli/run.js +8 -8
- package/lib/rew/cli/utils.js +368 -199
- package/lib/rew/const/config_path.js +2 -2
- package/lib/rew/const/default.js +38 -53
- package/lib/rew/const/files.js +11 -14
- package/lib/rew/const/opt.js +6 -6
- package/lib/rew/css/theme.css +1 -1
- package/lib/rew/functions/core.js +55 -55
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -25
- package/lib/rew/functions/export.js +17 -17
- package/lib/rew/functions/fs.js +57 -59
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +106 -122
- package/lib/rew/functions/map.js +10 -10
- package/lib/rew/functions/match.js +35 -42
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -36
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +18 -18
- package/lib/rew/functions/types.js +82 -106
- package/lib/rew/html/ui.html +12 -12
- package/lib/rew/html/ui.js +196 -201
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +13 -13
- package/lib/rew/misc/findAppPath.js +15 -15
- package/lib/rew/misc/req.js +7 -0
- package/lib/rew/misc/seededid.js +8 -8
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +237 -209
- package/lib/rew/modules/fs.js +10 -10
- package/lib/rew/modules/runtime.js +17 -21
- package/lib/rew/modules/yaml.js +27 -30
- package/lib/rew/pkgs/conf.js +82 -92
- package/lib/rew/pkgs/data.js +10 -10
- package/lib/rew/pkgs/date.js +27 -27
- package/lib/rew/pkgs/env.js +5 -5
- package/lib/rew/pkgs/modules/data/bintree.js +51 -51
- package/lib/rew/pkgs/modules/data/doublylinked.js +84 -84
- package/lib/rew/pkgs/modules/data/linkedList.js +72 -72
- package/lib/rew/pkgs/modules/data/queue.js +18 -18
- package/lib/rew/pkgs/modules/data/stack.js +18 -18
- package/lib/rew/pkgs/modules/threads/worker.js +36 -36
- package/lib/rew/pkgs/modules/ui/classes.js +181 -184
- package/lib/rew/pkgs/pkgs.js +9 -9
- package/lib/rew/pkgs/rune.js +373 -410
- package/lib/rew/pkgs/threads.js +62 -66
- package/lib/rew/pkgs/ui.js +148 -160
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +4 -3
@@ -1,2496 +1,1930 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
|
-
(function() {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
(function () {
|
3
|
+
// The CoffeeScript parser is generated by [Jison](https://github.com/zaach/jison)
|
4
|
+
// from this grammar file. Jison is a bottom-up parser generator, similar in
|
5
|
+
// style to [Bison](http://www.gnu.org/software/bison), implemented in JavaScript.
|
6
|
+
// It can recognize [LALR(1), LR(0), SLR(1), and LR(1)](https://en.wikipedia.org/wiki/LR_grammar)
|
7
|
+
// type grammars. To create the Jison parser, we list the pattern to match
|
8
|
+
// on the left-hand side, and the action to take (usually the creation of syntax
|
9
|
+
// tree nodes) on the right. As the parser runs, it
|
10
|
+
// shifts tokens from our token stream, from left to right, and
|
11
|
+
// [attempts to match](https://en.wikipedia.org/wiki/Bottom-up_parsing)
|
12
|
+
// the token sequence against the rules below. When a match can be made, it
|
13
|
+
// reduces into the [nonterminal](https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols)
|
14
|
+
// (the enclosing name at the top), and we proceed from there.
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
// If you run the `cake build:parser` command, Jison constructs a parse table
|
17
|
+
// from our rules and saves it into `lib/parser.js`.
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
// The only dependency is on the **Jison.Parser**.
|
20
|
+
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
|
21
21
|
|
22
|
-
|
22
|
+
({ Parser } = require('jison'));
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
// Jison DSL
|
25
|
+
// ---------
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
// Since we're going to be wrapped in a function by Jison in any case, if our
|
28
|
+
// action immediately returns a value, we can optimize by removing the function
|
29
|
+
// wrapper and just returning the value directly.
|
30
|
+
unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
|
31
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
|
-
|
32
|
+
// Our handy DSL for Jison grammar generation, thanks to
|
33
|
+
// [Tim Caswell](https://github.com/creationix). For every rule in the grammar,
|
34
|
+
// we pass the pattern-defining string, the action to run, and extra options,
|
35
|
+
// optionally. If no action is specified, we simply pass the value of the
|
36
|
+
// previous nonterminal.
|
37
|
+
o = function (patternString, action, options) {
|
38
|
+
var getAddDataToNodeFunctionString, match, patternCount, performActionFunctionString, returnsLoc;
|
39
|
+
patternString = patternString.replace(/\s{2,}/g, ' ');
|
40
|
+
patternCount = patternString.split(' ').length;
|
41
|
+
if (action) {
|
42
|
+
// This code block does string replacements in the generated `parser.js`
|
43
|
+
// file, replacing the calls to the `LOC` function and other strings as
|
44
|
+
// listed below.
|
45
|
+
action = (match = unwrap.exec(action)) ? match[1] : `(${action}())`;
|
46
|
+
// All runtime functions we need are defined on `yy`
|
47
|
+
action = action.replace(/\bnew /g, '$&yy.');
|
48
|
+
action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
|
49
|
+
// Returns strings of functions to add to `parser.js` which add extra data
|
50
|
+
// that nodes may have, such as comments or location data. Location data
|
51
|
+
// is added to the first parameter passed in, and the parameter is returned.
|
52
|
+
// If the parameter is not a node, it will just be passed through unaffected.
|
53
|
+
getAddDataToNodeFunctionString = function (first, last, forceUpdateLocation = true) {
|
54
|
+
return `yy.addDataToNode(yy, @${first}, ${first[0] === '$' ? '$$' : '$'}${first}, ${last ? `@${last}, ${last[0] === '$' ? '$$' : '$'}${last}` : 'null, null'}, ${forceUpdateLocation ? 'true' : 'false'})`;
|
55
|
+
};
|
56
|
+
// This code replaces the calls to `LOC` with the `yy.addDataToNode` string
|
57
|
+
// defined above. The `LOC` function, when used below in the grammar rules,
|
58
|
+
// is used to make sure that newly created node class objects get correct
|
59
|
+
// location data assigned to them. By default, the grammar will assign the
|
60
|
+
// location data spanned by *all* of the tokens on the left (e.g. a string
|
61
|
+
// such as `'Body TERMINATOR Line'`) to the “top-level” node returned by
|
62
|
+
// the grammar rule (the function on the right). But for “inner” node class
|
63
|
+
// objects created by grammar rules, they won’t get correct location data
|
64
|
+
// assigned to them without adding `LOC`.
|
65
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
|
-
|
66
|
+
// For example, consider the grammar rule `'NEW_TARGET . Property'`, which
|
67
|
+
// is handled by a function that returns
|
68
|
+
// `new MetaProperty LOC(1)(new IdentifierLiteral $1), LOC(3)(new Access $3)`.
|
69
|
+
// The `1` in `LOC(1)` refers to the first token (`NEW_TARGET`) and the `3`
|
70
|
+
// in `LOC(3)` refers to the third token (`Property`). In order for the
|
71
|
+
// `new IdentifierLiteral` to get assigned the location data corresponding
|
72
|
+
// to `new` in the source code, we use
|
73
|
+
// `LOC(1)(new IdentifierLiteral ...)` to mean “assign the location data of
|
74
|
+
// the *first* token of this grammar rule (`NEW_TARGET`) to this
|
75
|
+
// `new IdentifierLiteral`”. The `LOC(3)` means “assign the location data of
|
76
|
+
// the *third* token of this grammar rule (`Property`) to this
|
77
|
+
// `new Access`”.
|
78
|
+
returnsLoc = /^LOC/.test(action);
|
79
|
+
action = action.replace(/LOC\(([0-9]*)\)/g, getAddDataToNodeFunctionString('$1'));
|
80
|
+
// A call to `LOC` with two arguments, e.g. `LOC(2,4)`, sets the location
|
81
|
+
// data for the generated node on both of the referenced tokens (the second
|
82
|
+
// and fourth in this example).
|
83
|
+
action = action.replace(/LOC\(([0-9]*),\s*([0-9]*)\)/g, getAddDataToNodeFunctionString('$1', '$2'));
|
84
|
+
performActionFunctionString = `$$ = ${getAddDataToNodeFunctionString(1, patternCount, !returnsLoc)}(${action});`;
|
85
|
+
} else {
|
86
|
+
performActionFunctionString = '$$ = $1;';
|
87
|
+
}
|
88
|
+
return [patternString, performActionFunctionString, options];
|
89
|
+
};
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
// Grammatical Rules
|
92
|
+
// -----------------
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
// In all of the rules that follow, you'll see the name of the nonterminal as
|
95
|
+
// the key to a list of alternative matches. With each match's action, the
|
96
|
+
// dollar-sign variables are provided by Jison as references to the value of
|
97
|
+
// their numeric position, so in this rule:
|
98
98
|
|
99
|
-
|
99
|
+
// 'Expression UNLESS Expression'
|
100
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
|
-
|
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
|
-
|
236
|
-
|
237
|
-
|
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
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
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
|
-
|
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
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
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
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
guard: $4,
|
1848
|
-
step: $6
|
1849
|
-
};
|
1850
|
-
}),
|
1851
|
-
o('FORIN Expression BY Expression WHEN Expression',
|
1852
|
-
function() {
|
1853
|
-
return {
|
1854
|
-
source: $2,
|
1855
|
-
step: $4,
|
1856
|
-
guard: $6
|
1857
|
-
};
|
1858
|
-
}),
|
1859
|
-
o('FORIN ExpressionLine BY Expression WHEN Expression',
|
1860
|
-
function() {
|
1861
|
-
return {
|
1862
|
-
source: $2,
|
1863
|
-
step: $4,
|
1864
|
-
guard: $6
|
1865
|
-
};
|
1866
|
-
}),
|
1867
|
-
o('FORIN Expression BY ExpressionLine WHEN Expression',
|
1868
|
-
function() {
|
1869
|
-
return {
|
1870
|
-
source: $2,
|
1871
|
-
step: $4,
|
1872
|
-
guard: $6
|
1873
|
-
};
|
1874
|
-
}),
|
1875
|
-
o('FORIN ExpressionLine BY ExpressionLine WHEN Expression',
|
1876
|
-
function() {
|
1877
|
-
return {
|
1878
|
-
source: $2,
|
1879
|
-
step: $4,
|
1880
|
-
guard: $6
|
1881
|
-
};
|
1882
|
-
}),
|
1883
|
-
o('FORFROM Expression',
|
1884
|
-
function() {
|
1885
|
-
return {
|
1886
|
-
source: $2,
|
1887
|
-
from: true
|
1888
|
-
};
|
1889
|
-
}),
|
1890
|
-
o('FORFROM Expression WHEN Expression',
|
1891
|
-
function() {
|
1892
|
-
return {
|
1893
|
-
source: $2,
|
1894
|
-
guard: $4,
|
1895
|
-
from: true
|
1896
|
-
};
|
1897
|
-
}),
|
1898
|
-
o('FORFROM ExpressionLine WHEN Expression',
|
1899
|
-
function() {
|
1900
|
-
return {
|
1901
|
-
source: $2,
|
1902
|
-
guard: $4,
|
1903
|
-
from: true
|
1904
|
-
};
|
1905
|
-
})
|
1906
|
-
],
|
1907
|
-
ForLineSource: [
|
1908
|
-
o('FORIN ExpressionLine',
|
1909
|
-
function() {
|
1910
|
-
return {
|
1911
|
-
source: $2
|
1912
|
-
};
|
1913
|
-
}),
|
1914
|
-
o('FOROF ExpressionLine',
|
1915
|
-
function() {
|
1916
|
-
return {
|
1917
|
-
source: $2,
|
1918
|
-
object: true
|
1919
|
-
};
|
1920
|
-
}),
|
1921
|
-
o('FORIN Expression WHEN ExpressionLine',
|
1922
|
-
function() {
|
1923
|
-
return {
|
1924
|
-
source: $2,
|
1925
|
-
guard: $4
|
1926
|
-
};
|
1927
|
-
}),
|
1928
|
-
o('FORIN ExpressionLine WHEN ExpressionLine',
|
1929
|
-
function() {
|
1930
|
-
return {
|
1931
|
-
source: $2,
|
1932
|
-
guard: $4
|
1933
|
-
};
|
1934
|
-
}),
|
1935
|
-
o('FOROF Expression WHEN ExpressionLine',
|
1936
|
-
function() {
|
1937
|
-
return {
|
1938
|
-
source: $2,
|
1939
|
-
guard: $4,
|
1940
|
-
object: true
|
1941
|
-
};
|
1942
|
-
}),
|
1943
|
-
o('FOROF ExpressionLine WHEN ExpressionLine',
|
1944
|
-
function() {
|
1945
|
-
return {
|
1946
|
-
source: $2,
|
1947
|
-
guard: $4,
|
1948
|
-
object: true
|
1949
|
-
};
|
1950
|
-
}),
|
1951
|
-
o('FORIN Expression BY ExpressionLine',
|
1952
|
-
function() {
|
1953
|
-
return {
|
1954
|
-
source: $2,
|
1955
|
-
step: $4
|
1956
|
-
};
|
1957
|
-
}),
|
1958
|
-
o('FORIN ExpressionLine BY ExpressionLine',
|
1959
|
-
function() {
|
1960
|
-
return {
|
1961
|
-
source: $2,
|
1962
|
-
step: $4
|
1963
|
-
};
|
1964
|
-
}),
|
1965
|
-
o('FORIN Expression WHEN Expression BY ExpressionLine',
|
1966
|
-
function() {
|
1967
|
-
return {
|
1968
|
-
source: $2,
|
1969
|
-
guard: $4,
|
1970
|
-
step: $6
|
1971
|
-
};
|
1972
|
-
}),
|
1973
|
-
o('FORIN ExpressionLine WHEN Expression BY ExpressionLine',
|
1974
|
-
function() {
|
1975
|
-
return {
|
1976
|
-
source: $2,
|
1977
|
-
guard: $4,
|
1978
|
-
step: $6
|
1979
|
-
};
|
1980
|
-
}),
|
1981
|
-
o('FORIN Expression WHEN ExpressionLine BY ExpressionLine',
|
1982
|
-
function() {
|
1983
|
-
return {
|
1984
|
-
source: $2,
|
1985
|
-
guard: $4,
|
1986
|
-
step: $6
|
1987
|
-
};
|
1988
|
-
}),
|
1989
|
-
o('FORIN ExpressionLine WHEN ExpressionLine BY ExpressionLine',
|
1990
|
-
function() {
|
1991
|
-
return {
|
1992
|
-
source: $2,
|
1993
|
-
guard: $4,
|
1994
|
-
step: $6
|
1995
|
-
};
|
1996
|
-
}),
|
1997
|
-
o('FORIN Expression BY Expression WHEN ExpressionLine',
|
1998
|
-
function() {
|
1999
|
-
return {
|
2000
|
-
source: $2,
|
2001
|
-
step: $4,
|
2002
|
-
guard: $6
|
2003
|
-
};
|
2004
|
-
}),
|
2005
|
-
o('FORIN ExpressionLine BY Expression WHEN ExpressionLine',
|
2006
|
-
function() {
|
2007
|
-
return {
|
2008
|
-
source: $2,
|
2009
|
-
step: $4,
|
2010
|
-
guard: $6
|
2011
|
-
};
|
2012
|
-
}),
|
2013
|
-
o('FORIN Expression BY ExpressionLine WHEN ExpressionLine',
|
2014
|
-
function() {
|
2015
|
-
return {
|
2016
|
-
source: $2,
|
2017
|
-
step: $4,
|
2018
|
-
guard: $6
|
2019
|
-
};
|
2020
|
-
}),
|
2021
|
-
o('FORIN ExpressionLine BY ExpressionLine WHEN ExpressionLine',
|
2022
|
-
function() {
|
2023
|
-
return {
|
2024
|
-
source: $2,
|
2025
|
-
step: $4,
|
2026
|
-
guard: $6
|
2027
|
-
};
|
2028
|
-
}),
|
2029
|
-
o('FORFROM ExpressionLine',
|
2030
|
-
function() {
|
2031
|
-
return {
|
2032
|
-
source: $2,
|
2033
|
-
from: true
|
2034
|
-
};
|
2035
|
-
}),
|
2036
|
-
o('FORFROM Expression WHEN ExpressionLine',
|
2037
|
-
function() {
|
2038
|
-
return {
|
2039
|
-
source: $2,
|
2040
|
-
guard: $4,
|
2041
|
-
from: true
|
2042
|
-
};
|
2043
|
-
}),
|
2044
|
-
o('FORFROM ExpressionLine WHEN ExpressionLine',
|
2045
|
-
function() {
|
2046
|
-
return {
|
2047
|
-
source: $2,
|
2048
|
-
guard: $4,
|
2049
|
-
from: true
|
2050
|
-
};
|
2051
|
-
})
|
2052
|
-
],
|
2053
|
-
Switch: [
|
2054
|
-
o('SWITCH Expression INDENT Whens OUTDENT',
|
2055
|
-
function() {
|
2056
|
-
return new Switch($2,
|
2057
|
-
$4);
|
2058
|
-
}),
|
2059
|
-
o('SWITCH ExpressionLine INDENT Whens OUTDENT',
|
2060
|
-
function() {
|
2061
|
-
return new Switch($2,
|
2062
|
-
$4);
|
2063
|
-
}),
|
2064
|
-
o('SWITCH Expression INDENT Whens ELSE Block OUTDENT',
|
2065
|
-
function() {
|
2066
|
-
return new Switch($2,
|
2067
|
-
$4,
|
2068
|
-
LOC(5,
|
2069
|
-
6)($6));
|
2070
|
-
}),
|
2071
|
-
o('SWITCH ExpressionLine INDENT Whens ELSE Block OUTDENT',
|
2072
|
-
function() {
|
2073
|
-
return new Switch($2,
|
2074
|
-
$4,
|
2075
|
-
LOC(5,
|
2076
|
-
6)($6));
|
2077
|
-
}),
|
2078
|
-
o('SWITCH INDENT Whens OUTDENT',
|
2079
|
-
function() {
|
2080
|
-
return new Switch(null,
|
2081
|
-
$3);
|
2082
|
-
}),
|
2083
|
-
o('SWITCH INDENT Whens ELSE Block OUTDENT',
|
2084
|
-
function() {
|
2085
|
-
return new Switch(null,
|
2086
|
-
$3,
|
2087
|
-
LOC(4,
|
2088
|
-
5)($5));
|
2089
|
-
})
|
2090
|
-
],
|
2091
|
-
Whens: [
|
2092
|
-
o('When',
|
2093
|
-
function() {
|
2094
|
-
return [$1];
|
2095
|
-
}),
|
2096
|
-
o('Whens When',
|
2097
|
-
function() {
|
2098
|
-
return $1.concat($2);
|
2099
|
-
})
|
2100
|
-
],
|
2101
|
-
// An individual **When** clause, with action.
|
2102
|
-
When: [
|
2103
|
-
o('LEADING_WHEN SimpleArgs Block',
|
2104
|
-
function() {
|
2105
|
-
return new SwitchWhen($2,
|
2106
|
-
$3);
|
2107
|
-
}),
|
2108
|
-
o('LEADING_WHEN SimpleArgs Block TERMINATOR',
|
2109
|
-
function() {
|
2110
|
-
return LOC(1,
|
2111
|
-
3)(new SwitchWhen($2,
|
2112
|
-
$3));
|
2113
|
-
})
|
2114
|
-
],
|
2115
|
-
// The most basic form of *if* is a condition and an action. The following
|
2116
|
-
// if-related rules are broken up along these lines in order to avoid
|
2117
|
-
// ambiguity.
|
2118
|
-
IfBlock: [
|
2119
|
-
o('IF Expression Block',
|
2120
|
-
function() {
|
2121
|
-
return new If($2,
|
2122
|
-
$3,
|
2123
|
-
{
|
2124
|
-
type: $1
|
2125
|
-
});
|
2126
|
-
}),
|
2127
|
-
o('IfBlock ELSE IF Expression Block',
|
2128
|
-
function() {
|
2129
|
-
return $1.addElse(LOC(3,
|
2130
|
-
5)(new If($4,
|
2131
|
-
$5,
|
2132
|
-
{
|
2133
|
-
type: $3
|
2134
|
-
})));
|
2135
|
-
})
|
2136
|
-
],
|
2137
|
-
// The full complement of *if* expressions, including postfix one-liner
|
2138
|
-
// *if* and *unless*.
|
2139
|
-
If: [
|
2140
|
-
o('IfBlock'),
|
2141
|
-
o('IfBlock ELSE Block',
|
2142
|
-
function() {
|
2143
|
-
return $1.addElse($3);
|
2144
|
-
}),
|
2145
|
-
o('Statement POST_IF Expression',
|
2146
|
-
function() {
|
2147
|
-
return new If($3,
|
2148
|
-
LOC(1)(Block.wrap([$1])),
|
2149
|
-
{
|
2150
|
-
type: $2,
|
2151
|
-
postfix: true
|
2152
|
-
});
|
2153
|
-
}),
|
2154
|
-
o('Expression POST_IF Expression',
|
2155
|
-
function() {
|
2156
|
-
return new If($3,
|
2157
|
-
LOC(1)(Block.wrap([$1])),
|
2158
|
-
{
|
2159
|
-
type: $2,
|
2160
|
-
postfix: true
|
2161
|
-
});
|
2162
|
-
})
|
2163
|
-
],
|
2164
|
-
IfBlockLine: [
|
2165
|
-
o('IF ExpressionLine Block',
|
2166
|
-
function() {
|
2167
|
-
return new If($2,
|
2168
|
-
$3,
|
2169
|
-
{
|
2170
|
-
type: $1
|
2171
|
-
});
|
2172
|
-
}),
|
2173
|
-
o('IfBlockLine ELSE IF ExpressionLine Block',
|
2174
|
-
function() {
|
2175
|
-
return $1.addElse(LOC(3,
|
2176
|
-
5)(new If($4,
|
2177
|
-
$5,
|
2178
|
-
{
|
2179
|
-
type: $3
|
2180
|
-
})));
|
2181
|
-
})
|
2182
|
-
],
|
2183
|
-
IfLine: [
|
2184
|
-
o('IfBlockLine'),
|
2185
|
-
o('IfBlockLine ELSE Block',
|
2186
|
-
function() {
|
2187
|
-
return $1.addElse($3);
|
2188
|
-
}),
|
2189
|
-
o('Statement POST_IF ExpressionLine',
|
2190
|
-
function() {
|
2191
|
-
return new If($3,
|
2192
|
-
LOC(1)(Block.wrap([$1])),
|
2193
|
-
{
|
2194
|
-
type: $2,
|
2195
|
-
postfix: true
|
2196
|
-
});
|
2197
|
-
}),
|
2198
|
-
o('Expression POST_IF ExpressionLine',
|
2199
|
-
function() {
|
2200
|
-
return new If($3,
|
2201
|
-
LOC(1)(Block.wrap([$1])),
|
2202
|
-
{
|
2203
|
-
type: $2,
|
2204
|
-
postfix: true
|
2205
|
-
});
|
2206
|
-
})
|
2207
|
-
],
|
2208
|
-
// Arithmetic and logical operators, working on one or more operands.
|
2209
|
-
// Here they are grouped by order of precedence. The actual precedence rules
|
2210
|
-
// are defined at the bottom of the page. It would be shorter if we could
|
2211
|
-
// combine most of these rules into a single generic *Operand OpSymbol Operand*
|
2212
|
-
// -type rule, but in order to make the precedence binding possible, separate
|
2213
|
-
// rules are necessary.
|
2214
|
-
OperationLine: [
|
2215
|
-
o('UNARY ExpressionLine',
|
2216
|
-
function() {
|
2217
|
-
return new Op($1,
|
2218
|
-
$2);
|
2219
|
-
}),
|
2220
|
-
o('DO ExpressionLine',
|
2221
|
-
function() {
|
2222
|
-
return new Op($1,
|
2223
|
-
$2);
|
2224
|
-
}),
|
2225
|
-
o('DO_IIFE CodeLine',
|
2226
|
-
function() {
|
2227
|
-
return new Op($1,
|
2228
|
-
$2);
|
2229
|
-
})
|
2230
|
-
],
|
2231
|
-
Operation: [
|
2232
|
-
o('UNARY Expression',
|
2233
|
-
function() {
|
2234
|
-
return new Op($1.toString(),
|
2235
|
-
$2,
|
2236
|
-
void 0,
|
2237
|
-
void 0,
|
2238
|
-
{
|
2239
|
-
originalOperator: $1.original
|
2240
|
-
});
|
2241
|
-
}),
|
2242
|
-
o('DO Expression',
|
2243
|
-
function() {
|
2244
|
-
return new Op($1,
|
2245
|
-
$2);
|
2246
|
-
}),
|
2247
|
-
o('UNARY_MATH Expression',
|
2248
|
-
function() {
|
2249
|
-
return new Op($1,
|
2250
|
-
$2);
|
2251
|
-
}),
|
2252
|
-
o('- Expression',
|
2253
|
-
(function() {
|
2254
|
-
return new Op('-',
|
2255
|
-
$2);
|
2256
|
-
}),
|
2257
|
-
{
|
2258
|
-
prec: 'UNARY_MATH'
|
2259
|
-
}),
|
2260
|
-
o('+ Expression',
|
2261
|
-
(function() {
|
2262
|
-
return new Op('+',
|
2263
|
-
$2);
|
2264
|
-
}),
|
2265
|
-
{
|
2266
|
-
prec: 'UNARY_MATH'
|
2267
|
-
}),
|
2268
|
-
o('AWAIT Expression',
|
2269
|
-
function() {
|
2270
|
-
return new Op($1,
|
2271
|
-
$2);
|
2272
|
-
}),
|
2273
|
-
o('AWAIT INDENT Object OUTDENT',
|
2274
|
-
function() {
|
2275
|
-
return new Op($1,
|
2276
|
-
$3);
|
2277
|
-
}),
|
2278
|
-
o('-- SimpleAssignable',
|
2279
|
-
function() {
|
2280
|
-
return new Op('--',
|
2281
|
-
$2);
|
2282
|
-
}),
|
2283
|
-
o('++ SimpleAssignable',
|
2284
|
-
function() {
|
2285
|
-
return new Op('++',
|
2286
|
-
$2);
|
2287
|
-
}),
|
2288
|
-
o('SimpleAssignable --',
|
2289
|
-
function() {
|
2290
|
-
return new Op('--',
|
2291
|
-
$1,
|
2292
|
-
null,
|
2293
|
-
true);
|
2294
|
-
}),
|
2295
|
-
o('SimpleAssignable ++',
|
2296
|
-
function() {
|
2297
|
-
return new Op('++',
|
2298
|
-
$1,
|
2299
|
-
null,
|
2300
|
-
true);
|
2301
|
-
}),
|
2302
|
-
// [The existential operator](https://coffeescript.org/#existential-operator).
|
2303
|
-
o('Expression ?',
|
2304
|
-
function() {
|
2305
|
-
return new Existence($1);
|
2306
|
-
}),
|
2307
|
-
o('Expression + Expression',
|
2308
|
-
function() {
|
2309
|
-
return new Op('+',
|
2310
|
-
$1,
|
2311
|
-
$3);
|
2312
|
-
}),
|
2313
|
-
o('Expression - Expression',
|
2314
|
-
function() {
|
2315
|
-
return new Op('-',
|
2316
|
-
$1,
|
2317
|
-
$3);
|
2318
|
-
}),
|
2319
|
-
o('Expression MATH Expression',
|
2320
|
-
function() {
|
2321
|
-
return new Op($2,
|
2322
|
-
$1,
|
2323
|
-
$3);
|
2324
|
-
}),
|
2325
|
-
o('Expression ** Expression',
|
2326
|
-
function() {
|
2327
|
-
return new Op($2,
|
2328
|
-
$1,
|
2329
|
-
$3);
|
2330
|
-
}),
|
2331
|
-
o('Expression SHIFT Expression',
|
2332
|
-
function() {
|
2333
|
-
return new Op($2,
|
2334
|
-
$1,
|
2335
|
-
$3);
|
2336
|
-
}),
|
2337
|
-
o('Expression COMPARE Expression',
|
2338
|
-
function() {
|
2339
|
-
return new Op($2.toString(),
|
2340
|
-
$1,
|
2341
|
-
$3,
|
2342
|
-
void 0,
|
2343
|
-
{
|
2344
|
-
originalOperator: $2.original
|
2345
|
-
});
|
2346
|
-
}),
|
2347
|
-
o('Expression & Expression',
|
2348
|
-
function() {
|
2349
|
-
return new Op($2,
|
2350
|
-
$1,
|
2351
|
-
$3);
|
2352
|
-
}),
|
2353
|
-
o('Expression ^ Expression',
|
2354
|
-
function() {
|
2355
|
-
return new Op($2,
|
2356
|
-
$1,
|
2357
|
-
$3);
|
2358
|
-
}),
|
2359
|
-
o('Expression | Expression',
|
2360
|
-
function() {
|
2361
|
-
return new Op($2,
|
2362
|
-
$1,
|
2363
|
-
$3);
|
2364
|
-
}),
|
2365
|
-
o('Expression && Expression',
|
2366
|
-
function() {
|
2367
|
-
return new Op($2.toString(),
|
2368
|
-
$1,
|
2369
|
-
$3,
|
2370
|
-
void 0,
|
2371
|
-
{
|
2372
|
-
originalOperator: $2.original
|
2373
|
-
});
|
2374
|
-
}),
|
2375
|
-
o('Expression || Expression',
|
2376
|
-
function() {
|
2377
|
-
return new Op($2.toString(),
|
2378
|
-
$1,
|
2379
|
-
$3,
|
2380
|
-
void 0,
|
2381
|
-
{
|
2382
|
-
originalOperator: $2.original
|
2383
|
-
});
|
2384
|
-
}),
|
2385
|
-
o('Expression BIN? Expression',
|
2386
|
-
function() {
|
2387
|
-
return new Op($2,
|
2388
|
-
$1,
|
2389
|
-
$3);
|
2390
|
-
}),
|
2391
|
-
o('Expression RELATION Expression',
|
2392
|
-
function() {
|
2393
|
-
var ref,
|
2394
|
-
ref1;
|
2395
|
-
return new Op($2.toString(),
|
2396
|
-
$1,
|
2397
|
-
$3,
|
2398
|
-
void 0,
|
2399
|
-
{
|
2400
|
-
invertOperator: (ref = (ref1 = $2.invert) != null ? ref1.original : void 0) != null ? ref : $2.invert
|
2401
|
-
});
|
2402
|
-
}),
|
2403
|
-
o('SimpleAssignable COMPOUND_ASSIGN Expression',
|
2404
|
-
function() {
|
2405
|
-
return new Assign($1,
|
2406
|
-
$3,
|
2407
|
-
$2.toString(),
|
2408
|
-
{
|
2409
|
-
originalContext: $2.original
|
2410
|
-
});
|
2411
|
-
}),
|
2412
|
-
o('SimpleAssignable COMPOUND_ASSIGN INDENT Expression OUTDENT',
|
2413
|
-
function() {
|
2414
|
-
return new Assign($1,
|
2415
|
-
$4,
|
2416
|
-
$2.toString(),
|
2417
|
-
{
|
2418
|
-
originalContext: $2.original
|
2419
|
-
});
|
2420
|
-
}),
|
2421
|
-
o('SimpleAssignable COMPOUND_ASSIGN TERMINATOR Expression',
|
2422
|
-
function() {
|
2423
|
-
return new Assign($1,
|
2424
|
-
$4,
|
2425
|
-
$2.toString(),
|
2426
|
-
{
|
2427
|
-
originalContext: $2.original
|
2428
|
-
});
|
2429
|
-
})
|
2430
|
-
],
|
2431
|
-
DoIife: [
|
2432
|
-
o('DO_IIFE Code',
|
2433
|
-
function() {
|
2434
|
-
return new Op($1,
|
2435
|
-
$2);
|
2436
|
-
})
|
2437
|
-
]
|
2438
|
-
};
|
101
|
+
// `$1` would be the value of the first `Expression`, `$2` would be the token
|
102
|
+
// for the `UNLESS` terminal, and `$3` would be the value of the second
|
103
|
+
// `Expression`.
|
104
|
+
grammar = {
|
105
|
+
// The **Root** is the top-level node in the syntax tree. Since we parse bottom-up,
|
106
|
+
// all parsing must end here.
|
107
|
+
Root: [
|
108
|
+
o('', function () {
|
109
|
+
return new Root(new Block());
|
110
|
+
}),
|
111
|
+
o('Body', function () {
|
112
|
+
return new Root($1);
|
113
|
+
}),
|
114
|
+
],
|
115
|
+
// Any list of statements and expressions, separated by line breaks or semicolons.
|
116
|
+
Body: [
|
117
|
+
o('Line', function () {
|
118
|
+
return Block.wrap([$1]);
|
119
|
+
}),
|
120
|
+
o('Body TERMINATOR Line', function () {
|
121
|
+
return $1.push($3);
|
122
|
+
}),
|
123
|
+
o('Body TERMINATOR'),
|
124
|
+
],
|
125
|
+
// Block and statements, which make up a line in a body. FuncDirective is a
|
126
|
+
// statement, but not included in Statement because that results in an ambiguous
|
127
|
+
// grammar.
|
128
|
+
Line: [o('Expression'), o('ExpressionLine'), o('Statement'), o('FuncDirective')],
|
129
|
+
FuncDirective: [o('YieldReturn'), o('AwaitReturn')],
|
130
|
+
// Pure statements which cannot be expressions.
|
131
|
+
Statement: [
|
132
|
+
o('Return'),
|
133
|
+
o('STATEMENT', function () {
|
134
|
+
return new StatementLiteral($1);
|
135
|
+
}),
|
136
|
+
o('Import'),
|
137
|
+
o('Export'),
|
138
|
+
],
|
139
|
+
// All the different types of expressions in our language. The basic unit of
|
140
|
+
// CoffeeScript is the **Expression** -- everything that can be an expression
|
141
|
+
// is one. Blocks serve as the building blocks of many other rules, making
|
142
|
+
// them somewhat circular.
|
143
|
+
Expression: [
|
144
|
+
o('Value'),
|
145
|
+
o('Code'),
|
146
|
+
o('Operation'),
|
147
|
+
o('Assign'),
|
148
|
+
o('If'),
|
149
|
+
o('Try'),
|
150
|
+
o('While'),
|
151
|
+
o('For'),
|
152
|
+
o('Switch'),
|
153
|
+
o('Class'),
|
154
|
+
o('Throw'),
|
155
|
+
o('Yield'),
|
156
|
+
],
|
157
|
+
// Expressions which are written in single line and would otherwise require being
|
158
|
+
// wrapped in braces: E.g `a = b if do -> f a is 1`, `if f (a) -> a*2 then ...`,
|
159
|
+
// `for x in do (obj) -> f obj when x > 8 then f x`
|
160
|
+
ExpressionLine: [o('CodeLine'), o('IfLine'), o('OperationLine')],
|
161
|
+
Yield: [
|
162
|
+
o('YIELD', function () {
|
163
|
+
return new Op($1, new Value(new Literal('')));
|
164
|
+
}),
|
165
|
+
o('YIELD Expression', function () {
|
166
|
+
return new Op($1, $2);
|
167
|
+
}),
|
168
|
+
o('YIELD INDENT Object OUTDENT', function () {
|
169
|
+
return new Op($1, $3);
|
170
|
+
}),
|
171
|
+
o('YIELD FROM Expression', function () {
|
172
|
+
return new Op($1.concat($2), $3);
|
173
|
+
}),
|
174
|
+
],
|
175
|
+
// An indented block of expressions. Note that the [Rewriter](rewriter.html)
|
176
|
+
// will convert some postfix forms into blocks for us, by adjusting the
|
177
|
+
// token stream.
|
178
|
+
Block: [
|
179
|
+
o('INDENT OUTDENT', function () {
|
180
|
+
return new Block();
|
181
|
+
}),
|
182
|
+
o('INDENT Body OUTDENT', function () {
|
183
|
+
return $2;
|
184
|
+
}),
|
185
|
+
],
|
186
|
+
Identifier: [
|
187
|
+
o('IDENTIFIER', function () {
|
188
|
+
return new IdentifierLiteral($1);
|
189
|
+
}),
|
190
|
+
o('JSX_TAG', function () {
|
191
|
+
var ref, ref1, ref2, ref3;
|
192
|
+
return new JSXTag($1.toString(), {
|
193
|
+
tagNameLocationData: $1.tagNameToken[2],
|
194
|
+
closingTagOpeningBracketLocationData: (ref = $1.closingTagOpeningBracketToken) != null ? ref[2] : void 0,
|
195
|
+
closingTagSlashLocationData: (ref1 = $1.closingTagSlashToken) != null ? ref1[2] : void 0,
|
196
|
+
closingTagNameLocationData: (ref2 = $1.closingTagNameToken) != null ? ref2[2] : void 0,
|
197
|
+
closingTagClosingBracketLocationData: (ref3 = $1.closingTagClosingBracketToken) != null ? ref3[2] : void 0,
|
198
|
+
});
|
199
|
+
}),
|
200
|
+
],
|
201
|
+
Property: [
|
202
|
+
o('PROPERTY', function () {
|
203
|
+
return new PropertyName($1.toString());
|
204
|
+
}),
|
205
|
+
],
|
206
|
+
// Alphanumerics are separated from the other **Literal** matchers because
|
207
|
+
// they can also serve as keys in object literals.
|
208
|
+
AlphaNumeric: [
|
209
|
+
o('NUMBER', function () {
|
210
|
+
return new NumberLiteral($1.toString(), {
|
211
|
+
parsedValue: $1.parsedValue,
|
212
|
+
});
|
213
|
+
}),
|
214
|
+
o('String'),
|
215
|
+
],
|
216
|
+
String: [
|
217
|
+
o('STRING', function () {
|
218
|
+
return new StringLiteral(
|
219
|
+
$1.slice(1, -1), // strip artificial quotes and unwrap to primitive string
|
220
|
+
{
|
221
|
+
quote: $1.quote,
|
222
|
+
initialChunk: $1.initialChunk,
|
223
|
+
finalChunk: $1.finalChunk,
|
224
|
+
indent: $1.indent,
|
225
|
+
double: $1.double,
|
226
|
+
heregex: $1.heregex,
|
227
|
+
},
|
228
|
+
);
|
229
|
+
}),
|
230
|
+
o('STRING_START Interpolations STRING_END', function () {
|
231
|
+
return new StringWithInterpolations(Block.wrap($2), {
|
232
|
+
quote: $1.quote,
|
233
|
+
startQuote: LOC(1)(new Literal($1.toString())),
|
234
|
+
});
|
235
|
+
}),
|
236
|
+
],
|
237
|
+
Interpolations: [
|
238
|
+
o('InterpolationChunk', function () {
|
239
|
+
return [$1];
|
240
|
+
}),
|
241
|
+
o('Interpolations InterpolationChunk', function () {
|
242
|
+
return $1.concat($2);
|
243
|
+
}),
|
244
|
+
],
|
245
|
+
InterpolationChunk: [
|
246
|
+
o('INTERPOLATION_START Body INTERPOLATION_END', function () {
|
247
|
+
return new Interpolation($2);
|
248
|
+
}),
|
249
|
+
o('INTERPOLATION_START INDENT Body OUTDENT INTERPOLATION_END', function () {
|
250
|
+
return new Interpolation($3);
|
251
|
+
}),
|
252
|
+
o('INTERPOLATION_START INTERPOLATION_END', function () {
|
253
|
+
return new Interpolation();
|
254
|
+
}),
|
255
|
+
o('String', function () {
|
256
|
+
return $1;
|
257
|
+
}),
|
258
|
+
],
|
259
|
+
// The .toString() calls here and elsewhere are to convert `String` objects
|
260
|
+
// back to primitive strings now that we've retrieved stowaway extra properties
|
261
|
+
Regex: [
|
262
|
+
o('REGEX', function () {
|
263
|
+
return new RegexLiteral($1.toString(), {
|
264
|
+
delimiter: $1.delimiter,
|
265
|
+
heregexCommentTokens: $1.heregexCommentTokens,
|
266
|
+
});
|
267
|
+
}),
|
268
|
+
o('REGEX_START Invocation REGEX_END', function () {
|
269
|
+
return new RegexWithInterpolations($2, {
|
270
|
+
heregexCommentTokens: $3.heregexCommentTokens,
|
271
|
+
});
|
272
|
+
}),
|
273
|
+
],
|
274
|
+
// All of our immediate values. Generally these can be passed straight
|
275
|
+
// through and printed to JavaScript.
|
276
|
+
Literal: [
|
277
|
+
o('AlphaNumeric'),
|
278
|
+
o('JS', function () {
|
279
|
+
return new PassthroughLiteral($1.toString(), {
|
280
|
+
here: $1.here,
|
281
|
+
generated: $1.generated,
|
282
|
+
});
|
283
|
+
}),
|
284
|
+
o('Regex'),
|
285
|
+
o('UNDEFINED', function () {
|
286
|
+
return new UndefinedLiteral($1);
|
287
|
+
}),
|
288
|
+
o('NULL', function () {
|
289
|
+
return new NullLiteral($1);
|
290
|
+
}),
|
291
|
+
o('BOOL', function () {
|
292
|
+
return new BooleanLiteral($1.toString(), {
|
293
|
+
originalValue: $1.original,
|
294
|
+
});
|
295
|
+
}),
|
296
|
+
o('INFINITY', function () {
|
297
|
+
return new InfinityLiteral($1.toString(), {
|
298
|
+
originalValue: $1.original,
|
299
|
+
});
|
300
|
+
}),
|
301
|
+
o('NAN', function () {
|
302
|
+
return new NaNLiteral($1);
|
303
|
+
}),
|
304
|
+
],
|
305
|
+
// Assignment of a variable, property, or index to a value.
|
306
|
+
Assign: [
|
307
|
+
o('Assignable = Expression', function () {
|
308
|
+
return new Assign($1, $3);
|
309
|
+
}),
|
310
|
+
o('Assignable = TERMINATOR Expression', function () {
|
311
|
+
return new Assign($1, $4);
|
312
|
+
}),
|
313
|
+
o('Assignable = INDENT Expression OUTDENT', function () {
|
314
|
+
return new Assign($1, $4);
|
315
|
+
}),
|
316
|
+
],
|
317
|
+
// Assignment when it happens within an object literal. The difference from
|
318
|
+
// the ordinary **Assign** is that these allow numbers and strings as keys.
|
319
|
+
AssignObj: [
|
320
|
+
o('ObjAssignable', function () {
|
321
|
+
return new Value($1);
|
322
|
+
}),
|
323
|
+
o('ObjRestValue'),
|
324
|
+
o('ObjAssignable : Expression', function () {
|
325
|
+
return new Assign(LOC(1)(new Value($1)), $3, 'object', {
|
326
|
+
operatorToken: LOC(2)(new Literal($2)),
|
327
|
+
});
|
328
|
+
}),
|
329
|
+
o('ObjAssignable : INDENT Expression OUTDENT', function () {
|
330
|
+
return new Assign(LOC(1)(new Value($1)), $4, 'object', {
|
331
|
+
operatorToken: LOC(2)(new Literal($2)),
|
332
|
+
});
|
333
|
+
}),
|
334
|
+
o('SimpleObjAssignable = Expression', function () {
|
335
|
+
return new Assign(LOC(1)(new Value($1)), $3, null, {
|
336
|
+
operatorToken: LOC(2)(new Literal($2)),
|
337
|
+
});
|
338
|
+
}),
|
339
|
+
o('SimpleObjAssignable = INDENT Expression OUTDENT', function () {
|
340
|
+
return new Assign(LOC(1)(new Value($1)), $4, null, {
|
341
|
+
operatorToken: LOC(2)(new Literal($2)),
|
342
|
+
});
|
343
|
+
}),
|
344
|
+
],
|
345
|
+
SimpleObjAssignable: [o('Identifier'), o('Property'), o('ThisProperty')],
|
346
|
+
ObjAssignable: [
|
347
|
+
o('SimpleObjAssignable'),
|
348
|
+
o('[ Expression ]', function () {
|
349
|
+
return new Value(new ComputedPropertyName($2));
|
350
|
+
}),
|
351
|
+
o('@ [ Expression ]', function () {
|
352
|
+
return new Value(LOC(1)(new ThisLiteral($1)), [LOC(3)(new ComputedPropertyName($3))], 'this');
|
353
|
+
}),
|
354
|
+
o('AlphaNumeric'),
|
355
|
+
],
|
356
|
+
// Object literal spread properties.
|
357
|
+
ObjRestValue: [
|
358
|
+
o('SimpleObjAssignable ...', function () {
|
359
|
+
return new Splat(new Value($1));
|
360
|
+
}),
|
361
|
+
o('... SimpleObjAssignable', function () {
|
362
|
+
return new Splat(new Value($2), {
|
363
|
+
postfix: false,
|
364
|
+
});
|
365
|
+
}),
|
366
|
+
o('ObjSpreadExpr ...', function () {
|
367
|
+
return new Splat($1);
|
368
|
+
}),
|
369
|
+
o('... ObjSpreadExpr', function () {
|
370
|
+
return new Splat($2, {
|
371
|
+
postfix: false,
|
372
|
+
});
|
373
|
+
}),
|
374
|
+
],
|
375
|
+
ObjSpreadExpr: [
|
376
|
+
o('ObjSpreadIdentifier'),
|
377
|
+
o('Object'),
|
378
|
+
o('Parenthetical'),
|
379
|
+
o('Super'),
|
380
|
+
o('This'),
|
381
|
+
o('SUPER OptFuncExist Arguments', function () {
|
382
|
+
return new SuperCall(LOC(1)(new Super()), $3, $2.soak, $1);
|
383
|
+
}),
|
384
|
+
o('DYNAMIC_IMPORT Arguments', function () {
|
385
|
+
return new DynamicImportCall(LOC(1)(new DynamicImport()), $2);
|
386
|
+
}),
|
387
|
+
o('SimpleObjAssignable OptFuncExist Arguments', function () {
|
388
|
+
return new Call(new Value($1), $3, $2.soak);
|
389
|
+
}),
|
390
|
+
o('ObjSpreadExpr OptFuncExist Arguments', function () {
|
391
|
+
return new Call($1, $3, $2.soak);
|
392
|
+
}),
|
393
|
+
],
|
394
|
+
ObjSpreadIdentifier: [
|
395
|
+
o('SimpleObjAssignable Accessor', function () {
|
396
|
+
return new Value($1).add($2);
|
397
|
+
}),
|
398
|
+
o('ObjSpreadExpr Accessor', function () {
|
399
|
+
return new Value($1).add($2);
|
400
|
+
}),
|
401
|
+
],
|
402
|
+
// A return statement from a function body.
|
403
|
+
Return: [
|
404
|
+
o('RETURN Expression', function () {
|
405
|
+
return new Return($2);
|
406
|
+
}),
|
407
|
+
o('RETURN INDENT Object OUTDENT', function () {
|
408
|
+
return new Return(new Value($3));
|
409
|
+
}),
|
410
|
+
o('RETURN', function () {
|
411
|
+
return new Return();
|
412
|
+
}),
|
413
|
+
],
|
414
|
+
YieldReturn: [
|
415
|
+
o('YIELD RETURN Expression', function () {
|
416
|
+
return new YieldReturn($3, {
|
417
|
+
returnKeyword: LOC(2)(new Literal($2)),
|
418
|
+
});
|
419
|
+
}),
|
420
|
+
o('YIELD RETURN', function () {
|
421
|
+
return new YieldReturn(null, {
|
422
|
+
returnKeyword: LOC(2)(new Literal($2)),
|
423
|
+
});
|
424
|
+
}),
|
425
|
+
],
|
426
|
+
AwaitReturn: [
|
427
|
+
o('AWAIT RETURN Expression', function () {
|
428
|
+
return new AwaitReturn($3, {
|
429
|
+
returnKeyword: LOC(2)(new Literal($2)),
|
430
|
+
});
|
431
|
+
}),
|
432
|
+
o('AWAIT RETURN', function () {
|
433
|
+
return new AwaitReturn(null, {
|
434
|
+
returnKeyword: LOC(2)(new Literal($2)),
|
435
|
+
});
|
436
|
+
}),
|
437
|
+
],
|
438
|
+
// The **Code** node is the function literal. It’s defined by an indented block
|
439
|
+
// of **Block** preceded by a function arrow, with an optional parameter list.
|
440
|
+
Code: [
|
441
|
+
o('PARAM_START ParamList PARAM_END FuncGlyph Block', function () {
|
442
|
+
return new Code($2, $5, $4, LOC(1)(new Literal($1)));
|
443
|
+
}),
|
444
|
+
o('FuncGlyph Block', function () {
|
445
|
+
return new Code([], $2, $1);
|
446
|
+
}),
|
447
|
+
],
|
448
|
+
// The Codeline is the **Code** node with **Line** instead of indented **Block**.
|
449
|
+
CodeLine: [
|
450
|
+
o('PARAM_START ParamList PARAM_END FuncGlyph Line', function () {
|
451
|
+
return new Code($2, LOC(5)(Block.wrap([$5])), $4, LOC(1)(new Literal($1)));
|
452
|
+
}),
|
453
|
+
o('FuncGlyph Line', function () {
|
454
|
+
return new Code([], LOC(2)(Block.wrap([$2])), $1);
|
455
|
+
}),
|
456
|
+
],
|
457
|
+
// CoffeeScript has two different symbols for functions. `->` is for ordinary
|
458
|
+
// functions, and `=>` is for functions bound to the current value of *this*.
|
459
|
+
FuncGlyph: [
|
460
|
+
o('->', function () {
|
461
|
+
return new FuncGlyph($1);
|
462
|
+
}),
|
463
|
+
o('=>', function () {
|
464
|
+
return new FuncGlyph($1);
|
465
|
+
}),
|
466
|
+
],
|
467
|
+
// An optional, trailing comma.
|
468
|
+
OptComma: [o(''), o(',')],
|
469
|
+
// The list of parameters that a function accepts can be of any length.
|
470
|
+
ParamList: [
|
471
|
+
o('', function () {
|
472
|
+
return [];
|
473
|
+
}),
|
474
|
+
o('Param', function () {
|
475
|
+
return [$1];
|
476
|
+
}),
|
477
|
+
o('ParamList , Param', function () {
|
478
|
+
return $1.concat($3);
|
479
|
+
}),
|
480
|
+
o('ParamList OptComma TERMINATOR Param', function () {
|
481
|
+
return $1.concat($4);
|
482
|
+
}),
|
483
|
+
o('ParamList OptComma INDENT ParamList OptComma OUTDENT', function () {
|
484
|
+
return $1.concat($4);
|
485
|
+
}),
|
486
|
+
],
|
487
|
+
// A single parameter in a function definition can be ordinary, or a splat
|
488
|
+
// that hoovers up the remaining arguments.
|
489
|
+
Param: [
|
490
|
+
o('ParamVar', function () {
|
491
|
+
return new Param($1);
|
492
|
+
}),
|
493
|
+
o('ParamVar ...', function () {
|
494
|
+
return new Param($1, null, true);
|
495
|
+
}),
|
496
|
+
o('... ParamVar', function () {
|
497
|
+
return new Param($2, null, {
|
498
|
+
postfix: false,
|
499
|
+
});
|
500
|
+
}),
|
501
|
+
o('ParamVar = Expression', function () {
|
502
|
+
return new Param($1, $3);
|
503
|
+
}),
|
504
|
+
o('...', function () {
|
505
|
+
return new Expansion();
|
506
|
+
}),
|
507
|
+
],
|
508
|
+
// Function Parameters
|
509
|
+
ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
|
510
|
+
// A splat that occurs outside of a parameter list.
|
511
|
+
Splat: [
|
512
|
+
o('Expression ...', function () {
|
513
|
+
return new Splat($1);
|
514
|
+
}),
|
515
|
+
o('... Expression', function () {
|
516
|
+
return new Splat($2, {
|
517
|
+
postfix: false,
|
518
|
+
});
|
519
|
+
}),
|
520
|
+
],
|
521
|
+
// Variables and properties that can be assigned to.
|
522
|
+
SimpleAssignable: [
|
523
|
+
o('Identifier', function () {
|
524
|
+
return new Value($1);
|
525
|
+
}),
|
526
|
+
o('Value Accessor', function () {
|
527
|
+
return $1.add($2);
|
528
|
+
}),
|
529
|
+
o('Code Accessor', function () {
|
530
|
+
return new Value($1).add($2);
|
531
|
+
}),
|
532
|
+
o('ThisProperty'),
|
533
|
+
],
|
534
|
+
// Everything that can be assigned to.
|
535
|
+
Assignable: [
|
536
|
+
o('SimpleAssignable'),
|
537
|
+
o('Array', function () {
|
538
|
+
return new Value($1);
|
539
|
+
}),
|
540
|
+
o('Object', function () {
|
541
|
+
return new Value($1);
|
542
|
+
}),
|
543
|
+
],
|
544
|
+
// The types of things that can be treated as values -- assigned to, invoked
|
545
|
+
// as functions, indexed into, named as a class, etc.
|
546
|
+
Value: [
|
547
|
+
o('Assignable'),
|
548
|
+
o('Literal', function () {
|
549
|
+
return new Value($1);
|
550
|
+
}),
|
551
|
+
o('Parenthetical', function () {
|
552
|
+
return new Value($1);
|
553
|
+
}),
|
554
|
+
o('Range', function () {
|
555
|
+
return new Value($1);
|
556
|
+
}),
|
557
|
+
o('Invocation', function () {
|
558
|
+
return new Value($1);
|
559
|
+
}),
|
560
|
+
o('DoIife', function () {
|
561
|
+
return new Value($1);
|
562
|
+
}),
|
563
|
+
o('This'),
|
564
|
+
o('Super', function () {
|
565
|
+
return new Value($1);
|
566
|
+
}),
|
567
|
+
o('MetaProperty', function () {
|
568
|
+
return new Value($1);
|
569
|
+
}),
|
570
|
+
],
|
571
|
+
// A `super`-based expression that can be used as a value.
|
572
|
+
Super: [
|
573
|
+
o('SUPER . Property', function () {
|
574
|
+
return new Super(LOC(3)(new Access($3)), LOC(1)(new Literal($1)));
|
575
|
+
}),
|
576
|
+
o('SUPER INDEX_START Expression INDEX_END', function () {
|
577
|
+
return new Super(LOC(3)(new Index($3)), LOC(1)(new Literal($1)));
|
578
|
+
}),
|
579
|
+
o('SUPER INDEX_START INDENT Expression OUTDENT INDEX_END', function () {
|
580
|
+
return new Super(LOC(4)(new Index($4)), LOC(1)(new Literal($1)));
|
581
|
+
}),
|
582
|
+
],
|
583
|
+
// A “meta-property” access e.g. `new.target` or `import.meta`, where
|
584
|
+
// something that looks like a property is referenced on a keyword.
|
585
|
+
MetaProperty: [
|
586
|
+
o('NEW_TARGET . Property', function () {
|
587
|
+
return new MetaProperty(LOC(1)(new IdentifierLiteral($1)), LOC(3)(new Access($3)));
|
588
|
+
}),
|
589
|
+
o('IMPORT_META . Property', function () {
|
590
|
+
return new MetaProperty(LOC(1)(new IdentifierLiteral($1)), LOC(3)(new Access($3)));
|
591
|
+
}),
|
592
|
+
],
|
593
|
+
// The general group of accessors into an object, by property, by prototype
|
594
|
+
// or by array index or slice.
|
595
|
+
Accessor: [
|
596
|
+
o('. Property', function () {
|
597
|
+
return new Access($2);
|
598
|
+
}),
|
599
|
+
o('?. Property', function () {
|
600
|
+
return new Access($2, {
|
601
|
+
soak: true,
|
602
|
+
});
|
603
|
+
}),
|
604
|
+
o(':: Property', function () {
|
605
|
+
return [
|
606
|
+
LOC(1)(
|
607
|
+
new Access(new PropertyName('prototype'), {
|
608
|
+
shorthand: true,
|
609
|
+
}),
|
610
|
+
),
|
611
|
+
LOC(2)(new Access($2)),
|
612
|
+
];
|
613
|
+
}),
|
614
|
+
o('?:: Property', function () {
|
615
|
+
return [
|
616
|
+
LOC(1)(
|
617
|
+
new Access(new PropertyName('prototype'), {
|
618
|
+
shorthand: true,
|
619
|
+
soak: true,
|
620
|
+
}),
|
621
|
+
),
|
622
|
+
LOC(2)(new Access($2)),
|
623
|
+
];
|
624
|
+
}),
|
625
|
+
o('::', function () {
|
626
|
+
return new Access(new PropertyName('prototype'), {
|
627
|
+
shorthand: true,
|
628
|
+
});
|
629
|
+
}),
|
630
|
+
o('?::', function () {
|
631
|
+
return new Access(new PropertyName('prototype'), {
|
632
|
+
shorthand: true,
|
633
|
+
soak: true,
|
634
|
+
});
|
635
|
+
}),
|
636
|
+
o('Index'),
|
637
|
+
],
|
638
|
+
// Indexing into an object or array using bracket notation.
|
639
|
+
Index: [
|
640
|
+
o('INDEX_START IndexValue INDEX_END', function () {
|
641
|
+
return $2;
|
642
|
+
}),
|
643
|
+
o('INDEX_START INDENT IndexValue OUTDENT INDEX_END', function () {
|
644
|
+
return $3;
|
645
|
+
}),
|
646
|
+
o('INDEX_SOAK Index', function () {
|
647
|
+
return extend($2, {
|
648
|
+
soak: true,
|
649
|
+
});
|
650
|
+
}),
|
651
|
+
],
|
652
|
+
IndexValue: [
|
653
|
+
o('Expression', function () {
|
654
|
+
return new Index($1);
|
655
|
+
}),
|
656
|
+
o('Slice', function () {
|
657
|
+
return new Slice($1);
|
658
|
+
}),
|
659
|
+
],
|
660
|
+
// In CoffeeScript, an object literal is simply a list of assignments.
|
661
|
+
Object: [
|
662
|
+
o('{ AssignList OptComma }', function () {
|
663
|
+
return new Obj($2, $1.generated);
|
664
|
+
}),
|
665
|
+
],
|
666
|
+
// Assignment of properties within an object literal can be separated by
|
667
|
+
// comma, as in JavaScript, or simply by newline.
|
668
|
+
AssignList: [
|
669
|
+
o('', function () {
|
670
|
+
return [];
|
671
|
+
}),
|
672
|
+
o('AssignObj', function () {
|
673
|
+
return [$1];
|
674
|
+
}),
|
675
|
+
o('AssignList , AssignObj', function () {
|
676
|
+
return $1.concat($3);
|
677
|
+
}),
|
678
|
+
o('AssignList OptComma TERMINATOR AssignObj', function () {
|
679
|
+
return $1.concat($4);
|
680
|
+
}),
|
681
|
+
o('AssignList OptComma INDENT AssignList OptComma OUTDENT', function () {
|
682
|
+
return $1.concat($4);
|
683
|
+
}),
|
684
|
+
],
|
685
|
+
// Class definitions have optional bodies of prototype property assignments,
|
686
|
+
// and optional references to the superclass.
|
687
|
+
Class: [
|
688
|
+
o('CLASS', function () {
|
689
|
+
return new Class();
|
690
|
+
}),
|
691
|
+
o('CLASS Block', function () {
|
692
|
+
return new Class(null, null, $2);
|
693
|
+
}),
|
694
|
+
o('CLASS EXTENDS Expression', function () {
|
695
|
+
return new Class(null, $3);
|
696
|
+
}),
|
697
|
+
o('CLASS EXTENDS Expression Block', function () {
|
698
|
+
return new Class(null, $3, $4);
|
699
|
+
}),
|
700
|
+
o('CLASS SimpleAssignable', function () {
|
701
|
+
return new Class($2);
|
702
|
+
}),
|
703
|
+
o('CLASS SimpleAssignable Block', function () {
|
704
|
+
return new Class($2, null, $3);
|
705
|
+
}),
|
706
|
+
o('CLASS SimpleAssignable EXTENDS Expression', function () {
|
707
|
+
return new Class($2, $4);
|
708
|
+
}),
|
709
|
+
o('CLASS SimpleAssignable EXTENDS Expression Block', function () {
|
710
|
+
return new Class($2, $4, $5);
|
711
|
+
}),
|
712
|
+
],
|
713
|
+
Import: [
|
714
|
+
o('IMPORT String', function () {
|
715
|
+
return new ImportDeclaration(null, $2);
|
716
|
+
}),
|
717
|
+
o('IMPORT String ASSERT Object', function () {
|
718
|
+
return new ImportDeclaration(null, $2, $4);
|
719
|
+
}),
|
720
|
+
o('IMPORT ImportDefaultSpecifier FROM String', function () {
|
721
|
+
return new ImportDeclaration(new ImportClause($2, null), $4);
|
722
|
+
}),
|
723
|
+
o('IMPORT ImportDefaultSpecifier FROM String ASSERT Object', function () {
|
724
|
+
return new ImportDeclaration(new ImportClause($2, null), $4, $6);
|
725
|
+
}),
|
726
|
+
o('IMPORT ImportNamespaceSpecifier FROM String', function () {
|
727
|
+
return new ImportDeclaration(new ImportClause(null, $2), $4);
|
728
|
+
}),
|
729
|
+
o('IMPORT ImportNamespaceSpecifier FROM String ASSERT Object', function () {
|
730
|
+
return new ImportDeclaration(new ImportClause(null, $2), $4, $6);
|
731
|
+
}),
|
732
|
+
o('IMPORT { } FROM String', function () {
|
733
|
+
return new ImportDeclaration(new ImportClause(null, new ImportSpecifierList([])), $5);
|
734
|
+
}),
|
735
|
+
o('IMPORT { } FROM String ASSERT Object', function () {
|
736
|
+
return new ImportDeclaration(new ImportClause(null, new ImportSpecifierList([])), $5, $7);
|
737
|
+
}),
|
738
|
+
o('IMPORT { ImportSpecifierList OptComma } FROM String', function () {
|
739
|
+
return new ImportDeclaration(new ImportClause(null, new ImportSpecifierList($3)), $7);
|
740
|
+
}),
|
741
|
+
o('IMPORT { ImportSpecifierList OptComma } FROM String ASSERT Object', function () {
|
742
|
+
return new ImportDeclaration(new ImportClause(null, new ImportSpecifierList($3)), $7, $9);
|
743
|
+
}),
|
744
|
+
o('IMPORT ImportDefaultSpecifier , ImportNamespaceSpecifier FROM String', function () {
|
745
|
+
return new ImportDeclaration(new ImportClause($2, $4), $6);
|
746
|
+
}),
|
747
|
+
o('IMPORT ImportDefaultSpecifier , ImportNamespaceSpecifier FROM String ASSERT Object', function () {
|
748
|
+
return new ImportDeclaration(new ImportClause($2, $4), $6, $8);
|
749
|
+
}),
|
750
|
+
o('IMPORT ImportDefaultSpecifier , { ImportSpecifierList OptComma } FROM String', function () {
|
751
|
+
return new ImportDeclaration(new ImportClause($2, new ImportSpecifierList($5)), $9);
|
752
|
+
}),
|
753
|
+
o('IMPORT ImportDefaultSpecifier , { ImportSpecifierList OptComma } FROM String ASSERT Object', function () {
|
754
|
+
return new ImportDeclaration(new ImportClause($2, new ImportSpecifierList($5)), $9, $11);
|
755
|
+
}),
|
756
|
+
],
|
757
|
+
ImportSpecifierList: [
|
758
|
+
o('ImportSpecifier', function () {
|
759
|
+
return [$1];
|
760
|
+
}),
|
761
|
+
o('ImportSpecifierList , ImportSpecifier', function () {
|
762
|
+
return $1.concat($3);
|
763
|
+
}),
|
764
|
+
o('ImportSpecifierList OptComma TERMINATOR ImportSpecifier', function () {
|
765
|
+
return $1.concat($4);
|
766
|
+
}),
|
767
|
+
o('INDENT ImportSpecifierList OptComma OUTDENT', function () {
|
768
|
+
return $2;
|
769
|
+
}),
|
770
|
+
o('ImportSpecifierList OptComma INDENT ImportSpecifierList OptComma OUTDENT', function () {
|
771
|
+
return $1.concat($4);
|
772
|
+
}),
|
773
|
+
],
|
774
|
+
ImportSpecifier: [
|
775
|
+
o('Identifier', function () {
|
776
|
+
return new ImportSpecifier($1);
|
777
|
+
}),
|
778
|
+
o('Identifier AS Identifier', function () {
|
779
|
+
return new ImportSpecifier($1, $3);
|
780
|
+
}),
|
781
|
+
o('DEFAULT', function () {
|
782
|
+
return new ImportSpecifier(LOC(1)(new DefaultLiteral($1)));
|
783
|
+
}),
|
784
|
+
o('DEFAULT AS Identifier', function () {
|
785
|
+
return new ImportSpecifier(LOC(1)(new DefaultLiteral($1)), $3);
|
786
|
+
}),
|
787
|
+
],
|
788
|
+
ImportDefaultSpecifier: [
|
789
|
+
o('Identifier', function () {
|
790
|
+
return new ImportDefaultSpecifier($1);
|
791
|
+
}),
|
792
|
+
],
|
793
|
+
ImportNamespaceSpecifier: [
|
794
|
+
o('IMPORT_ALL AS Identifier', function () {
|
795
|
+
return new ImportNamespaceSpecifier(new Literal($1), $3);
|
796
|
+
}),
|
797
|
+
],
|
798
|
+
Export: [
|
799
|
+
o('EXPORT { }', function () {
|
800
|
+
return new ExportNamedDeclaration(new ExportSpecifierList([]));
|
801
|
+
}),
|
802
|
+
o('EXPORT { ExportSpecifierList OptComma }', function () {
|
803
|
+
return new ExportNamedDeclaration(new ExportSpecifierList($3));
|
804
|
+
}),
|
805
|
+
o('EXPORT Class', function () {
|
806
|
+
return new ExportNamedDeclaration($2);
|
807
|
+
}),
|
808
|
+
o('EXPORT Identifier = Expression', function () {
|
809
|
+
return new ExportNamedDeclaration(
|
810
|
+
LOC(
|
811
|
+
2,
|
812
|
+
4,
|
813
|
+
)(
|
814
|
+
new Assign($2, $4, null, {
|
815
|
+
moduleDeclaration: 'export',
|
816
|
+
}),
|
817
|
+
),
|
818
|
+
);
|
819
|
+
}),
|
820
|
+
o('EXPORT Identifier = TERMINATOR Expression', function () {
|
821
|
+
return new ExportNamedDeclaration(
|
822
|
+
LOC(
|
823
|
+
2,
|
824
|
+
5,
|
825
|
+
)(
|
826
|
+
new Assign($2, $5, null, {
|
827
|
+
moduleDeclaration: 'export',
|
828
|
+
}),
|
829
|
+
),
|
830
|
+
);
|
831
|
+
}),
|
832
|
+
o('EXPORT Identifier = INDENT Expression OUTDENT', function () {
|
833
|
+
return new ExportNamedDeclaration(
|
834
|
+
LOC(
|
835
|
+
2,
|
836
|
+
6,
|
837
|
+
)(
|
838
|
+
new Assign($2, $5, null, {
|
839
|
+
moduleDeclaration: 'export',
|
840
|
+
}),
|
841
|
+
),
|
842
|
+
);
|
843
|
+
}),
|
844
|
+
o('EXPORT DEFAULT Expression', function () {
|
845
|
+
return new ExportDefaultDeclaration($3);
|
846
|
+
}),
|
847
|
+
o('EXPORT DEFAULT INDENT Object OUTDENT', function () {
|
848
|
+
return new ExportDefaultDeclaration(new Value($4));
|
849
|
+
}),
|
850
|
+
o('EXPORT EXPORT_ALL FROM String', function () {
|
851
|
+
return new ExportAllDeclaration(new Literal($2), $4);
|
852
|
+
}),
|
853
|
+
o('EXPORT EXPORT_ALL FROM String ASSERT Object', function () {
|
854
|
+
return new ExportAllDeclaration(new Literal($2), $4, $6);
|
855
|
+
}),
|
856
|
+
o('EXPORT { } FROM String', function () {
|
857
|
+
return new ExportNamedDeclaration(new ExportSpecifierList([]), $5);
|
858
|
+
}),
|
859
|
+
o('EXPORT { } FROM String ASSERT Object', function () {
|
860
|
+
return new ExportNamedDeclaration(new ExportSpecifierList([]), $5, $7);
|
861
|
+
}),
|
862
|
+
o('EXPORT { ExportSpecifierList OptComma } FROM String', function () {
|
863
|
+
return new ExportNamedDeclaration(new ExportSpecifierList($3), $7);
|
864
|
+
}),
|
865
|
+
o('EXPORT { ExportSpecifierList OptComma } FROM String ASSERT Object', function () {
|
866
|
+
return new ExportNamedDeclaration(new ExportSpecifierList($3), $7, $9);
|
867
|
+
}),
|
868
|
+
],
|
869
|
+
ExportSpecifierList: [
|
870
|
+
o('ExportSpecifier', function () {
|
871
|
+
return [$1];
|
872
|
+
}),
|
873
|
+
o('ExportSpecifierList , ExportSpecifier', function () {
|
874
|
+
return $1.concat($3);
|
875
|
+
}),
|
876
|
+
o('ExportSpecifierList OptComma TERMINATOR ExportSpecifier', function () {
|
877
|
+
return $1.concat($4);
|
878
|
+
}),
|
879
|
+
o('INDENT ExportSpecifierList OptComma OUTDENT', function () {
|
880
|
+
return $2;
|
881
|
+
}),
|
882
|
+
o('ExportSpecifierList OptComma INDENT ExportSpecifierList OptComma OUTDENT', function () {
|
883
|
+
return $1.concat($4);
|
884
|
+
}),
|
885
|
+
],
|
886
|
+
ExportSpecifier: [
|
887
|
+
o('Identifier', function () {
|
888
|
+
return new ExportSpecifier($1);
|
889
|
+
}),
|
890
|
+
o('Identifier AS Identifier', function () {
|
891
|
+
return new ExportSpecifier($1, $3);
|
892
|
+
}),
|
893
|
+
o('Identifier AS DEFAULT', function () {
|
894
|
+
return new ExportSpecifier($1, LOC(3)(new DefaultLiteral($3)));
|
895
|
+
}),
|
896
|
+
o('DEFAULT', function () {
|
897
|
+
return new ExportSpecifier(LOC(1)(new DefaultLiteral($1)));
|
898
|
+
}),
|
899
|
+
o('DEFAULT AS Identifier', function () {
|
900
|
+
return new ExportSpecifier(LOC(1)(new DefaultLiteral($1)), $3);
|
901
|
+
}),
|
902
|
+
],
|
903
|
+
// Ordinary function invocation, or a chained series of calls.
|
904
|
+
Invocation: [
|
905
|
+
o('Value OptFuncExist String', function () {
|
906
|
+
return new TaggedTemplateCall($1, $3, $2.soak);
|
907
|
+
}),
|
908
|
+
o('Value OptFuncExist Arguments', function () {
|
909
|
+
return new Call($1, $3, $2.soak);
|
910
|
+
}),
|
911
|
+
o('SUPER OptFuncExist Arguments', function () {
|
912
|
+
return new SuperCall(LOC(1)(new Super()), $3, $2.soak, $1);
|
913
|
+
}),
|
914
|
+
o('DYNAMIC_IMPORT Arguments', function () {
|
915
|
+
return new DynamicImportCall(LOC(1)(new DynamicImport()), $2);
|
916
|
+
}),
|
917
|
+
],
|
918
|
+
// An optional existence check on a function.
|
919
|
+
OptFuncExist: [
|
920
|
+
o('', function () {
|
921
|
+
return {
|
922
|
+
soak: false,
|
923
|
+
};
|
924
|
+
}),
|
925
|
+
o('FUNC_EXIST', function () {
|
926
|
+
return {
|
927
|
+
soak: true,
|
928
|
+
};
|
929
|
+
}),
|
930
|
+
],
|
931
|
+
// The list of arguments to a function call.
|
932
|
+
Arguments: [
|
933
|
+
o('CALL_START CALL_END', function () {
|
934
|
+
return [];
|
935
|
+
}),
|
936
|
+
o('CALL_START ArgList OptComma CALL_END', function () {
|
937
|
+
$2.implicit = $1.generated;
|
938
|
+
return $2;
|
939
|
+
}),
|
940
|
+
],
|
941
|
+
// A reference to the *this* current object.
|
942
|
+
This: [
|
943
|
+
o('THIS', function () {
|
944
|
+
return new Value(new ThisLiteral($1));
|
945
|
+
}),
|
946
|
+
o('@', function () {
|
947
|
+
return new Value(new ThisLiteral($1));
|
948
|
+
}),
|
949
|
+
],
|
950
|
+
// A reference to a property on *this*.
|
951
|
+
ThisProperty: [
|
952
|
+
o('@ Property', function () {
|
953
|
+
return new Value(LOC(1)(new ThisLiteral($1)), [LOC(2)(new Access($2))], 'this');
|
954
|
+
}),
|
955
|
+
],
|
956
|
+
// The array literal.
|
957
|
+
Array: [
|
958
|
+
o('[ ]', function () {
|
959
|
+
return new Arr([]);
|
960
|
+
}),
|
961
|
+
o('[ Elisions ]', function () {
|
962
|
+
return new Arr($2);
|
963
|
+
}),
|
964
|
+
o('[ ArgElisionList OptElisions ]', function () {
|
965
|
+
return new Arr([].concat($2, $3));
|
966
|
+
}),
|
967
|
+
],
|
968
|
+
// Inclusive and exclusive range dots.
|
969
|
+
RangeDots: [
|
970
|
+
o('..', function () {
|
971
|
+
return {
|
972
|
+
exclusive: false,
|
973
|
+
};
|
974
|
+
}),
|
975
|
+
o('...', function () {
|
976
|
+
return {
|
977
|
+
exclusive: true,
|
978
|
+
};
|
979
|
+
}),
|
980
|
+
],
|
981
|
+
// The CoffeeScript range literal.
|
982
|
+
Range: [
|
983
|
+
o('[ Expression RangeDots Expression ]', function () {
|
984
|
+
return new Range($2, $4, $3.exclusive ? 'exclusive' : 'inclusive');
|
985
|
+
}),
|
986
|
+
o('[ ExpressionLine RangeDots Expression ]', function () {
|
987
|
+
return new Range($2, $4, $3.exclusive ? 'exclusive' : 'inclusive');
|
988
|
+
}),
|
989
|
+
],
|
990
|
+
// Array slice literals.
|
991
|
+
Slice: [
|
992
|
+
o('Expression RangeDots Expression', function () {
|
993
|
+
return new Range($1, $3, $2.exclusive ? 'exclusive' : 'inclusive');
|
994
|
+
}),
|
995
|
+
o('Expression RangeDots', function () {
|
996
|
+
return new Range($1, null, $2.exclusive ? 'exclusive' : 'inclusive');
|
997
|
+
}),
|
998
|
+
o('ExpressionLine RangeDots Expression', function () {
|
999
|
+
return new Range($1, $3, $2.exclusive ? 'exclusive' : 'inclusive');
|
1000
|
+
}),
|
1001
|
+
o('ExpressionLine RangeDots', function () {
|
1002
|
+
return new Range($1, null, $2.exclusive ? 'exclusive' : 'inclusive');
|
1003
|
+
}),
|
1004
|
+
o('RangeDots Expression', function () {
|
1005
|
+
return new Range(null, $2, $1.exclusive ? 'exclusive' : 'inclusive');
|
1006
|
+
}),
|
1007
|
+
o('RangeDots', function () {
|
1008
|
+
return new Range(null, null, $1.exclusive ? 'exclusive' : 'inclusive');
|
1009
|
+
}),
|
1010
|
+
],
|
1011
|
+
// The **ArgList** is the list of objects passed into a function call
|
1012
|
+
// (i.e. comma-separated expressions). Newlines work as well.
|
1013
|
+
ArgList: [
|
1014
|
+
o('Arg', function () {
|
1015
|
+
return [$1];
|
1016
|
+
}),
|
1017
|
+
o('ArgList , Arg', function () {
|
1018
|
+
return $1.concat($3);
|
1019
|
+
}),
|
1020
|
+
o('ArgList OptComma TERMINATOR Arg', function () {
|
1021
|
+
return $1.concat($4);
|
1022
|
+
}),
|
1023
|
+
o('INDENT ArgList OptComma OUTDENT', function () {
|
1024
|
+
return $2;
|
1025
|
+
}),
|
1026
|
+
o('ArgList OptComma INDENT ArgList OptComma OUTDENT', function () {
|
1027
|
+
return $1.concat($4);
|
1028
|
+
}),
|
1029
|
+
],
|
1030
|
+
// Valid arguments are Blocks or Splats.
|
1031
|
+
Arg: [
|
1032
|
+
o('Expression'),
|
1033
|
+
o('ExpressionLine'),
|
1034
|
+
o('Splat'),
|
1035
|
+
o('...', function () {
|
1036
|
+
return new Expansion();
|
1037
|
+
}),
|
1038
|
+
],
|
1039
|
+
// The **ArgElisionList** is the list of objects, contents of an array literal
|
1040
|
+
// (i.e. comma-separated expressions and elisions). Newlines work as well.
|
1041
|
+
ArgElisionList: [
|
1042
|
+
o('ArgElision'),
|
1043
|
+
o('ArgElisionList , ArgElision', function () {
|
1044
|
+
return $1.concat($3);
|
1045
|
+
}),
|
1046
|
+
o('ArgElisionList OptComma TERMINATOR ArgElision', function () {
|
1047
|
+
return $1.concat($4);
|
1048
|
+
}),
|
1049
|
+
o('INDENT ArgElisionList OptElisions OUTDENT', function () {
|
1050
|
+
return $2.concat($3);
|
1051
|
+
}),
|
1052
|
+
o('ArgElisionList OptElisions INDENT ArgElisionList OptElisions OUTDENT', function () {
|
1053
|
+
return $1.concat($2, $4, $5);
|
1054
|
+
}),
|
1055
|
+
],
|
1056
|
+
ArgElision: [
|
1057
|
+
o('Arg', function () {
|
1058
|
+
return [$1];
|
1059
|
+
}),
|
1060
|
+
o('Elisions Arg', function () {
|
1061
|
+
return $1.concat($2);
|
1062
|
+
}),
|
1063
|
+
],
|
1064
|
+
OptElisions: [
|
1065
|
+
o('OptComma', function () {
|
1066
|
+
return [];
|
1067
|
+
}),
|
1068
|
+
o(', Elisions', function () {
|
1069
|
+
return [].concat($2);
|
1070
|
+
}),
|
1071
|
+
],
|
1072
|
+
Elisions: [
|
1073
|
+
o('Elision', function () {
|
1074
|
+
return [$1];
|
1075
|
+
}),
|
1076
|
+
o('Elisions Elision', function () {
|
1077
|
+
return $1.concat($2);
|
1078
|
+
}),
|
1079
|
+
],
|
1080
|
+
Elision: [
|
1081
|
+
o(',', function () {
|
1082
|
+
return new Elision();
|
1083
|
+
}),
|
1084
|
+
o('Elision TERMINATOR', function () {
|
1085
|
+
return $1;
|
1086
|
+
}),
|
1087
|
+
],
|
1088
|
+
// Just simple, comma-separated, required arguments (no fancy syntax). We need
|
1089
|
+
// this to be separate from the **ArgList** for use in **Switch** blocks, where
|
1090
|
+
// having the newlines wouldn't make sense.
|
1091
|
+
SimpleArgs: [
|
1092
|
+
o('Expression'),
|
1093
|
+
o('ExpressionLine'),
|
1094
|
+
o('SimpleArgs , Expression', function () {
|
1095
|
+
return [].concat($1, $3);
|
1096
|
+
}),
|
1097
|
+
o('SimpleArgs , ExpressionLine', function () {
|
1098
|
+
return [].concat($1, $3);
|
1099
|
+
}),
|
1100
|
+
],
|
1101
|
+
// The variants of *try/catch/finally* exception handling blocks.
|
1102
|
+
Try: [
|
1103
|
+
o('TRY Block', function () {
|
1104
|
+
return new Try($2);
|
1105
|
+
}),
|
1106
|
+
o('TRY Block Catch', function () {
|
1107
|
+
return new Try($2, $3);
|
1108
|
+
}),
|
1109
|
+
o('TRY Block FINALLY Block', function () {
|
1110
|
+
return new Try($2, null, $4, LOC(3)(new Literal($3)));
|
1111
|
+
}),
|
1112
|
+
o('TRY Block Catch FINALLY Block', function () {
|
1113
|
+
return new Try($2, $3, $5, LOC(4)(new Literal($4)));
|
1114
|
+
}),
|
1115
|
+
],
|
1116
|
+
// A catch clause names its error and runs a block of code.
|
1117
|
+
Catch: [
|
1118
|
+
o('CATCH Identifier Block', function () {
|
1119
|
+
return new Catch($3, $2);
|
1120
|
+
}),
|
1121
|
+
o('CATCH Object Block', function () {
|
1122
|
+
return new Catch($3, LOC(2)(new Value($2)));
|
1123
|
+
}),
|
1124
|
+
o('CATCH Block', function () {
|
1125
|
+
return new Catch($2);
|
1126
|
+
}),
|
1127
|
+
],
|
1128
|
+
// Throw an exception object.
|
1129
|
+
Throw: [
|
1130
|
+
o('THROW Expression', function () {
|
1131
|
+
return new Throw($2);
|
1132
|
+
}),
|
1133
|
+
o('THROW INDENT Object OUTDENT', function () {
|
1134
|
+
return new Throw(new Value($3));
|
1135
|
+
}),
|
1136
|
+
],
|
1137
|
+
// Parenthetical expressions. Note that the **Parenthetical** is a **Value**,
|
1138
|
+
// not an **Expression**, so if you need to use an expression in a place
|
1139
|
+
// where only values are accepted, wrapping it in parentheses will always do
|
1140
|
+
// the trick.
|
1141
|
+
Parenthetical: [
|
1142
|
+
o('( Body )', function () {
|
1143
|
+
return new Parens($2);
|
1144
|
+
}),
|
1145
|
+
o('( INDENT Body OUTDENT )', function () {
|
1146
|
+
return new Parens($3);
|
1147
|
+
}),
|
1148
|
+
],
|
1149
|
+
// The condition portion of a while loop.
|
1150
|
+
WhileLineSource: [
|
1151
|
+
o('WHILE ExpressionLine', function () {
|
1152
|
+
return new While($2);
|
1153
|
+
}),
|
1154
|
+
o('WHILE ExpressionLine WHEN ExpressionLine', function () {
|
1155
|
+
return new While($2, {
|
1156
|
+
guard: $4,
|
1157
|
+
});
|
1158
|
+
}),
|
1159
|
+
o('UNTIL ExpressionLine', function () {
|
1160
|
+
return new While($2, {
|
1161
|
+
invert: true,
|
1162
|
+
});
|
1163
|
+
}),
|
1164
|
+
o('UNTIL ExpressionLine WHEN ExpressionLine', function () {
|
1165
|
+
return new While($2, {
|
1166
|
+
invert: true,
|
1167
|
+
guard: $4,
|
1168
|
+
});
|
1169
|
+
}),
|
1170
|
+
],
|
1171
|
+
WhileSource: [
|
1172
|
+
o('WHILE Expression', function () {
|
1173
|
+
return new While($2);
|
1174
|
+
}),
|
1175
|
+
o('WHILE Expression WHEN Expression', function () {
|
1176
|
+
return new While($2, {
|
1177
|
+
guard: $4,
|
1178
|
+
});
|
1179
|
+
}),
|
1180
|
+
o('WHILE ExpressionLine WHEN Expression', function () {
|
1181
|
+
return new While($2, {
|
1182
|
+
guard: $4,
|
1183
|
+
});
|
1184
|
+
}),
|
1185
|
+
o('UNTIL Expression', function () {
|
1186
|
+
return new While($2, {
|
1187
|
+
invert: true,
|
1188
|
+
});
|
1189
|
+
}),
|
1190
|
+
o('UNTIL Expression WHEN Expression', function () {
|
1191
|
+
return new While($2, {
|
1192
|
+
invert: true,
|
1193
|
+
guard: $4,
|
1194
|
+
});
|
1195
|
+
}),
|
1196
|
+
o('UNTIL ExpressionLine WHEN Expression', function () {
|
1197
|
+
return new While($2, {
|
1198
|
+
invert: true,
|
1199
|
+
guard: $4,
|
1200
|
+
});
|
1201
|
+
}),
|
1202
|
+
],
|
1203
|
+
// The while loop can either be normal, with a block of expressions to execute,
|
1204
|
+
// or postfix, with a single expression. There is no do..while.
|
1205
|
+
While: [
|
1206
|
+
o('WhileSource Block', function () {
|
1207
|
+
return $1.addBody($2);
|
1208
|
+
}),
|
1209
|
+
o('WhileLineSource Block', function () {
|
1210
|
+
return $1.addBody($2);
|
1211
|
+
}),
|
1212
|
+
o('Statement WhileSource', function () {
|
1213
|
+
return Object.assign($2, {
|
1214
|
+
postfix: true,
|
1215
|
+
}).addBody(LOC(1)(Block.wrap([$1])));
|
1216
|
+
}),
|
1217
|
+
o('Expression WhileSource', function () {
|
1218
|
+
return Object.assign($2, {
|
1219
|
+
postfix: true,
|
1220
|
+
}).addBody(LOC(1)(Block.wrap([$1])));
|
1221
|
+
}),
|
1222
|
+
o('Loop', function () {
|
1223
|
+
return $1;
|
1224
|
+
}),
|
1225
|
+
],
|
1226
|
+
Loop: [
|
1227
|
+
o('LOOP Block', function () {
|
1228
|
+
return new While(LOC(1)(new BooleanLiteral('true')), {
|
1229
|
+
isLoop: true,
|
1230
|
+
}).addBody($2);
|
1231
|
+
}),
|
1232
|
+
o('LOOP Expression', function () {
|
1233
|
+
return new While(LOC(1)(new BooleanLiteral('true')), {
|
1234
|
+
isLoop: true,
|
1235
|
+
}).addBody(LOC(2)(Block.wrap([$2])));
|
1236
|
+
}),
|
1237
|
+
],
|
1238
|
+
// Array, object, and range comprehensions, at the most generic level.
|
1239
|
+
// Comprehensions can either be normal, with a block of expressions to execute,
|
1240
|
+
// or postfix, with a single expression.
|
1241
|
+
For: [
|
1242
|
+
o('Statement ForBody', function () {
|
1243
|
+
$2.postfix = true;
|
1244
|
+
return $2.addBody($1);
|
1245
|
+
}),
|
1246
|
+
o('Expression ForBody', function () {
|
1247
|
+
$2.postfix = true;
|
1248
|
+
return $2.addBody($1);
|
1249
|
+
}),
|
1250
|
+
o('ForBody Block', function () {
|
1251
|
+
return $1.addBody($2);
|
1252
|
+
}),
|
1253
|
+
o('ForLineBody Block', function () {
|
1254
|
+
return $1.addBody($2);
|
1255
|
+
}),
|
1256
|
+
],
|
1257
|
+
ForBody: [
|
1258
|
+
o('FOR Range', function () {
|
1259
|
+
return new For([], {
|
1260
|
+
source: LOC(2)(new Value($2)),
|
1261
|
+
});
|
1262
|
+
}),
|
1263
|
+
o('FOR Range BY Expression', function () {
|
1264
|
+
return new For([], {
|
1265
|
+
source: LOC(2)(new Value($2)),
|
1266
|
+
step: $4,
|
1267
|
+
});
|
1268
|
+
}),
|
1269
|
+
o('ForStart ForSource', function () {
|
1270
|
+
return $1.addSource($2);
|
1271
|
+
}),
|
1272
|
+
],
|
1273
|
+
ForLineBody: [
|
1274
|
+
o('FOR Range BY ExpressionLine', function () {
|
1275
|
+
return new For([], {
|
1276
|
+
source: LOC(2)(new Value($2)),
|
1277
|
+
step: $4,
|
1278
|
+
});
|
1279
|
+
}),
|
1280
|
+
o('ForStart ForLineSource', function () {
|
1281
|
+
return $1.addSource($2);
|
1282
|
+
}),
|
1283
|
+
],
|
1284
|
+
ForStart: [
|
1285
|
+
o('FOR ForVariables', function () {
|
1286
|
+
return new For([], {
|
1287
|
+
name: $2[0],
|
1288
|
+
index: $2[1],
|
1289
|
+
});
|
1290
|
+
}),
|
1291
|
+
o('FOR AWAIT ForVariables', function () {
|
1292
|
+
var index, name;
|
1293
|
+
[name, index] = $3;
|
1294
|
+
return new For([], {
|
1295
|
+
name,
|
1296
|
+
index,
|
1297
|
+
await: true,
|
1298
|
+
awaitTag: LOC(2)(new Literal($2)),
|
1299
|
+
});
|
1300
|
+
}),
|
1301
|
+
o('FOR OWN ForVariables', function () {
|
1302
|
+
var index, name;
|
1303
|
+
[name, index] = $3;
|
1304
|
+
return new For([], {
|
1305
|
+
name,
|
1306
|
+
index,
|
1307
|
+
own: true,
|
1308
|
+
ownTag: LOC(2)(new Literal($2)),
|
1309
|
+
});
|
1310
|
+
}),
|
1311
|
+
],
|
1312
|
+
// An array of all accepted values for a variable inside the loop.
|
1313
|
+
// This enables support for pattern matching.
|
1314
|
+
ForValue: [
|
1315
|
+
o('Identifier'),
|
1316
|
+
o('ThisProperty'),
|
1317
|
+
o('Array', function () {
|
1318
|
+
return new Value($1);
|
1319
|
+
}),
|
1320
|
+
o('Object', function () {
|
1321
|
+
return new Value($1);
|
1322
|
+
}),
|
1323
|
+
],
|
1324
|
+
// An array or range comprehension has variables for the current element
|
1325
|
+
// and (optional) reference to the current index. Or, *key, value*, in the case
|
1326
|
+
// of object comprehensions.
|
1327
|
+
ForVariables: [
|
1328
|
+
o('ForValue', function () {
|
1329
|
+
return [$1];
|
1330
|
+
}),
|
1331
|
+
o('ForValue , ForValue', function () {
|
1332
|
+
return [$1, $3];
|
1333
|
+
}),
|
1334
|
+
],
|
1335
|
+
// The source of a comprehension is an array or object with an optional guard
|
1336
|
+
// clause. If it’s an array comprehension, you can also choose to step through
|
1337
|
+
// in fixed-size increments.
|
1338
|
+
ForSource: [
|
1339
|
+
o('FORIN Expression', function () {
|
1340
|
+
return {
|
1341
|
+
source: $2,
|
1342
|
+
};
|
1343
|
+
}),
|
1344
|
+
o('FOROF Expression', function () {
|
1345
|
+
return {
|
1346
|
+
source: $2,
|
1347
|
+
object: true,
|
1348
|
+
};
|
1349
|
+
}),
|
1350
|
+
o('FORIN Expression WHEN Expression', function () {
|
1351
|
+
return {
|
1352
|
+
source: $2,
|
1353
|
+
guard: $4,
|
1354
|
+
};
|
1355
|
+
}),
|
1356
|
+
o('FORIN ExpressionLine WHEN Expression', function () {
|
1357
|
+
return {
|
1358
|
+
source: $2,
|
1359
|
+
guard: $4,
|
1360
|
+
};
|
1361
|
+
}),
|
1362
|
+
o('FOROF Expression WHEN Expression', function () {
|
1363
|
+
return {
|
1364
|
+
source: $2,
|
1365
|
+
guard: $4,
|
1366
|
+
object: true,
|
1367
|
+
};
|
1368
|
+
}),
|
1369
|
+
o('FOROF ExpressionLine WHEN Expression', function () {
|
1370
|
+
return {
|
1371
|
+
source: $2,
|
1372
|
+
guard: $4,
|
1373
|
+
object: true,
|
1374
|
+
};
|
1375
|
+
}),
|
1376
|
+
o('FORIN Expression BY Expression', function () {
|
1377
|
+
return {
|
1378
|
+
source: $2,
|
1379
|
+
step: $4,
|
1380
|
+
};
|
1381
|
+
}),
|
1382
|
+
o('FORIN ExpressionLine BY Expression', function () {
|
1383
|
+
return {
|
1384
|
+
source: $2,
|
1385
|
+
step: $4,
|
1386
|
+
};
|
1387
|
+
}),
|
1388
|
+
o('FORIN Expression WHEN Expression BY Expression', function () {
|
1389
|
+
return {
|
1390
|
+
source: $2,
|
1391
|
+
guard: $4,
|
1392
|
+
step: $6,
|
1393
|
+
};
|
1394
|
+
}),
|
1395
|
+
o('FORIN ExpressionLine WHEN Expression BY Expression', function () {
|
1396
|
+
return {
|
1397
|
+
source: $2,
|
1398
|
+
guard: $4,
|
1399
|
+
step: $6,
|
1400
|
+
};
|
1401
|
+
}),
|
1402
|
+
o('FORIN Expression WHEN ExpressionLine BY Expression', function () {
|
1403
|
+
return {
|
1404
|
+
source: $2,
|
1405
|
+
guard: $4,
|
1406
|
+
step: $6,
|
1407
|
+
};
|
1408
|
+
}),
|
1409
|
+
o('FORIN ExpressionLine WHEN ExpressionLine BY Expression', function () {
|
1410
|
+
return {
|
1411
|
+
source: $2,
|
1412
|
+
guard: $4,
|
1413
|
+
step: $6,
|
1414
|
+
};
|
1415
|
+
}),
|
1416
|
+
o('FORIN Expression BY Expression WHEN Expression', function () {
|
1417
|
+
return {
|
1418
|
+
source: $2,
|
1419
|
+
step: $4,
|
1420
|
+
guard: $6,
|
1421
|
+
};
|
1422
|
+
}),
|
1423
|
+
o('FORIN ExpressionLine BY Expression WHEN Expression', function () {
|
1424
|
+
return {
|
1425
|
+
source: $2,
|
1426
|
+
step: $4,
|
1427
|
+
guard: $6,
|
1428
|
+
};
|
1429
|
+
}),
|
1430
|
+
o('FORIN Expression BY ExpressionLine WHEN Expression', function () {
|
1431
|
+
return {
|
1432
|
+
source: $2,
|
1433
|
+
step: $4,
|
1434
|
+
guard: $6,
|
1435
|
+
};
|
1436
|
+
}),
|
1437
|
+
o('FORIN ExpressionLine BY ExpressionLine WHEN Expression', function () {
|
1438
|
+
return {
|
1439
|
+
source: $2,
|
1440
|
+
step: $4,
|
1441
|
+
guard: $6,
|
1442
|
+
};
|
1443
|
+
}),
|
1444
|
+
o('FORFROM Expression', function () {
|
1445
|
+
return {
|
1446
|
+
source: $2,
|
1447
|
+
from: true,
|
1448
|
+
};
|
1449
|
+
}),
|
1450
|
+
o('FORFROM Expression WHEN Expression', function () {
|
1451
|
+
return {
|
1452
|
+
source: $2,
|
1453
|
+
guard: $4,
|
1454
|
+
from: true,
|
1455
|
+
};
|
1456
|
+
}),
|
1457
|
+
o('FORFROM ExpressionLine WHEN Expression', function () {
|
1458
|
+
return {
|
1459
|
+
source: $2,
|
1460
|
+
guard: $4,
|
1461
|
+
from: true,
|
1462
|
+
};
|
1463
|
+
}),
|
1464
|
+
],
|
1465
|
+
ForLineSource: [
|
1466
|
+
o('FORIN ExpressionLine', function () {
|
1467
|
+
return {
|
1468
|
+
source: $2,
|
1469
|
+
};
|
1470
|
+
}),
|
1471
|
+
o('FOROF ExpressionLine', function () {
|
1472
|
+
return {
|
1473
|
+
source: $2,
|
1474
|
+
object: true,
|
1475
|
+
};
|
1476
|
+
}),
|
1477
|
+
o('FORIN Expression WHEN ExpressionLine', function () {
|
1478
|
+
return {
|
1479
|
+
source: $2,
|
1480
|
+
guard: $4,
|
1481
|
+
};
|
1482
|
+
}),
|
1483
|
+
o('FORIN ExpressionLine WHEN ExpressionLine', function () {
|
1484
|
+
return {
|
1485
|
+
source: $2,
|
1486
|
+
guard: $4,
|
1487
|
+
};
|
1488
|
+
}),
|
1489
|
+
o('FOROF Expression WHEN ExpressionLine', function () {
|
1490
|
+
return {
|
1491
|
+
source: $2,
|
1492
|
+
guard: $4,
|
1493
|
+
object: true,
|
1494
|
+
};
|
1495
|
+
}),
|
1496
|
+
o('FOROF ExpressionLine WHEN ExpressionLine', function () {
|
1497
|
+
return {
|
1498
|
+
source: $2,
|
1499
|
+
guard: $4,
|
1500
|
+
object: true,
|
1501
|
+
};
|
1502
|
+
}),
|
1503
|
+
o('FORIN Expression BY ExpressionLine', function () {
|
1504
|
+
return {
|
1505
|
+
source: $2,
|
1506
|
+
step: $4,
|
1507
|
+
};
|
1508
|
+
}),
|
1509
|
+
o('FORIN ExpressionLine BY ExpressionLine', function () {
|
1510
|
+
return {
|
1511
|
+
source: $2,
|
1512
|
+
step: $4,
|
1513
|
+
};
|
1514
|
+
}),
|
1515
|
+
o('FORIN Expression WHEN Expression BY ExpressionLine', function () {
|
1516
|
+
return {
|
1517
|
+
source: $2,
|
1518
|
+
guard: $4,
|
1519
|
+
step: $6,
|
1520
|
+
};
|
1521
|
+
}),
|
1522
|
+
o('FORIN ExpressionLine WHEN Expression BY ExpressionLine', function () {
|
1523
|
+
return {
|
1524
|
+
source: $2,
|
1525
|
+
guard: $4,
|
1526
|
+
step: $6,
|
1527
|
+
};
|
1528
|
+
}),
|
1529
|
+
o('FORIN Expression WHEN ExpressionLine BY ExpressionLine', function () {
|
1530
|
+
return {
|
1531
|
+
source: $2,
|
1532
|
+
guard: $4,
|
1533
|
+
step: $6,
|
1534
|
+
};
|
1535
|
+
}),
|
1536
|
+
o('FORIN ExpressionLine WHEN ExpressionLine BY ExpressionLine', function () {
|
1537
|
+
return {
|
1538
|
+
source: $2,
|
1539
|
+
guard: $4,
|
1540
|
+
step: $6,
|
1541
|
+
};
|
1542
|
+
}),
|
1543
|
+
o('FORIN Expression BY Expression WHEN ExpressionLine', function () {
|
1544
|
+
return {
|
1545
|
+
source: $2,
|
1546
|
+
step: $4,
|
1547
|
+
guard: $6,
|
1548
|
+
};
|
1549
|
+
}),
|
1550
|
+
o('FORIN ExpressionLine BY Expression WHEN ExpressionLine', function () {
|
1551
|
+
return {
|
1552
|
+
source: $2,
|
1553
|
+
step: $4,
|
1554
|
+
guard: $6,
|
1555
|
+
};
|
1556
|
+
}),
|
1557
|
+
o('FORIN Expression BY ExpressionLine WHEN ExpressionLine', function () {
|
1558
|
+
return {
|
1559
|
+
source: $2,
|
1560
|
+
step: $4,
|
1561
|
+
guard: $6,
|
1562
|
+
};
|
1563
|
+
}),
|
1564
|
+
o('FORIN ExpressionLine BY ExpressionLine WHEN ExpressionLine', function () {
|
1565
|
+
return {
|
1566
|
+
source: $2,
|
1567
|
+
step: $4,
|
1568
|
+
guard: $6,
|
1569
|
+
};
|
1570
|
+
}),
|
1571
|
+
o('FORFROM ExpressionLine', function () {
|
1572
|
+
return {
|
1573
|
+
source: $2,
|
1574
|
+
from: true,
|
1575
|
+
};
|
1576
|
+
}),
|
1577
|
+
o('FORFROM Expression WHEN ExpressionLine', function () {
|
1578
|
+
return {
|
1579
|
+
source: $2,
|
1580
|
+
guard: $4,
|
1581
|
+
from: true,
|
1582
|
+
};
|
1583
|
+
}),
|
1584
|
+
o('FORFROM ExpressionLine WHEN ExpressionLine', function () {
|
1585
|
+
return {
|
1586
|
+
source: $2,
|
1587
|
+
guard: $4,
|
1588
|
+
from: true,
|
1589
|
+
};
|
1590
|
+
}),
|
1591
|
+
],
|
1592
|
+
Switch: [
|
1593
|
+
o('SWITCH Expression INDENT Whens OUTDENT', function () {
|
1594
|
+
return new Switch($2, $4);
|
1595
|
+
}),
|
1596
|
+
o('SWITCH ExpressionLine INDENT Whens OUTDENT', function () {
|
1597
|
+
return new Switch($2, $4);
|
1598
|
+
}),
|
1599
|
+
o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function () {
|
1600
|
+
return new Switch($2, $4, LOC(5, 6)($6));
|
1601
|
+
}),
|
1602
|
+
o('SWITCH ExpressionLine INDENT Whens ELSE Block OUTDENT', function () {
|
1603
|
+
return new Switch($2, $4, LOC(5, 6)($6));
|
1604
|
+
}),
|
1605
|
+
o('SWITCH INDENT Whens OUTDENT', function () {
|
1606
|
+
return new Switch(null, $3);
|
1607
|
+
}),
|
1608
|
+
o('SWITCH INDENT Whens ELSE Block OUTDENT', function () {
|
1609
|
+
return new Switch(null, $3, LOC(4, 5)($5));
|
1610
|
+
}),
|
1611
|
+
],
|
1612
|
+
Whens: [
|
1613
|
+
o('When', function () {
|
1614
|
+
return [$1];
|
1615
|
+
}),
|
1616
|
+
o('Whens When', function () {
|
1617
|
+
return $1.concat($2);
|
1618
|
+
}),
|
1619
|
+
],
|
1620
|
+
// An individual **When** clause, with action.
|
1621
|
+
When: [
|
1622
|
+
o('LEADING_WHEN SimpleArgs Block', function () {
|
1623
|
+
return new SwitchWhen($2, $3);
|
1624
|
+
}),
|
1625
|
+
o('LEADING_WHEN SimpleArgs Block TERMINATOR', function () {
|
1626
|
+
return LOC(1, 3)(new SwitchWhen($2, $3));
|
1627
|
+
}),
|
1628
|
+
],
|
1629
|
+
// The most basic form of *if* is a condition and an action. The following
|
1630
|
+
// if-related rules are broken up along these lines in order to avoid
|
1631
|
+
// ambiguity.
|
1632
|
+
IfBlock: [
|
1633
|
+
o('IF Expression Block', function () {
|
1634
|
+
return new If($2, $3, {
|
1635
|
+
type: $1,
|
1636
|
+
});
|
1637
|
+
}),
|
1638
|
+
o('IfBlock ELSE IF Expression Block', function () {
|
1639
|
+
return $1.addElse(
|
1640
|
+
LOC(
|
1641
|
+
3,
|
1642
|
+
5,
|
1643
|
+
)(
|
1644
|
+
new If($4, $5, {
|
1645
|
+
type: $3,
|
1646
|
+
}),
|
1647
|
+
),
|
1648
|
+
);
|
1649
|
+
}),
|
1650
|
+
],
|
1651
|
+
// The full complement of *if* expressions, including postfix one-liner
|
1652
|
+
// *if* and *unless*.
|
1653
|
+
If: [
|
1654
|
+
o('IfBlock'),
|
1655
|
+
o('IfBlock ELSE Block', function () {
|
1656
|
+
return $1.addElse($3);
|
1657
|
+
}),
|
1658
|
+
o('Statement POST_IF Expression', function () {
|
1659
|
+
return new If($3, LOC(1)(Block.wrap([$1])), {
|
1660
|
+
type: $2,
|
1661
|
+
postfix: true,
|
1662
|
+
});
|
1663
|
+
}),
|
1664
|
+
o('Expression POST_IF Expression', function () {
|
1665
|
+
return new If($3, LOC(1)(Block.wrap([$1])), {
|
1666
|
+
type: $2,
|
1667
|
+
postfix: true,
|
1668
|
+
});
|
1669
|
+
}),
|
1670
|
+
],
|
1671
|
+
IfBlockLine: [
|
1672
|
+
o('IF ExpressionLine Block', function () {
|
1673
|
+
return new If($2, $3, {
|
1674
|
+
type: $1,
|
1675
|
+
});
|
1676
|
+
}),
|
1677
|
+
o('IfBlockLine ELSE IF ExpressionLine Block', function () {
|
1678
|
+
return $1.addElse(
|
1679
|
+
LOC(
|
1680
|
+
3,
|
1681
|
+
5,
|
1682
|
+
)(
|
1683
|
+
new If($4, $5, {
|
1684
|
+
type: $3,
|
1685
|
+
}),
|
1686
|
+
),
|
1687
|
+
);
|
1688
|
+
}),
|
1689
|
+
],
|
1690
|
+
IfLine: [
|
1691
|
+
o('IfBlockLine'),
|
1692
|
+
o('IfBlockLine ELSE Block', function () {
|
1693
|
+
return $1.addElse($3);
|
1694
|
+
}),
|
1695
|
+
o('Statement POST_IF ExpressionLine', function () {
|
1696
|
+
return new If($3, LOC(1)(Block.wrap([$1])), {
|
1697
|
+
type: $2,
|
1698
|
+
postfix: true,
|
1699
|
+
});
|
1700
|
+
}),
|
1701
|
+
o('Expression POST_IF ExpressionLine', function () {
|
1702
|
+
return new If($3, LOC(1)(Block.wrap([$1])), {
|
1703
|
+
type: $2,
|
1704
|
+
postfix: true,
|
1705
|
+
});
|
1706
|
+
}),
|
1707
|
+
],
|
1708
|
+
// Arithmetic and logical operators, working on one or more operands.
|
1709
|
+
// Here they are grouped by order of precedence. The actual precedence rules
|
1710
|
+
// are defined at the bottom of the page. It would be shorter if we could
|
1711
|
+
// combine most of these rules into a single generic *Operand OpSymbol Operand*
|
1712
|
+
// -type rule, but in order to make the precedence binding possible, separate
|
1713
|
+
// rules are necessary.
|
1714
|
+
OperationLine: [
|
1715
|
+
o('UNARY ExpressionLine', function () {
|
1716
|
+
return new Op($1, $2);
|
1717
|
+
}),
|
1718
|
+
o('DO ExpressionLine', function () {
|
1719
|
+
return new Op($1, $2);
|
1720
|
+
}),
|
1721
|
+
o('DO_IIFE CodeLine', function () {
|
1722
|
+
return new Op($1, $2);
|
1723
|
+
}),
|
1724
|
+
],
|
1725
|
+
Operation: [
|
1726
|
+
o('UNARY Expression', function () {
|
1727
|
+
return new Op($1.toString(), $2, void 0, void 0, {
|
1728
|
+
originalOperator: $1.original,
|
1729
|
+
});
|
1730
|
+
}),
|
1731
|
+
o('DO Expression', function () {
|
1732
|
+
return new Op($1, $2);
|
1733
|
+
}),
|
1734
|
+
o('UNARY_MATH Expression', function () {
|
1735
|
+
return new Op($1, $2);
|
1736
|
+
}),
|
1737
|
+
o(
|
1738
|
+
'- Expression',
|
1739
|
+
function () {
|
1740
|
+
return new Op('-', $2);
|
1741
|
+
},
|
1742
|
+
{
|
1743
|
+
prec: 'UNARY_MATH',
|
1744
|
+
},
|
1745
|
+
),
|
1746
|
+
o(
|
1747
|
+
'+ Expression',
|
1748
|
+
function () {
|
1749
|
+
return new Op('+', $2);
|
1750
|
+
},
|
1751
|
+
{
|
1752
|
+
prec: 'UNARY_MATH',
|
1753
|
+
},
|
1754
|
+
),
|
1755
|
+
o('AWAIT Expression', function () {
|
1756
|
+
return new Op($1, $2);
|
1757
|
+
}),
|
1758
|
+
o('AWAIT INDENT Object OUTDENT', function () {
|
1759
|
+
return new Op($1, $3);
|
1760
|
+
}),
|
1761
|
+
o('-- SimpleAssignable', function () {
|
1762
|
+
return new Op('--', $2);
|
1763
|
+
}),
|
1764
|
+
o('++ SimpleAssignable', function () {
|
1765
|
+
return new Op('++', $2);
|
1766
|
+
}),
|
1767
|
+
o('SimpleAssignable --', function () {
|
1768
|
+
return new Op('--', $1, null, true);
|
1769
|
+
}),
|
1770
|
+
o('SimpleAssignable ++', function () {
|
1771
|
+
return new Op('++', $1, null, true);
|
1772
|
+
}),
|
1773
|
+
// [The existential operator](https://coffeescript.org/#existential-operator).
|
1774
|
+
o('Expression ?', function () {
|
1775
|
+
return new Existence($1);
|
1776
|
+
}),
|
1777
|
+
o('Expression + Expression', function () {
|
1778
|
+
return new Op('+', $1, $3);
|
1779
|
+
}),
|
1780
|
+
o('Expression - Expression', function () {
|
1781
|
+
return new Op('-', $1, $3);
|
1782
|
+
}),
|
1783
|
+
o('Expression MATH Expression', function () {
|
1784
|
+
return new Op($2, $1, $3);
|
1785
|
+
}),
|
1786
|
+
o('Expression ** Expression', function () {
|
1787
|
+
return new Op($2, $1, $3);
|
1788
|
+
}),
|
1789
|
+
o('Expression SHIFT Expression', function () {
|
1790
|
+
return new Op($2, $1, $3);
|
1791
|
+
}),
|
1792
|
+
o('Expression COMPARE Expression', function () {
|
1793
|
+
return new Op($2.toString(), $1, $3, void 0, {
|
1794
|
+
originalOperator: $2.original,
|
1795
|
+
});
|
1796
|
+
}),
|
1797
|
+
o('Expression & Expression', function () {
|
1798
|
+
return new Op($2, $1, $3);
|
1799
|
+
}),
|
1800
|
+
o('Expression ^ Expression', function () {
|
1801
|
+
return new Op($2, $1, $3);
|
1802
|
+
}),
|
1803
|
+
o('Expression | Expression', function () {
|
1804
|
+
return new Op($2, $1, $3);
|
1805
|
+
}),
|
1806
|
+
o('Expression && Expression', function () {
|
1807
|
+
return new Op($2.toString(), $1, $3, void 0, {
|
1808
|
+
originalOperator: $2.original,
|
1809
|
+
});
|
1810
|
+
}),
|
1811
|
+
o('Expression || Expression', function () {
|
1812
|
+
return new Op($2.toString(), $1, $3, void 0, {
|
1813
|
+
originalOperator: $2.original,
|
1814
|
+
});
|
1815
|
+
}),
|
1816
|
+
o('Expression BIN? Expression', function () {
|
1817
|
+
return new Op($2, $1, $3);
|
1818
|
+
}),
|
1819
|
+
o('Expression RELATION Expression', function () {
|
1820
|
+
var ref, ref1;
|
1821
|
+
return new Op($2.toString(), $1, $3, void 0, {
|
1822
|
+
invertOperator: (ref = (ref1 = $2.invert) != null ? ref1.original : void 0) != null ? ref : $2.invert,
|
1823
|
+
});
|
1824
|
+
}),
|
1825
|
+
o('SimpleAssignable COMPOUND_ASSIGN Expression', function () {
|
1826
|
+
return new Assign($1, $3, $2.toString(), {
|
1827
|
+
originalContext: $2.original,
|
1828
|
+
});
|
1829
|
+
}),
|
1830
|
+
o('SimpleAssignable COMPOUND_ASSIGN INDENT Expression OUTDENT', function () {
|
1831
|
+
return new Assign($1, $4, $2.toString(), {
|
1832
|
+
originalContext: $2.original,
|
1833
|
+
});
|
1834
|
+
}),
|
1835
|
+
o('SimpleAssignable COMPOUND_ASSIGN TERMINATOR Expression', function () {
|
1836
|
+
return new Assign($1, $4, $2.toString(), {
|
1837
|
+
originalContext: $2.original,
|
1838
|
+
});
|
1839
|
+
}),
|
1840
|
+
],
|
1841
|
+
DoIife: [
|
1842
|
+
o('DO_IIFE Code', function () {
|
1843
|
+
return new Op($1, $2);
|
1844
|
+
}),
|
1845
|
+
],
|
1846
|
+
};
|
2439
1847
|
|
2440
|
-
|
2441
|
-
|
1848
|
+
// Precedence
|
1849
|
+
// ----------
|
2442
1850
|
|
2443
|
-
|
2444
|
-
|
1851
|
+
// Operators at the top of this list have higher precedence than the ones lower
|
1852
|
+
// down. Following these rules is what makes `2 + 3 * 4` parse as:
|
2445
1853
|
|
2446
|
-
|
1854
|
+
// 2 + (3 * 4)
|
2447
1855
|
|
2448
|
-
|
1856
|
+
// And not:
|
2449
1857
|
|
2450
|
-
|
2451
|
-
|
1858
|
+
// (2 + 3) * 4
|
1859
|
+
operators = [
|
1860
|
+
['right', 'DO_IIFE'],
|
1861
|
+
['left', '.', '?.', '::', '?::'],
|
1862
|
+
['left', 'CALL_START', 'CALL_END'],
|
1863
|
+
['nonassoc', '++', '--'],
|
1864
|
+
['left', '?'],
|
1865
|
+
['right', 'UNARY', 'DO'],
|
1866
|
+
['right', 'AWAIT'],
|
1867
|
+
['right', '**'],
|
1868
|
+
['right', 'UNARY_MATH'],
|
1869
|
+
['left', 'MATH'],
|
1870
|
+
['left', '+', '-'],
|
1871
|
+
['left', 'SHIFT'],
|
1872
|
+
['left', 'RELATION'],
|
1873
|
+
['left', 'COMPARE'],
|
1874
|
+
['left', '&'],
|
1875
|
+
['left', '^'],
|
1876
|
+
['left', '|'],
|
1877
|
+
['left', '&&'],
|
1878
|
+
['left', '||'],
|
1879
|
+
['left', 'BIN?'],
|
1880
|
+
['nonassoc', 'INDENT', 'OUTDENT'],
|
1881
|
+
['right', 'YIELD'],
|
1882
|
+
['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'],
|
1883
|
+
['right', 'FORIN', 'FOROF', 'FORFROM', 'BY', 'WHEN'],
|
1884
|
+
['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS', 'IMPORT', 'EXPORT', 'DYNAMIC_IMPORT'],
|
1885
|
+
['left', 'POST_IF'],
|
1886
|
+
];
|
2452
1887
|
|
2453
|
-
|
2454
|
-
|
1888
|
+
// Wrapping Up
|
1889
|
+
// -----------
|
2455
1890
|
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
1891
|
+
// Finally, now that we have our **grammar** and our **operators**, we can create
|
1892
|
+
// our **Jison.Parser**. We do this by processing all of our rules, recording all
|
1893
|
+
// terminals (every symbol which does not appear as the name of a rule above)
|
1894
|
+
// as "tokens".
|
1895
|
+
tokens = [];
|
2461
1896
|
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2467
|
-
|
2468
|
-
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
// Initialize the **Parser** with our list of terminal **tokens**, our **grammar**
|
2486
|
-
// rules, and the name of the root. Reverse the operators because Jison orders
|
2487
|
-
// precedence from low to high, and we have it high to low
|
2488
|
-
// (as in [Yacc](http://dinosaur.compilertools.net/yacc/index.html)).
|
2489
|
-
exports.parser = new Parser({
|
2490
|
-
tokens: tokens.join(' '),
|
2491
|
-
bnf: grammar,
|
2492
|
-
operators: operators.reverse(),
|
2493
|
-
startSymbol: 'Root'
|
2494
|
-
});
|
1897
|
+
for (name in grammar) {
|
1898
|
+
alternatives = grammar[name];
|
1899
|
+
grammar[name] = (function () {
|
1900
|
+
var i, j, len, len1, ref, results;
|
1901
|
+
results = [];
|
1902
|
+
for (i = 0, len = alternatives.length; i < len; i++) {
|
1903
|
+
alt = alternatives[i];
|
1904
|
+
ref = alt[0].split(' ');
|
1905
|
+
for (j = 0, len1 = ref.length; j < len1; j++) {
|
1906
|
+
token = ref[j];
|
1907
|
+
if (!grammar[token]) {
|
1908
|
+
tokens.push(token);
|
1909
|
+
}
|
1910
|
+
}
|
1911
|
+
if (name === 'Root') {
|
1912
|
+
alt[1] = `return ${alt[1]}`;
|
1913
|
+
}
|
1914
|
+
results.push(alt);
|
1915
|
+
}
|
1916
|
+
return results;
|
1917
|
+
})();
|
1918
|
+
}
|
2495
1919
|
|
1920
|
+
// Initialize the **Parser** with our list of terminal **tokens**, our **grammar**
|
1921
|
+
// rules, and the name of the root. Reverse the operators because Jison orders
|
1922
|
+
// precedence from low to high, and we have it high to low
|
1923
|
+
// (as in [Yacc](http://dinosaur.compilertools.net/yacc/index.html)).
|
1924
|
+
exports.parser = new Parser({
|
1925
|
+
tokens: tokens.join(' '),
|
1926
|
+
bnf: grammar,
|
1927
|
+
operators: operators.reverse(),
|
1928
|
+
startSymbol: 'Root',
|
1929
|
+
});
|
2496
1930
|
}).call(this);
|