@bablr/language-en-es6 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/grammar.js +285 -103
- package/lib/mixins/class.js +53 -53
- package/lib/mixins/function.js +150 -96
- package/lib/mixins/import.js +66 -68
- package/lib/mixins/string.js +120 -0
- package/lib/regex.js +1 -1
- package/package.json +14 -14
- package/lib/grammar.macro.js +0 -162
- package/lib/mixins/class.macro.js +0 -86
- package/lib/mixins/function.macro.js +0 -144
- package/lib/mixins/import.macro.js +0 -160
package/lib/grammar.js
CHANGED
|
@@ -1,149 +1,331 @@
|
|
|
1
|
-
/* @macrome
|
|
2
|
-
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./grammar.macro.js#6db663572ef553014ae1495b3d21522c3bc88f0c
|
|
4
|
-
* This file is autogenerated. Please do not edit it directly.
|
|
5
|
-
* When editing run `npx macrome watch` then change the file this is generated from.
|
|
6
|
-
*/
|
|
7
|
-
import _applyDecs from "@babel/runtime/helpers/applyDecs2305";
|
|
8
|
-
var _importMixin;
|
|
9
|
-
let _initProto, _VariableDeclarationStatementDecs, _ForStatementDecs;
|
|
10
1
|
import { re, spam as m } from '@bablr/boot';
|
|
11
|
-
import {
|
|
12
|
-
|
|
2
|
+
import {
|
|
3
|
+
eat,
|
|
4
|
+
eatMatch,
|
|
5
|
+
shiftMatch,
|
|
6
|
+
match,
|
|
7
|
+
o,
|
|
8
|
+
r,
|
|
9
|
+
shift,
|
|
10
|
+
getInstrMatcher,
|
|
11
|
+
eatHeld,
|
|
12
|
+
} from '@bablr/helpers/grammar';
|
|
13
13
|
import { triviaEnhancer } from '@bablr/helpers/trivia';
|
|
14
|
-
import * as
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
|
|
14
|
+
import * as BTree from '@bablr/agast-helpers/btree';
|
|
15
|
+
import Space from '@bablr/language-en-blank-space';
|
|
16
|
+
import Comment from '@bablr/language-en-c-comments';
|
|
17
|
+
import {
|
|
18
|
+
default as es5,
|
|
19
|
+
reservedWords,
|
|
20
|
+
unaryPrefixOperatorAlternatives,
|
|
21
|
+
} from '@bablr/language-en-es5';
|
|
22
|
+
import classMixin from './mixins/class.js';
|
|
23
|
+
import importMixin from './mixins/import.js';
|
|
24
|
+
import functionMixin from './mixins/function.js';
|
|
25
|
+
import stringMixin from './mixins/string.js';
|
|
19
26
|
import { buildPattern } from '@bablr/helpers/builders';
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
|
|
27
|
+
import Regex from './regex.js';
|
|
28
|
+
import { getRoot, printSource } from '@bablr/agast-helpers/tree';
|
|
29
|
+
import { reifyMatcherReferenceName } from '@bablr/agast-vm-helpers';
|
|
30
|
+
import { Coroutine } from '@bablr/coroutine';
|
|
31
|
+
|
|
32
|
+
export const dependencies = { Comment, Space, Regex };
|
|
33
|
+
|
|
34
|
+
let runCo = (generator) => new Coroutine(generator).advance();
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
powerLevels,
|
|
38
|
+
reservedWords,
|
|
39
|
+
assignmentOperators,
|
|
40
|
+
assignmentOperatorAlternatives,
|
|
41
|
+
unaryPrefixOperators,
|
|
42
|
+
unaryPrefixOperatorAlternatives,
|
|
43
|
+
unaryPostfixOperators,
|
|
44
|
+
unaryPostfixOperatorAlternatives,
|
|
45
|
+
getBinaryOperatorAlternatives,
|
|
46
|
+
} from '@bablr/language-en-es5';
|
|
47
|
+
|
|
48
|
+
let reservedWords_ = new Set(reservedWords);
|
|
49
|
+
|
|
25
50
|
export const canonicalURL = 'https://bablr.org/languages/universe/es6';
|
|
26
|
-
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
|
|
52
|
+
export const defaultMatcher = m`_+: <_Expression />`;
|
|
53
|
+
|
|
54
|
+
let unaryMatcher;
|
|
55
|
+
|
|
56
|
+
const atrivial = class ES6Grammar extends importMixin(
|
|
57
|
+
classMixin(functionMixin(stringMixin(es5.grammar.atrivial))),
|
|
58
|
+
) {
|
|
59
|
+
constructor() {
|
|
60
|
+
super();
|
|
61
|
+
this.emptyables = new Set([...(this.emptyables || []), 'Statement']);
|
|
34
62
|
}
|
|
35
|
-
|
|
63
|
+
|
|
64
|
+
*Expression(args) {
|
|
36
65
|
let {
|
|
37
|
-
props: {
|
|
38
|
-
|
|
39
|
-
noIn = false
|
|
40
|
-
},
|
|
41
|
-
s
|
|
66
|
+
props: { power = 34, noIn = false },
|
|
67
|
+
getState,
|
|
42
68
|
} = args;
|
|
69
|
+
let s = getState();
|
|
70
|
+
let yieldPower = 0; // TODO fixme
|
|
71
|
+
|
|
72
|
+
let sigil;
|
|
43
73
|
let res;
|
|
44
74
|
if (!s.holding) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
sigil = yield match(
|
|
76
|
+
re`/[\u0060({['"/\d]|(?:yield|function|class|super|new|this|true|false|null|Infinity|NaN)\b/`,
|
|
77
|
+
);
|
|
78
|
+
switch (printSource(sigil)) {
|
|
79
|
+
case '`':
|
|
80
|
+
res = yield eat(m`<TemplateString />`);
|
|
81
|
+
break;
|
|
82
|
+
case '/':
|
|
83
|
+
res = yield eat(m`:Regex: <Pattern />`);
|
|
84
|
+
break;
|
|
85
|
+
case '(':
|
|
86
|
+
if ((res = yield eatMatch(m`<ArrowFunctionExpression />`))) {
|
|
87
|
+
} else {
|
|
88
|
+
res = yield eat(m`<ParenthesisExpression />`);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case 'yield':
|
|
92
|
+
if (power > yieldPower) {
|
|
93
|
+
res = yield eatMatch(m`<YieldExpression />`);
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case 'function':
|
|
97
|
+
res = yield eat(m`<FunctionExpression />`);
|
|
98
|
+
break;
|
|
99
|
+
case 'class':
|
|
100
|
+
res = yield eat(m`<ClassExpression />`);
|
|
101
|
+
break;
|
|
102
|
+
case 'super':
|
|
103
|
+
res = yield eat(m`<SuperExpression />`);
|
|
104
|
+
break;
|
|
105
|
+
case 'true':
|
|
106
|
+
case 'false':
|
|
107
|
+
case 'null':
|
|
108
|
+
case 'Infinity':
|
|
109
|
+
case 'NaN':
|
|
110
|
+
case '[':
|
|
111
|
+
case '{':
|
|
112
|
+
case '"':
|
|
113
|
+
case "'":
|
|
114
|
+
case '0':
|
|
115
|
+
case '1':
|
|
116
|
+
case '2':
|
|
117
|
+
case '3':
|
|
118
|
+
case '4':
|
|
119
|
+
case '5':
|
|
120
|
+
case '6':
|
|
121
|
+
case '7':
|
|
122
|
+
case '8':
|
|
123
|
+
case '9':
|
|
124
|
+
res = yield eat(m`<_JSONExpression />`);
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 'new':
|
|
128
|
+
if (power >= 4) {
|
|
129
|
+
res = yield eatMatch(m`<NewExpression />`, o({ power }));
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
case 'this':
|
|
134
|
+
res = yield eatMatch(m`<ThisExpression />`, o({ power }));
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
default: {
|
|
138
|
+
if (
|
|
139
|
+
power >= 4 &&
|
|
140
|
+
(res = yield eatMatch(
|
|
141
|
+
(unaryMatcher ??= m`<UnaryExpression ${buildPattern(
|
|
142
|
+
unaryPrefixOperatorAlternatives,
|
|
143
|
+
)} />`),
|
|
144
|
+
))
|
|
145
|
+
) {
|
|
146
|
+
} else {
|
|
147
|
+
res = yield eat(m`<Identifier />`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
54
150
|
}
|
|
151
|
+
} else if ((res = yield eatMatch(m`<TemplateString '\u0060' />`))) {
|
|
152
|
+
} else {
|
|
153
|
+
res = yield eat(m`<_LogicExpression />`, o({ power, noIn }));
|
|
55
154
|
}
|
|
56
155
|
if (res) {
|
|
57
|
-
return shiftMatch(m`<_Expression />`, o({
|
|
58
|
-
power
|
|
59
|
-
}));
|
|
156
|
+
return r(shiftMatch(m`<_Expression />`, o({ power })));
|
|
60
157
|
}
|
|
61
158
|
}
|
|
159
|
+
|
|
62
160
|
*Statement(args) {
|
|
63
|
-
|
|
64
|
-
|
|
161
|
+
let res = yield match(re`/import|export|class|var|const|let/`);
|
|
162
|
+
switch (printSource(res)) {
|
|
163
|
+
case 'import':
|
|
164
|
+
yield eat(m`<ImportDeclaration />`);
|
|
165
|
+
break;
|
|
166
|
+
case 'export':
|
|
167
|
+
yield eat(m`<ExportDeclaration />`);
|
|
168
|
+
break;
|
|
169
|
+
case 'class':
|
|
170
|
+
yield eat(m`<ClassDeclaration />`);
|
|
171
|
+
break;
|
|
172
|
+
case 'var':
|
|
173
|
+
case 'const':
|
|
174
|
+
case 'let':
|
|
175
|
+
yield eat(m`<VariableDeclaration />`);
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
yield* super.Statement(args);
|
|
65
179
|
}
|
|
66
180
|
}
|
|
181
|
+
|
|
67
182
|
*JSONExpression(args) {
|
|
68
|
-
if (yield eatMatch(m`<ClassExpression 'class' />`)) {
|
|
183
|
+
if (yield eatMatch(m`<ClassExpression 'class' />`)) {
|
|
184
|
+
} else if (yield eatMatch(m`<ThisExpression 'this' />`)) {
|
|
185
|
+
} else if (yield eatMatch(m`<SuperExpression 'super' />`)) {
|
|
186
|
+
} else if (yield eatMatch(m`<ArrowFunctionExpression '(' />`)) {
|
|
187
|
+
} else {
|
|
69
188
|
yield* super.JSONExpression(args);
|
|
70
189
|
}
|
|
71
190
|
}
|
|
72
|
-
|
|
73
|
-
|
|
191
|
+
|
|
192
|
+
*VariableDeclaration() {
|
|
193
|
+
yield eat(m`sigilToken*: <*Keyword /var|const|let/ />`);
|
|
194
|
+
|
|
74
195
|
let sep = true;
|
|
75
196
|
while (sep) {
|
|
76
|
-
yield eatMatch(m`declarations[]
|
|
77
|
-
sep = yield eatMatch(m`#separatorTokens
|
|
197
|
+
yield eatMatch(m`declarations[]*: <VariableDeclarator />`);
|
|
198
|
+
sep = yield eatMatch(m`#separatorTokens: <* ',' />`);
|
|
78
199
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}));
|
|
200
|
+
|
|
201
|
+
yield eatMatch(m`endToken*: <* ';' />`);
|
|
82
202
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
yield eat(m`
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
yield eatMatch(m`init+$: <_Expression />`, o({
|
|
90
|
-
noIn: true
|
|
91
|
-
}));
|
|
203
|
+
|
|
204
|
+
*For() {
|
|
205
|
+
yield eat(m`sigilToken*: <*Keyword 'for' />`);
|
|
206
|
+
yield eat(m`openHeaderToken*: <* '(' />`);
|
|
207
|
+
if (!(yield eatMatch(m`init+$: <VariableDeclaration />`, o({ noSemi: true })))) {
|
|
208
|
+
yield eatMatch(m`init+$: <_Expression />`, o({ noIn: true }));
|
|
92
209
|
}
|
|
93
|
-
let source = yield eatMatch(m`inToken
|
|
94
|
-
bind: true
|
|
95
|
-
}));
|
|
210
|
+
let source = yield eatMatch(m`inToken*: <*Keyword /in|of/ />`);
|
|
96
211
|
if (source) {
|
|
97
212
|
yield eatMatch(m`source+$: <_Expression />`);
|
|
98
213
|
} else {
|
|
99
|
-
yield eat(m`testSeparatorToken
|
|
214
|
+
yield eat(m`testSeparatorToken*: <* ';' />`);
|
|
100
215
|
yield eatMatch(m`test+$: <_Expression />`);
|
|
101
|
-
yield eat(m`updateSeparatorToken
|
|
216
|
+
yield eat(m`updateSeparatorToken*: <* ';' />`);
|
|
102
217
|
yield eatMatch(m`update+$: <_Expression />`);
|
|
103
218
|
}
|
|
104
|
-
yield eat(m`closeHeaderToken
|
|
105
|
-
yield eat(m`body
|
|
219
|
+
yield eat(m`closeHeaderToken*: <* ')' />`);
|
|
220
|
+
yield eat(m`body*: <_Statement />`);
|
|
106
221
|
}
|
|
222
|
+
|
|
107
223
|
*VariableDeclarator() {
|
|
108
224
|
if (yield match('{')) {
|
|
109
|
-
yield eat(m`
|
|
225
|
+
yield eat(m`receiver*: <ObjectPattern />`);
|
|
110
226
|
} else {
|
|
111
|
-
yield eat(m`
|
|
227
|
+
yield eat(m`receiver*: <Identifier />`);
|
|
112
228
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
yield eat(m`
|
|
116
|
-
|
|
117
|
-
}));
|
|
229
|
+
|
|
230
|
+
if (yield match('=')) {
|
|
231
|
+
yield eat(m`assignmentToken*: <* '=' />`);
|
|
232
|
+
yield eat(m`value+$: <_Expression />`, o({ power: 32 }));
|
|
118
233
|
} else {
|
|
119
|
-
yield eat(m`assignmentOperator: null`);
|
|
120
234
|
yield eat(m`value+$: null`);
|
|
121
235
|
}
|
|
122
236
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
237
|
+
|
|
238
|
+
*ObjectKey() {
|
|
239
|
+
if (yield eatMatch(m`<String /['"]/ />`)) {
|
|
240
|
+
} else if (yield eatMatch(m`<UnsignedInteger /\d/ />`)) {
|
|
241
|
+
} else if (yield eatMatch(m`<ComputedObjectKey '[' />`)) {
|
|
242
|
+
} else {
|
|
243
|
+
yield eat(m`<Identifier />`, o({ scoped: false }));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
*ComputedObjectKey() {
|
|
248
|
+
yield eat(m`openToken*: <* '[' />`);
|
|
249
|
+
yield eat(m`name+$: <_Expression />`);
|
|
250
|
+
yield eat(m`closeToken*: <* ']' />`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
*Method(args) {
|
|
254
|
+
let asyncToken = yield match('async');
|
|
255
|
+
let isSyncMethod = yield match(m`isSyncMethod*: <All />`, [(m`<* 'async' />`, m`<* '(' />`)]);
|
|
256
|
+
|
|
257
|
+
if (!asyncToken || !isSyncMethod) {
|
|
258
|
+
yield* super.Method(args);
|
|
259
|
+
} else {
|
|
260
|
+
let co = runCo(super.Method(args));
|
|
261
|
+
while (!co.done) {
|
|
262
|
+
let instr = co.value;
|
|
263
|
+
let refName = reifyMatcherReferenceName(getInstrMatcher(instr));
|
|
264
|
+
if (refName === 'asyncToken') {
|
|
265
|
+
co.advance(null);
|
|
266
|
+
} else {
|
|
267
|
+
co.advance(yield instr);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
*ObjectElement({ s }) {
|
|
274
|
+
if (s().held) {
|
|
275
|
+
if (yield eatMatch(m`<Property ':' />`)) {
|
|
276
|
+
} else {
|
|
277
|
+
yield eatMatch(m`<Method '(' />`);
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
280
|
+
let asyncToken = yield match('async');
|
|
281
|
+
let isAsyncMethod =
|
|
282
|
+
asyncToken && !(yield match(m`<All />`, [(m`<* 'async' />`, m`<* /[(:]/ />`)]));
|
|
283
|
+
|
|
284
|
+
if (isAsyncMethod) {
|
|
285
|
+
yield eat(m`<Method />`);
|
|
138
286
|
} else {
|
|
139
|
-
yield
|
|
140
|
-
|
|
141
|
-
|
|
287
|
+
yield eat(m`<_ObjectKey />`);
|
|
288
|
+
|
|
289
|
+
return r(shift(m`<_ObjectElement />`));
|
|
142
290
|
}
|
|
143
291
|
}
|
|
144
292
|
}
|
|
293
|
+
|
|
294
|
+
*Property() {
|
|
295
|
+
let key = yield eatHeld(m`key: <_ObjectKey />`);
|
|
296
|
+
let firstToken = printSource(BTree.getAt(-2, getRoot(key.node).value.bounds[0]).value.node);
|
|
297
|
+
let isIndex = /\d/.test(firstToken[0]);
|
|
298
|
+
let isComputed = firstToken === '[';
|
|
299
|
+
|
|
300
|
+
let cn =
|
|
301
|
+
isIndex || isComputed || reservedWords_.has(printSource(key.node))
|
|
302
|
+
? yield eat(m`mapOperator*: <* ':' />`)
|
|
303
|
+
: yield eatMatch(m`mapOperator*: <* ':' />`);
|
|
304
|
+
if (cn) {
|
|
305
|
+
yield eat(m`value+$: <_Expression />`, o({ power: 32 }));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
*Element() {
|
|
310
|
+
if (yield eatMatch(m`<SpreadElement '...' />`)) {
|
|
311
|
+
} else {
|
|
312
|
+
let { value } = yield eat(m`<_Expression />`, o({ power: 32 }), o({ shift: false }));
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
*SpreadElement() {
|
|
318
|
+
yield eat(m`sigilToken*: <* '...' />`);
|
|
319
|
+
yield eat(m`value+$: <_Expression />`, o({ power: 32 }));
|
|
320
|
+
}
|
|
145
321
|
};
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
322
|
+
|
|
323
|
+
export const grammar = triviaEnhancer(
|
|
324
|
+
{
|
|
325
|
+
triviaIsAllowed: (s) => s.span === 'Bare',
|
|
326
|
+
triviaMatcher: m`#: <__Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
|
|
327
|
+
},
|
|
328
|
+
atrivial,
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
export default { canonicalURL, dependencies, grammar, defaultMatcher };
|
package/lib/mixins/class.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
/* @macrome
|
|
2
|
-
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./class.macro.js#4ea6b11c85b1d7c1bedeff0c3d61fee7cfa5fb79
|
|
4
|
-
* This file is autogenerated. Please do not edit it directly.
|
|
5
|
-
* When editing run `npx macrome watch` then change the file this is generated from.
|
|
6
|
-
*/
|
|
7
|
-
import _applyDecs from "@babel/runtime/helpers/applyDecs2305";
|
|
8
1
|
import { spam as m } from '@bablr/boot';
|
|
9
|
-
import { CoveredBy, Node } from '@bablr/helpers/decorators';
|
|
10
2
|
import { o, eat, eatMatch, fail } from '@bablr/helpers/grammar';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
super(...args);
|
|
19
|
-
_initProto(this);
|
|
20
|
-
}
|
|
21
|
-
*[(_ClassExpressionDecs = [CoveredBy('Expression'), Node], _ClassMethodDecs = [CoveredBy('ClassMember'), Node], _SuperExpressionDecs = [CoveredBy('Expression'), Node], "ClassDeclaration")]() {
|
|
22
|
-
yield eat(m`sigilToken: <*Keyword 'class' />`);
|
|
3
|
+
import { List } from '@bablr/helpers/productions';
|
|
4
|
+
|
|
5
|
+
const mixin = (Base) =>
|
|
6
|
+
class ES6ClassGrammar extends Base {
|
|
7
|
+
*ClassDeclaration() {
|
|
8
|
+
yield eat(m`sigilToken*: <*Keyword 'class' />`);
|
|
9
|
+
|
|
23
10
|
yield eat(m`name$: <Identifier />`);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
yield eat(m`superClass$: <_Expression>`);
|
|
11
|
+
|
|
12
|
+
if (yield eatMatch(m`extendsToken*: <*Keyword 'extends' />`)) {
|
|
13
|
+
yield eat(m`superClass+$: <_Expression />`);
|
|
28
14
|
} else {
|
|
29
|
-
yield eat(m`superClass
|
|
15
|
+
yield eat(m`superClass+$: null`);
|
|
30
16
|
}
|
|
31
|
-
|
|
17
|
+
|
|
18
|
+
yield eat(m`body$: <ClassBody />`);
|
|
32
19
|
}
|
|
20
|
+
|
|
33
21
|
*ClassExpression() {
|
|
34
|
-
yield eat(m`sigilToken
|
|
22
|
+
yield eat(m`sigilToken*: <*Keyword 'class' />`);
|
|
23
|
+
|
|
35
24
|
yield eatMatch(m`name$: <Identifier />`);
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
|
|
26
|
+
if (yield eatMatch(m`extendsToken*: <*Keyword 'extends' />`)) {
|
|
27
|
+
yield eat(m`superClass+$: <_Expression />`);
|
|
38
28
|
} else {
|
|
39
|
-
yield eat(m`superClass
|
|
29
|
+
yield eat(m`superClass+$: null`);
|
|
40
30
|
}
|
|
41
|
-
|
|
31
|
+
|
|
32
|
+
yield eat(m`body$: <ClassBody />`);
|
|
42
33
|
}
|
|
34
|
+
|
|
43
35
|
*ClassBody() {
|
|
44
|
-
yield eat(m`openToken
|
|
45
|
-
while (yield eatMatch(m`members[]
|
|
46
|
-
yield eat(m`closeToken
|
|
36
|
+
yield eat(m`openToken*: <* '{' />`);
|
|
37
|
+
while (yield eatMatch(m`members[]$: <_ClassMember />`)) {}
|
|
38
|
+
yield eat(m`closeToken*: <* '}' />`);
|
|
47
39
|
}
|
|
40
|
+
|
|
48
41
|
*ClassMember() {
|
|
49
42
|
yield eat(m`<ClassMethod />`);
|
|
50
43
|
}
|
|
44
|
+
|
|
51
45
|
*ClassMethod() {
|
|
52
|
-
yield eatMatch(m`staticToken
|
|
46
|
+
yield eatMatch(m`staticToken*: <*Keyword 'static' />`);
|
|
53
47
|
let acc, a, gen;
|
|
54
|
-
acc = yield eatMatch(m`kindToken
|
|
48
|
+
acc = yield eatMatch(m`kindToken*: <*Keyword /get|set/ />`);
|
|
49
|
+
|
|
55
50
|
if (!acc) {
|
|
56
|
-
a = yield eatMatch(m`asyncToken
|
|
57
|
-
gen = yield eatMatch(m`starToken
|
|
58
|
-
} else {
|
|
59
|
-
yield eatMatch(m`asyncToken: null`);
|
|
60
|
-
yield eatMatch(m`starToken: null`);
|
|
51
|
+
a = yield eatMatch(m`asyncToken*: <*Keyword 'async' />`);
|
|
52
|
+
gen = yield eatMatch(m`starToken*: <* '*' />`);
|
|
61
53
|
}
|
|
54
|
+
|
|
62
55
|
if (a && gen) yield fail();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
|
|
57
|
+
if (yield eatMatch(m`openNameToken*: <* '[' />`)) {
|
|
58
|
+
yield eat(m`name+$: <_Expression />`);
|
|
59
|
+
yield eat(m`closeNameToken*: <* ']' />`);
|
|
60
|
+
} else {
|
|
61
|
+
yield eatMatch(m`name+$: <Identifier />`, o({}), o({ bind: true }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
yield eat(m`openParamsToken*: <* '(' />`);
|
|
65
|
+
yield* List({
|
|
66
|
+
element: m`params[]+$: <_CapturePattern />`,
|
|
69
67
|
allowTrailingSeparator: false,
|
|
70
|
-
separator: m`#separatorTokens
|
|
71
|
-
})
|
|
72
|
-
yield eat(m`closeParamsToken
|
|
73
|
-
yield eat(m`body
|
|
68
|
+
separator: m`#separatorTokens: <* ',' />`,
|
|
69
|
+
});
|
|
70
|
+
yield eat(m`closeParamsToken*: <* ')' />`);
|
|
71
|
+
yield eat(m`body$: <Block />`);
|
|
74
72
|
}
|
|
73
|
+
|
|
75
74
|
*SuperExpression() {
|
|
76
|
-
yield eat(m`sigilToken
|
|
75
|
+
yield eat(m`sigilToken*: <*Keyword 'super' />`);
|
|
77
76
|
}
|
|
78
77
|
};
|
|
79
|
-
|
|
78
|
+
|
|
79
|
+
export default mixin;
|