@bablr/language-en-es6 0.1.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,139 +1,331 @@
1
- /* @macrome
2
- * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#6042f078b7b381cf1100801b2c61981b32f17fc0
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 atrivialGrammar = class ES6Grammar extends (_importMixin = importMixin(classMixin(functionMixin(es5.atrivialGrammar)))) {
27
- static {
28
- [_initProto] = _applyDecs(this, [[AllowEmpty, 2, "Statement"], [_VariableDeclarationStatementDecs, 2, "VariableDeclarationStatement"], [_ForStatementDecs, 2, "ForStatement"], [Node, 2, "VariableDeclarator"], [Node, 2, "Property"]], [], 0, void 0, _importMixin).e;
29
- }
30
- constructor(...args) {
31
- super(...args);
32
- _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']);
33
62
  }
34
- *[(_VariableDeclarationStatementDecs = [CoveredBy('Statement'), Node], _ForStatementDecs = [CoveredBy('Statement'), Node], "Expression")](args) {
63
+
64
+ *Expression(args) {
35
65
  let {
36
- props: {
37
- power = 34,
38
- noIn = false
39
- },
40
- s
66
+ props: { power = 34, noIn = false },
67
+ getState,
41
68
  } = args;
69
+ let s = getState();
70
+ let yieldPower = 0; // TODO fixme
71
+
72
+ let sigil;
42
73
  let res;
43
74
  if (!s.holding) {
44
- 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({
45
- power
46
- })))) {} else if (res = yield eatMatch(m`<Identifier />`)) {}
47
- } else {
48
- if (res = yield eatMatch(m`<ArrowFunctionExpression /\g=\>/ />`)) {} else {
49
- res = yield eatMatch(m`<_LogicExpression />`, o({
50
- power,
51
- noIn
52
- }));
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
+ }
53
150
  }
151
+ } else if ((res = yield eatMatch(m`<TemplateString '\u0060' />`))) {
152
+ } else {
153
+ res = yield eat(m`<_LogicExpression />`, o({ power, noIn }));
54
154
  }
55
155
  if (res) {
56
- return shiftMatch(m`<__Expression />`, o({
57
- power
58
- }));
156
+ return r(shiftMatch(m`<_Expression />`, o({ power })));
59
157
  }
60
158
  }
159
+
61
160
  *Statement(args) {
62
- 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 {
63
- 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);
64
179
  }
65
180
  }
181
+
66
182
  *JSONExpression(args) {
67
- 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 {
68
188
  yield* super.JSONExpression(args);
69
189
  }
70
190
  }
71
- *VariableDeclarationStatement() {
72
- yield eat(m`sigilToken: <*Keyword /var|const|let/ />`);
191
+
192
+ *VariableDeclaration() {
193
+ yield eat(m`sigilToken*: <*Keyword /var|const|let/ />`);
194
+
73
195
  let sep = true;
74
196
  while (sep) {
75
- yield eatMatch(m`declarations[]: <VariableDeclarator />`);
76
- sep = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
197
+ yield eatMatch(m`declarations[]*: <VariableDeclarator />`);
198
+ sep = yield eatMatch(m`#separatorTokens: <* ',' />`);
77
199
  }
78
- yield eatMatch(m`endToken: <*Punctuator ';' />`, null, o({
79
- bind: true
80
- }));
200
+
201
+ yield eatMatch(m`endToken*: <* ';' />`);
81
202
  }
82
- *ForStatement() {
83
- yield eat(m`sigilToken: <*Keyword 'for' />`);
84
- yield eat(m`openHeaderToken: <*Punctuator '(' { balanced: ')' } />`);
85
- if (!(yield eatMatch(m`init+$: <VariableDeclarationStatement />`, o({
86
- noSemi: true
87
- })))) {
88
- yield eatMatch(m`init+$: <__Expression />`, o({
89
- noIn: true
90
- }));
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 }));
91
209
  }
92
- let source = yield eatMatch(m`inToken: <*Keyword /in|of/ />`, o({}), o({
93
- bind: true
94
- }));
210
+ let source = yield eatMatch(m`inToken*: <*Keyword /in|of/ />`);
95
211
  if (source) {
96
- yield eatMatch(m`source+$: <__Expression />`);
212
+ yield eatMatch(m`source+$: <_Expression />`);
97
213
  } else {
98
- yield eat(m`testSeparatorToken: <*Punctuator ';' />`);
99
- yield eatMatch(m`test+$: <__Expression />`);
100
- yield eat(m`updateSeparatorToken: <*Punctuator ';' />`);
101
- yield eatMatch(m`update+$: <__Expression />`);
214
+ yield eat(m`testSeparatorToken*: <* ';' />`);
215
+ yield eatMatch(m`test+$: <_Expression />`);
216
+ yield eat(m`updateSeparatorToken*: <* ';' />`);
217
+ yield eatMatch(m`update+$: <_Expression />`);
102
218
  }
103
- yield eat(m`closeHeaderToken: <*Punctuator ')' { balancer: true } />`);
104
- yield eat(m`body: <__Statement />`);
219
+ yield eat(m`closeHeaderToken*: <* ')' />`);
220
+ yield eat(m`body*: <_Statement />`);
105
221
  }
222
+
106
223
  *VariableDeclarator() {
107
224
  if (yield match('{')) {
108
- yield eat(m`target: <ObjectPattern />`);
225
+ yield eat(m`receiver*: <ObjectPattern />`);
109
226
  } else {
110
- yield eat(m`target: <Identifier />`);
227
+ yield eat(m`receiver*: <Identifier />`);
111
228
  }
112
- if (yield match(re`/=/s`)) {
113
- yield eat(m`assignmentOperator: <*Punctuator '=' />`);
114
- yield eat(m`value+$: <__Expression />`, o({
115
- power: 32
116
- }));
229
+
230
+ if (yield match('=')) {
231
+ yield eat(m`assignmentToken*: <* '=' />`);
232
+ yield eat(m`value+$: <_Expression />`, o({ power: 32 }));
117
233
  } else {
118
- yield eat(m`assignmentOperator: null`);
119
234
  yield eat(m`value+$: null`);
120
235
  }
121
236
  }
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 />`);
286
+ } else {
287
+ yield eat(m`<_ObjectKey />`);
288
+
289
+ return r(shift(m`<_ObjectElement />`));
290
+ }
291
+ }
292
+ }
293
+
122
294
  *Property() {
123
- yield eat(m`key$: <Identifier />`);
124
- let op = yield eatMatch(m`mapOperator: <*Punctuator ':' />`, o({}), o({
125
- bind: true
126
- }));
127
- if (op) {
128
- yield eat(m`value+$: <__Expression />`, o({
129
- power: 32
130
- }));
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 '...' />`)) {
131
311
  } else {
132
- yield eat(m`value+$: null`);
312
+ let { value } = yield eat(m`<_Expression />`, o({ power: 32 }), o({ shift: false }));
313
+ return value;
133
314
  }
134
315
  }
316
+
317
+ *SpreadElement() {
318
+ yield eat(m`sigilToken*: <* '...' />`);
319
+ yield eat(m`value+$: <_Expression />`, o({ power: 32 }));
320
+ }
135
321
  };
136
- export const grammar = triviaEnhancer({
137
- triviaIsAllowed: s => s.span === 'Bare',
138
- triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`
139
- }, 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,82 +1,79 @@
1
- /* @macrome
2
- * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./class.macro.js#4e159ba9b4b2272a008a11039caf5d564355a414
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, _ThisExpressionDecs;
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"], [_ThisExpressionDecs, 2, "ThisExpression"]], [], 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], _ThisExpressionDecs = [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' />`);
77
- }
78
- *ThisExpression() {
79
- yield eat(m`sigilToken: <*Keyword 'this' />`);
75
+ yield eat(m`sigilToken*: <*Keyword 'super' />`);
80
76
  }
81
77
  };
82
- };
78
+
79
+ export default mixin;