@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 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 { AllowEmpty, CoveredBy, Node } from '@bablr/helpers/decorators';
12
- import { eat, eatMatch, shiftMatch, match, o } from '@bablr/helpers/grammar';
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 Comment from '@bablr/language-en-c-comments';
15
- import * as es5 from '@bablr/language-en-es5';
16
- import { mixin as classMixin } from './mixins/class.js';
17
- import { mixin as importMixin } from './mixins/import.js';
18
- import { mixin as functionMixin } from './mixins/function.js';
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 { unaryPrefixOperatorAlternatives } from '@bablr/language-en-es5';
21
- export const dependencies = {
22
- Comment
23
- };
24
- export { powerLevels, reservedWords, assignmentOperators, assignmentOperatorAlternatives, unaryPrefixOperators, unaryPrefixOperatorAlternatives, unaryPostfixOperators, unaryPostfixOperatorAlternatives, getBinaryOperatorAlternatives } from '@bablr/language-en-es5';
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
- export const defaultMatcher = m`.+: <_Expression />`;
27
- export const atrivialGrammar = class ES6Grammar extends (_importMixin = importMixin(classMixin(functionMixin(es5.atrivialGrammar)))) {
28
- static {
29
- [_initProto] = _applyDecs(this, [[AllowEmpty, 2, "Statement"], [_VariableDeclarationStatementDecs, 2, "VariableDeclarationStatement"], [_ForStatementDecs, 2, "ForStatement"], [Node, 2, "VariableDeclarator"], [Node, 2, "Property"]], [], 0, void 0, _importMixin).e;
30
- }
31
- constructor(...args) {
32
- super(...args);
33
- _initProto(this);
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
- *[(_VariableDeclarationStatementDecs = [CoveredBy('Statement'), Node], _ForStatementDecs = [CoveredBy('Statement'), Node], "Expression")](args) {
63
+
64
+ *Expression(args) {
36
65
  let {
37
- props: {
38
- power = 34,
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
- if (res = yield eatMatch(m`<ArrowFunctionExpression '(' />`)) {} else if (res = yield eatMatch(m`<ParenthesisExpression '(' />`)) {} else if (res = yield eatMatch(m`<__JSONExpression />`)) {} else if (res = yield eatMatch(m`<FunctionExpression 'function' />`)) {} else if (power >= 4 && (res = yield eatMatch(m`<UnaryExpression ${buildPattern(unaryPrefixOperatorAlternatives)} />`))) {} else if (power >= 4 && (res = yield eatMatch(m`<NewExpression 'new' />`, o({
46
- power
47
- })))) {} else if (res = yield eatMatch(m`<Identifier />`)) {}
48
- } else {
49
- if (res = yield eatMatch(m`<ArrowFunctionExpression /\g=\>/ />`)) {} else {
50
- res = yield eatMatch(m`<__LogicExpression />`, o({
51
- power,
52
- noIn
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
- if (yield eatMatch(m`<ImportDeclaration 'import' />`)) {} else if (yield eatMatch(m`<ExportDeclaration 'export' />`)) {} else if (yield eatMatch(m`<ClassDeclaration 'class' />`)) {} else if (yield eatMatch(m`<YieldStatement 'yield' />`)) {} else if (yield eatMatch(m`<VariableDeclarationStatement /var|const|let/ />`)) {} else {
64
- yield* super.Statement(args);
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' />`)) {} else if (yield eatMatch(m`<ThisExpression 'this' />`)) {} else if (yield eatMatch(m`<SuperExpression 'super' />`)) {} else if (yield eatMatch(m`<ArrowFunctionExpression '(' />`)) {} else {
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
- *VariableDeclarationStatement() {
73
- yield eat(m`sigilToken: <*Keyword /var|const|let/ />`);
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[]: <VariableDeclarator />`);
77
- sep = yield eatMatch(m`#separatorTokens[]: <*Punctuator ',' />`);
197
+ yield eatMatch(m`declarations[]*: <VariableDeclarator />`);
198
+ sep = yield eatMatch(m`#separatorTokens: <* ',' />`);
78
199
  }
79
- yield eatMatch(m`endToken: <*Punctuator ';' />`, null, o({
80
- bind: true
81
- }));
200
+
201
+ yield eatMatch(m`endToken*: <* ';' />`);
82
202
  }
83
- *ForStatement() {
84
- yield eat(m`sigilToken: <*Keyword 'for' />`);
85
- yield eat(m`openHeaderToken: <*Punctuator '(' { balanced: ')' } />`);
86
- if (!(yield eatMatch(m`init+$: <VariableDeclarationStatement />`, o({
87
- noSemi: true
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: <*Keyword /in|of/ />`, o({}), o({
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: <*Punctuator ';' />`);
214
+ yield eat(m`testSeparatorToken*: <* ';' />`);
100
215
  yield eatMatch(m`test+$: <_Expression />`);
101
- yield eat(m`updateSeparatorToken: <*Punctuator ';' />`);
216
+ yield eat(m`updateSeparatorToken*: <* ';' />`);
102
217
  yield eatMatch(m`update+$: <_Expression />`);
103
218
  }
104
- yield eat(m`closeHeaderToken: <*Punctuator ')' { balancer: true } />`);
105
- yield eat(m`body: <_Statement />`);
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`target: <ObjectPattern />`);
225
+ yield eat(m`receiver*: <ObjectPattern />`);
110
226
  } else {
111
- yield eat(m`target: <Identifier />`);
227
+ yield eat(m`receiver*: <Identifier />`);
112
228
  }
113
- if (yield match(re`/=/s`)) {
114
- yield eat(m`assignmentOperator: <*Punctuator '=' />`);
115
- yield eat(m`value+$: <_Expression />`, o({
116
- power: 32
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
- *Property() {
124
- if (yield match(re`/['"]/`)) {
125
- yield eat(m`key$: <String />`);
126
- yield eat(m`mapOperator: <*Punctuator ':' />`);
127
- yield eat(m`value+$: <_Expression />`, o({
128
- power: 32
129
- }));
130
- } else if (yield eatMatch(m`key$: <Identifier />`)) {
131
- let cn = yield eatMatch(m`mapOperator: <*Punctuator ':' />`, null, o({
132
- bind: true
133
- }));
134
- if (cn) {
135
- yield eat(m`value+$: <_Expression />`, o({
136
- power: 32
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 eatMatch(m`value+$: <FunctionExpression />`, o({
140
- shorthand: true
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
- export const grammar = triviaEnhancer({
147
- triviaIsAllowed: s => s.span === 'Bare',
148
- triviaMatcher: m`#: :Comment: <__Trivia /[ \n\r\t]|\/\/|\/\*/ />`
149
- }, atrivialGrammar);
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 };
@@ -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
- export const mixin = Base => {
12
- let _initProto, _ClassExpressionDecs, _ClassMethodDecs, _SuperExpressionDecs;
13
- return class ES6ClassGrammar extends Base {
14
- static {
15
- [_initProto] = _applyDecs(this, [[Node, 2, "ClassDeclaration"], [_ClassExpressionDecs, 2, "ClassExpression"], [Node, 2, "ClassBody"], [_ClassMethodDecs, 2, "ClassMethod"], [_SuperExpressionDecs, 2, "SuperExpression"]], [], 0, void 0, Base).e;
16
- }
17
- constructor(...args) {
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
- if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`, o({}), o({
25
- bind: true
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$: null`);
15
+ yield eat(m`superClass+$: null`);
30
16
  }
31
- yield eat(m`body: <ClassBody />`);
17
+
18
+ yield eat(m`body$: <ClassBody />`);
32
19
  }
20
+
33
21
  *ClassExpression() {
34
- yield eat(m`sigilToken: <*Keyword 'class' />`);
22
+ yield eat(m`sigilToken*: <*Keyword 'class' />`);
23
+
35
24
  yield eatMatch(m`name$: <Identifier />`);
36
- if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`)) {
37
- yield eat(m`superClass$: <_Expression>`);
25
+
26
+ if (yield eatMatch(m`extendsToken*: <*Keyword 'extends' />`)) {
27
+ yield eat(m`superClass+$: <_Expression />`);
38
28
  } else {
39
- yield eat(m`superClass$: null`);
29
+ yield eat(m`superClass+$: null`);
40
30
  }
41
- yield eat(m`body: <ClassBody />`);
31
+
32
+ yield eat(m`body$: <ClassBody />`);
42
33
  }
34
+
43
35
  *ClassBody() {
44
- yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
45
- while (yield eatMatch(m`members[]: <_ClassMember />`)) {}
46
- yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
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: <*Keyword 'static' />`);
46
+ yield eatMatch(m`staticToken*: <*Keyword 'static' />`);
53
47
  let acc, a, gen;
54
- acc = yield eatMatch(m`kindToken: <*Keyword /get|set/ />`);
48
+ acc = yield eatMatch(m`kindToken*: <*Keyword /get|set/ />`);
49
+
55
50
  if (!acc) {
56
- a = yield eatMatch(m`asyncToken: <*Keyword 'async' />`);
57
- gen = yield eatMatch(m`starToken: <*Punctuator '*' />`);
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
- yield eatMatch(m`id: <Identifier />`, o({}), o({
64
- bind: true
65
- }));
66
- yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`);
67
- yield eat(m`params[]: <__List />`, o({
68
- element: m`<Identifier />`,
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[]: <*Punctuator ',' />`
71
- }));
72
- yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
73
- yield eat(m`body: <BlockStatement />`);
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: <*Keyword 'super' />`);
75
+ yield eat(m`sigilToken*: <*Keyword 'super' />`);
77
76
  }
78
77
  };
79
- };
78
+
79
+ export default mixin;