@bablr/language-en-es6 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Conrad Buck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/grammar.js ADDED
@@ -0,0 +1,139 @@
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
+ 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';
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';
19
+ 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';
25
+ 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);
33
+ }
34
+ *[(_VariableDeclarationStatementDecs = [CoveredBy('Statement'), Node], _ForStatementDecs = [CoveredBy('Statement'), Node], "Expression")](args) {
35
+ let {
36
+ props: {
37
+ power = 34,
38
+ noIn = false
39
+ },
40
+ s
41
+ } = args;
42
+ let res;
43
+ 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
+ }));
53
+ }
54
+ }
55
+ if (res) {
56
+ return shiftMatch(m`<__Expression />`, o({
57
+ power
58
+ }));
59
+ }
60
+ }
61
+ *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);
64
+ }
65
+ }
66
+ *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 {
68
+ yield* super.JSONExpression(args);
69
+ }
70
+ }
71
+ *VariableDeclarationStatement() {
72
+ yield eat(m`sigilToken: <*Keyword /var|const|let/ />`);
73
+ let sep = true;
74
+ while (sep) {
75
+ yield eatMatch(m`declarations[]: <VariableDeclarator />`);
76
+ sep = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
77
+ }
78
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, null, o({
79
+ bind: true
80
+ }));
81
+ }
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
+ }));
91
+ }
92
+ let source = yield eatMatch(m`inToken: <*Keyword /in|of/ />`, o({}), o({
93
+ bind: true
94
+ }));
95
+ if (source) {
96
+ yield eatMatch(m`source+$: <__Expression />`);
97
+ } 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 />`);
102
+ }
103
+ yield eat(m`closeHeaderToken: <*Punctuator ')' { balancer: true } />`);
104
+ yield eat(m`body: <__Statement />`);
105
+ }
106
+ *VariableDeclarator() {
107
+ if (yield match('{')) {
108
+ yield eat(m`target: <ObjectPattern />`);
109
+ } else {
110
+ yield eat(m`target: <Identifier />`);
111
+ }
112
+ if (yield match(re`/=/s`)) {
113
+ yield eat(m`assignmentOperator: <*Punctuator '=' />`);
114
+ yield eat(m`value+$: <__Expression />`, o({
115
+ power: 32
116
+ }));
117
+ } else {
118
+ yield eat(m`assignmentOperator: null`);
119
+ yield eat(m`value+$: null`);
120
+ }
121
+ }
122
+ *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
+ }));
131
+ } else {
132
+ yield eat(m`value+$: null`);
133
+ }
134
+ }
135
+ };
136
+ export const grammar = triviaEnhancer({
137
+ triviaIsAllowed: s => s.span === 'Bare',
138
+ triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`
139
+ }, atrivialGrammar);
@@ -0,0 +1,155 @@
1
+ import { re, spam as m } from '@bablr/boot';
2
+ import { AllowEmpty, CoveredBy, Node } from '@bablr/helpers/decorators';
3
+ import { eat, eatMatch, shiftMatch, match, o } from '@bablr/helpers/grammar';
4
+ import { triviaEnhancer } from '@bablr/helpers/trivia';
5
+ import * as Comment from '@bablr/language-en-c-comments';
6
+ import * as es5 from '@bablr/language-en-es5';
7
+ import { mixin as classMixin } from './mixins/class.js';
8
+ import { mixin as importMixin } from './mixins/import.js';
9
+ import { mixin as functionMixin } from './mixins/function.js';
10
+ import { buildPattern } from '@bablr/helpers/builders';
11
+ import { unaryPrefixOperatorAlternatives } from '@bablr/language-en-es5';
12
+
13
+ export const dependencies = { Comment };
14
+
15
+ export {
16
+ powerLevels,
17
+ reservedWords,
18
+ assignmentOperators,
19
+ assignmentOperatorAlternatives,
20
+ unaryPrefixOperators,
21
+ unaryPrefixOperatorAlternatives,
22
+ unaryPostfixOperators,
23
+ unaryPostfixOperatorAlternatives,
24
+ getBinaryOperatorAlternatives,
25
+ } from '@bablr/language-en-es5';
26
+
27
+ export const canonicalURL = 'https://bablr.org/languages/universe/es6';
28
+
29
+ export const atrivialGrammar = class ES6Grammar extends importMixin(
30
+ classMixin(functionMixin(es5.atrivialGrammar)),
31
+ ) {
32
+ *Expression(args) {
33
+ let {
34
+ props: { power = 34, noIn = false },
35
+ s,
36
+ } = args;
37
+ let res;
38
+ if (!s.holding) {
39
+ if ((res = yield eatMatch(m`<ArrowFunctionExpression '(' />`))) {
40
+ } else if ((res = yield eatMatch(m`<ParenthesisExpression '(' />`))) {
41
+ } else if ((res = yield eatMatch(m`<_JSONExpression />`))) {
42
+ } else if ((res = yield eatMatch(m`<FunctionExpression 'function' />`))) {
43
+ } else if (
44
+ power >= 4 &&
45
+ (res = yield eatMatch(
46
+ m`<UnaryExpression ${buildPattern(unaryPrefixOperatorAlternatives)} />`,
47
+ ))
48
+ ) {
49
+ } else if (power >= 4 && (res = yield eatMatch(m`<NewExpression 'new' />`, o({ power })))) {
50
+ } else if ((res = yield eatMatch(m`<Identifier />`))) {
51
+ }
52
+ } else {
53
+ if ((res = yield eatMatch(m`<ArrowFunctionExpression /\g=\>/ />`))) {
54
+ } else {
55
+ res = yield eatMatch(m`<_LogicExpression />`, o({ power, noIn }));
56
+ }
57
+ }
58
+ if (res) {
59
+ return shiftMatch(m`<__Expression />`, o({ power }));
60
+ }
61
+ }
62
+
63
+ @AllowEmpty
64
+ *Statement(args) {
65
+ if (yield eatMatch(m`<ImportDeclaration 'import' />`)) {
66
+ } else if (yield eatMatch(m`<ExportDeclaration 'export' />`)) {
67
+ } else if (yield eatMatch(m`<ClassDeclaration 'class' />`)) {
68
+ } else if (yield eatMatch(m`<YieldStatement 'yield' />`)) {
69
+ } else if (yield eatMatch(m`<VariableDeclarationStatement /var|const|let/ />`)) {
70
+ } else {
71
+ yield* super.Statement(args);
72
+ }
73
+ }
74
+
75
+ *JSONExpression(args) {
76
+ if (yield eatMatch(m`<ClassExpression 'class' />`)) {
77
+ } else if (yield eatMatch(m`<ThisExpression 'this' />`)) {
78
+ } else if (yield eatMatch(m`<SuperExpression 'super' />`)) {
79
+ } else if (yield eatMatch(m`<ArrowFunctionExpression '(' />`)) {
80
+ } else {
81
+ yield* super.JSONExpression(args);
82
+ }
83
+ }
84
+
85
+ @CoveredBy('Statement')
86
+ @Node
87
+ *VariableDeclarationStatement() {
88
+ yield eat(m`sigilToken: <*Keyword /var|const|let/ />`);
89
+
90
+ let sep = true;
91
+ while (sep) {
92
+ yield eatMatch(m`declarations[]: <VariableDeclarator />`);
93
+ sep = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
94
+ }
95
+
96
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, null, o({ bind: true }));
97
+ }
98
+
99
+ @CoveredBy('Statement')
100
+ @Node
101
+ *ForStatement() {
102
+ yield eat(m`sigilToken: <*Keyword 'for' />`);
103
+ yield eat(m`openHeaderToken: <*Punctuator '(' { balanced: ')' } />`);
104
+ if (!(yield eatMatch(m`init+$: <VariableDeclarationStatement />`, o({ noSemi: true })))) {
105
+ yield eatMatch(m`init+$: <__Expression />`, o({ noIn: true }));
106
+ }
107
+ let source = yield eatMatch(m`inToken: <*Keyword /in|of/ />`, o({}), o({ bind: true }));
108
+ if (source) {
109
+ yield eatMatch(m`source+$: <__Expression />`);
110
+ } else {
111
+ yield eat(m`testSeparatorToken: <*Punctuator ';' />`);
112
+ yield eatMatch(m`test+$: <__Expression />`);
113
+ yield eat(m`updateSeparatorToken: <*Punctuator ';' />`);
114
+ yield eatMatch(m`update+$: <__Expression />`);
115
+ }
116
+ yield eat(m`closeHeaderToken: <*Punctuator ')' { balancer: true } />`);
117
+ yield eat(m`body: <__Statement />`);
118
+ }
119
+
120
+ @Node
121
+ *VariableDeclarator() {
122
+ if (yield match('{')) {
123
+ yield eat(m`target: <ObjectPattern />`);
124
+ } else {
125
+ yield eat(m`target: <Identifier />`);
126
+ }
127
+
128
+ if (yield match(re`/=/s`)) {
129
+ yield eat(m`assignmentOperator: <*Punctuator '=' />`);
130
+ yield eat(m`value+$: <__Expression />`, o({ power: 32 }));
131
+ } else {
132
+ yield eat(m`assignmentOperator: null`);
133
+ yield eat(m`value+$: null`);
134
+ }
135
+ }
136
+
137
+ @Node
138
+ *Property() {
139
+ yield eat(m`key$: <Identifier />`);
140
+ let op = yield eatMatch(m`mapOperator: <*Punctuator ':' />`, o({}), o({ bind: true }));
141
+ if (op) {
142
+ yield eat(m`value+$: <__Expression />`, o({ power: 32 }));
143
+ } else {
144
+ yield eat(m`value+$: null`);
145
+ }
146
+ }
147
+ };
148
+
149
+ export const grammar = triviaEnhancer(
150
+ {
151
+ triviaIsAllowed: (s) => s.span === 'Bare',
152
+ triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
153
+ },
154
+ atrivialGrammar,
155
+ );
@@ -0,0 +1,82 @@
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
+ import { spam as m } from '@bablr/boot';
9
+ import { CoveredBy, Node } from '@bablr/helpers/decorators';
10
+ 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' />`);
23
+ 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>`);
28
+ } else {
29
+ yield eat(m`superClass$: null`);
30
+ }
31
+ yield eat(m`body: <ClassBody />`);
32
+ }
33
+ *ClassExpression() {
34
+ yield eat(m`sigilToken: <*Keyword 'class' />`);
35
+ yield eatMatch(m`name$: <Identifier />`);
36
+ if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`)) {
37
+ yield eat(m`superClass$: <__Expression>`);
38
+ } else {
39
+ yield eat(m`superClass$: null`);
40
+ }
41
+ yield eat(m`body: <ClassBody />`);
42
+ }
43
+ *ClassBody() {
44
+ yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
45
+ while (yield eatMatch(m`members[]: <__ClassMember />`)) {}
46
+ yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
47
+ }
48
+ *ClassMember() {
49
+ yield eat(m`<ClassMethod />`);
50
+ }
51
+ *ClassMethod() {
52
+ yield eatMatch(m`staticToken: <*Keyword 'static' />`);
53
+ let acc, a, gen;
54
+ acc = yield eatMatch(m`kindToken: <*Keyword /get|set/ />`);
55
+ 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`);
61
+ }
62
+ 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 />`,
69
+ allowTrailingSeparator: false,
70
+ separator: m`separatorTokens[]: <*Punctuator ',' />`
71
+ }));
72
+ yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
73
+ yield eat(m`body: <BlockStatement />`);
74
+ }
75
+ *SuperExpression() {
76
+ yield eat(m`sigilToken: <*Keyword 'super' />`);
77
+ }
78
+ *ThisExpression() {
79
+ yield eat(m`sigilToken: <*Keyword 'this' />`);
80
+ }
81
+ };
82
+ };
@@ -0,0 +1,92 @@
1
+ import { spam as m } from '@bablr/boot';
2
+ import { CoveredBy, Node } from '@bablr/helpers/decorators';
3
+ import { o, eat, eatMatch, fail } from '@bablr/helpers/grammar';
4
+
5
+ export const mixin = (Base) =>
6
+ class ES6ClassGrammar extends Base {
7
+ @Node
8
+ *ClassDeclaration() {
9
+ yield eat(m`sigilToken: <*Keyword 'class' />`);
10
+
11
+ yield eat(m`name$: <Identifier />`);
12
+
13
+ if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`, o({}), o({ bind: true }))) {
14
+ yield eat(m`superClass$: <__Expression>`);
15
+ } else {
16
+ yield eat(m`superClass$: null`);
17
+ }
18
+
19
+ yield eat(m`body: <ClassBody />`);
20
+ }
21
+
22
+ @CoveredBy('Expression')
23
+ @Node
24
+ *ClassExpression() {
25
+ yield eat(m`sigilToken: <*Keyword 'class' />`);
26
+
27
+ yield eatMatch(m`name$: <Identifier />`);
28
+
29
+ if (yield eatMatch(m`extendsToken: <*Keyword 'extends' />`)) {
30
+ yield eat(m`superClass$: <__Expression>`);
31
+ } else {
32
+ yield eat(m`superClass$: null`);
33
+ }
34
+
35
+ yield eat(m`body: <ClassBody />`);
36
+ }
37
+
38
+ @Node
39
+ *ClassBody() {
40
+ yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
41
+ while (yield eatMatch(m`members[]: <__ClassMember />`)) {}
42
+ yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
43
+ }
44
+
45
+ *ClassMember() {
46
+ yield eat(m`<ClassMethod />`);
47
+ }
48
+
49
+ @CoveredBy('ClassMember')
50
+ @Node
51
+ *ClassMethod() {
52
+ yield eatMatch(m`staticToken: <*Keyword 'static' />`);
53
+ let acc, a, gen;
54
+ acc = yield eatMatch(m`kindToken: <*Keyword /get|set/ />`);
55
+
56
+ if (!acc) {
57
+ a = yield eatMatch(m`asyncToken: <*Keyword 'async' />`);
58
+ gen = yield eatMatch(m`starToken: <*Punctuator '*' />`);
59
+ } else {
60
+ yield eatMatch(m`asyncToken: null`);
61
+ yield eatMatch(m`starToken: null`);
62
+ }
63
+
64
+ if (a && gen) yield fail();
65
+
66
+ yield eatMatch(m`id: <Identifier />`, o({}), o({ bind: true }));
67
+
68
+ yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`);
69
+ yield eat(
70
+ m`params[]: <_List />`,
71
+ o({
72
+ element: m`<Identifier />`,
73
+ allowTrailingSeparator: false,
74
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
75
+ }),
76
+ );
77
+ yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
78
+ yield eat(m`body: <BlockStatement />`);
79
+ }
80
+
81
+ @CoveredBy('Expression')
82
+ @Node
83
+ *SuperExpression() {
84
+ yield eat(m`sigilToken: <*Keyword 'super' />`);
85
+ }
86
+
87
+ @CoveredBy('Expression')
88
+ @Node
89
+ *ThisExpression() {
90
+ yield eat(m`sigilToken: <*Keyword 'this' />`);
91
+ }
92
+ };
@@ -0,0 +1,142 @@
1
+ /* @macrome
2
+ * @generatedby @bablr/macrome-generator-bablr
3
+ * @generatedfrom ./function.macro.js#831c60a39d2152781cdb56f58146f685d97b53d3
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
+ import { spam as m, re } from '@bablr/boot';
9
+ import { CoveredBy, Node } from '@bablr/helpers/decorators';
10
+ import { o, eat, eatMatch, fail, match, shiftMatch } from '@bablr/helpers/grammar';
11
+ export const mixin = Base => {
12
+ let _initProto, _FunctionExpressionDecs;
13
+ return class es6FunctionGrammar extends Base {
14
+ static {
15
+ [_initProto] = _applyDecs(this, [[_FunctionExpressionDecs, 2, "FunctionExpression"], [Node, 2, "YieldStatement"], [Node, 2, "ObjectPattern"], [Node, 2, "PropertyPattern"], [Node, 2, "AssignmentPattern"], [Node, 2, "ArrayPattern"], [Node, 2, "ArrowFunctionExpression"]], [], 0, void 0, Base).e;
16
+ }
17
+ constructor(...args) {
18
+ super(...args);
19
+ _initProto(this);
20
+ }
21
+ *[(_FunctionExpressionDecs = [CoveredBy('Expression'), Node], "FunctionExpression")]({
22
+ props: {
23
+ shorthand
24
+ }
25
+ }) {
26
+ if (!shorthand) {
27
+ yield eat(m`sigilToken: <*Keyword 'function' />`);
28
+ } else {
29
+ yield eat(m`sigilToken: null`);
30
+ }
31
+ let a = yield eatMatch(m`asyncToken: <*Keyword 'async' />`);
32
+ let gen = yield eatMatch(m`starToken: <*Punctuator '*' />`);
33
+ if (a && gen) yield fail();
34
+ if (!shorthand) {
35
+ yield eatMatch(m`id: <Identifier />`, o({}), o({
36
+ bind: true
37
+ }));
38
+ } else {
39
+ yield eat(m`id: null`);
40
+ }
41
+ yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`);
42
+ yield eat(m`params[]+: <_List />`, o({
43
+ element: m`<__CapturePattern />`,
44
+ allowTrailingSeparator: false,
45
+ separator: m`separatorTokens[]: <*Punctuator ',' />`
46
+ }));
47
+ yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
48
+ yield eat(m`body: <BlockStatement />`);
49
+ }
50
+ *YieldStatement() {
51
+ yield eat(m`sigilToken: <*Keyword 'yield' />`);
52
+ yield eat(m`expression+$: <__Expression />`);
53
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, null, o({
54
+ bind: true
55
+ }));
56
+ }
57
+
58
+ // (type = null, { prop, value: name = {} }) => {};
59
+
60
+ *CapturePattern({
61
+ ctx
62
+ }) {
63
+ let pn;
64
+ if (pn = yield match(re`/[[{]/`)) {
65
+ switch (ctx.sourceTextFor(pn).trim()) {
66
+ case '{':
67
+ yield eat(m`<ObjectPattern />`);
68
+ break;
69
+ case '[':
70
+ yield eat(m`<ArrayPattern />`);
71
+ break;
72
+ }
73
+ } else {
74
+ yield eat(m`<Identifier />`);
75
+ return shiftMatch(m`<AssignmentPattern '=' />`);
76
+ }
77
+ }
78
+ *ObjectPattern() {
79
+ yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
80
+ yield eat(m`params[]+$: <_List />`, o({
81
+ element: m`<PropertyPattern />`,
82
+ allowTrailingSeparator: true,
83
+ separator: m`separatorTokens[]: <*Punctuator ',' />`
84
+ }));
85
+ yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
86
+ }
87
+ *PropertyPattern() {
88
+ if (yield eatMatch(m`key$: <Identifier />`)) {
89
+ let cn = yield eatMatch(m`mapOperator: <*Punctuator ':' />`, null, o({
90
+ bind: true
91
+ }));
92
+ if (cn) {
93
+ yield eat(m`value+$: <__CapturePattern />`);
94
+ }
95
+ } else {
96
+ yield eat(m`key$: <Identifier />`, o({
97
+ scoped: false
98
+ }));
99
+ yield eat(m`mapOperator: <*Punctuator ':' />`);
100
+ yield eat(m`value+$: <__CapturePattern />`);
101
+ }
102
+ }
103
+ *AssignmentPattern() {
104
+ yield eat(m`source+$: <Identifier />`);
105
+ yield eat(m`assignmentOperator: <*Punctuator '=' />`);
106
+ yield eat(m`defaultValue+$: <__Expression />`, o({
107
+ power: 32
108
+ }));
109
+ }
110
+ *ArrayPattern() {
111
+ yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
112
+ yield eat(m`params[]+$: <_List />`, o({
113
+ element: m`<__CapturePattern />`,
114
+ allowTrailingSeparator: true,
115
+ separator: m`separatorTokens[]: <*Punctuator ',' />`
116
+ }));
117
+ yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
118
+ }
119
+ *ArrowFunctionExpression() {
120
+ // yield eat(m`params[]+: []`);
121
+ if (yield match('(')) {
122
+ yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`);
123
+ yield eat(m`params[]+$: <_List />`, o({
124
+ element: m`<__CapturePattern />`,
125
+ allowTrailingSeparator: false,
126
+ separator: m`separatorTokens[]: <*Punctuator ',' />`
127
+ }));
128
+ yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
129
+ } else {
130
+ yield eat(m`params[]+$: <Identifier />`);
131
+ yield eat(m`openParamsToken: null`);
132
+ yield eat(m`closeParamsToken: null`);
133
+ }
134
+ yield eat(m`sigilToken: <*Keyword '=>' />`);
135
+ if (yield match('{')) {
136
+ yield eat(m`body+: <BlockStatement />`);
137
+ } else {
138
+ yield eat(m`body+: <__Expression />`);
139
+ }
140
+ }
141
+ };
142
+ };
@@ -0,0 +1,144 @@
1
+ import { spam as m, re } from '@bablr/boot';
2
+ import { CoveredBy, Node } from '@bablr/helpers/decorators';
3
+ import { o, eat, eatMatch, fail, match, shiftMatch } from '@bablr/helpers/grammar';
4
+
5
+ export const mixin = (Base) =>
6
+ class es6FunctionGrammar extends Base {
7
+ @CoveredBy('Expression')
8
+ @Node
9
+ *FunctionExpression({ props: { shorthand } }) {
10
+ if (!shorthand) {
11
+ yield eat(m`sigilToken: <*Keyword 'function' />`);
12
+ } else {
13
+ yield eat(m`sigilToken: null`);
14
+ }
15
+
16
+ let a = yield eatMatch(m`asyncToken: <*Keyword 'async' />`);
17
+ let gen = yield eatMatch(m`starToken: <*Punctuator '*' />`);
18
+
19
+ if (a && gen) yield fail();
20
+
21
+ if (!shorthand) {
22
+ yield eatMatch(m`id: <Identifier />`, o({}), o({ bind: true }));
23
+ } else {
24
+ yield eat(m`id: null`);
25
+ }
26
+
27
+ yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`);
28
+ yield eat(
29
+ m`params[]+: <_List />`,
30
+ o({
31
+ element: m`<__CapturePattern />`,
32
+ allowTrailingSeparator: false,
33
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
34
+ }),
35
+ );
36
+ yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
37
+ yield eat(m`body: <BlockStatement />`);
38
+ }
39
+
40
+ @Node
41
+ *YieldStatement() {
42
+ yield eat(m`sigilToken: <*Keyword 'yield' />`);
43
+ yield eat(m`expression+$: <__Expression />`);
44
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, null, o({ bind: true }));
45
+ }
46
+
47
+ // (type = null, { prop, value: name = {} }) => {};
48
+
49
+ *CapturePattern({ ctx }) {
50
+ let pn;
51
+ if ((pn = yield match(re`/[[{]/`))) {
52
+ switch (ctx.sourceTextFor(pn).trim()) {
53
+ case '{':
54
+ yield eat(m`<ObjectPattern />`);
55
+ break;
56
+ case '[':
57
+ yield eat(m`<ArrayPattern />`);
58
+ break;
59
+ }
60
+ } else {
61
+ yield eat(m`<Identifier />`);
62
+
63
+ return shiftMatch(m`<AssignmentPattern '=' />`);
64
+ }
65
+ }
66
+
67
+ @Node
68
+ *ObjectPattern() {
69
+ yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
70
+ yield eat(
71
+ m`params[]+$: <_List />`,
72
+ o({
73
+ element: m`<PropertyPattern />`,
74
+ allowTrailingSeparator: true,
75
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
76
+ }),
77
+ );
78
+ yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
79
+ }
80
+
81
+ @Node
82
+ *PropertyPattern() {
83
+ if (yield eatMatch(m`key$: <Identifier />`)) {
84
+ let cn = yield eatMatch(m`mapOperator: <*Punctuator ':' />`, null, o({ bind: true }));
85
+ if (cn) {
86
+ yield eat(m`value+$: <__CapturePattern />`);
87
+ }
88
+ } else {
89
+ yield eat(m`key$: <Identifier />`, o({ scoped: false }));
90
+ yield eat(m`mapOperator: <*Punctuator ':' />`);
91
+ yield eat(m`value+$: <__CapturePattern />`);
92
+ }
93
+ }
94
+
95
+ @Node
96
+ *AssignmentPattern() {
97
+ yield eat(m`source+$: <Identifier />`);
98
+ yield eat(m`assignmentOperator: <*Punctuator '=' />`);
99
+ yield eat(m`defaultValue+$: <__Expression />`, o({ power: 32 }));
100
+ }
101
+
102
+ @Node
103
+ *ArrayPattern() {
104
+ yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
105
+ yield eat(
106
+ m`params[]+$: <_List />`,
107
+ o({
108
+ element: m`<__CapturePattern />`,
109
+ allowTrailingSeparator: true,
110
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
111
+ }),
112
+ );
113
+ yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
114
+ }
115
+
116
+ @Node
117
+ *ArrowFunctionExpression() {
118
+ // yield eat(m`params[]+: []`);
119
+ if (yield match('(')) {
120
+ yield eat(m`openParamsToken: <*Punctuator '(' { balanced: ')' } />`);
121
+ yield eat(
122
+ m`params[]+$: <_List />`,
123
+ o({
124
+ element: m`<__CapturePattern />`,
125
+ allowTrailingSeparator: false,
126
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
127
+ }),
128
+ );
129
+ yield eat(m`closeParamsToken: <*Punctuator ')' { balancer: true } />`);
130
+ } else {
131
+ yield eat(m`params[]+$: <Identifier />`);
132
+ yield eat(m`openParamsToken: null`);
133
+ yield eat(m`closeParamsToken: null`);
134
+ }
135
+
136
+ yield eat(m`sigilToken: <*Keyword '=>' />`);
137
+
138
+ if (yield match('{')) {
139
+ yield eat(m`body+: <BlockStatement />`);
140
+ } else {
141
+ yield eat(m`body+: <__Expression />`);
142
+ }
143
+ }
144
+ };
@@ -0,0 +1,138 @@
1
+ /* @macrome
2
+ * @generatedby @bablr/macrome-generator-bablr
3
+ * @generatedfrom ./import.macro.js#21371d90722f9817f110bb3037864d40e321d2bf
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
+ import { spam as m } from '@bablr/boot';
9
+ import { Node } from '@bablr/helpers/decorators';
10
+ import { o, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
11
+ export const mixin = Base => {
12
+ let _initProto;
13
+ return class ES6ImportGrammar extends Base {
14
+ static {
15
+ [_initProto] = _applyDecs(this, [[Node, 2, "ImportDeclaration"], [Node, 2, "ImportSpecifier"], [Node, 2, "ImportDefaultSpecifier"], [Node, 2, "ImportNamespaceSpecifier"], [Node, 2, "ExportDeclaration"], [Node, 2, "ExportDefaultSpecifier"], [Node, 2, "ExportAllSpecifier"], [Node, 2, "ExportSpecifier"]], [], 0, void 0, Base).e;
16
+ }
17
+ constructor(...args) {
18
+ super(...args);
19
+ _initProto(this);
20
+ }
21
+ *ImportDeclaration() {
22
+ yield eat(m`sigilToken: <*Keyword 'import' />`);
23
+ if (yield eatMatch(m`specifiers[]$: <ImportNamespaceSpecifier '*' />`)) {
24
+ yield eat(m`fromToken: <*Keyword 'from' />`);
25
+ } else {
26
+ let spec = yield eatMatch(m`specifiers[]$: <ImportDefaultSpecifier />`);
27
+ let sep = spec ? null : yield eatMatch(m`separators[]: <*Punctuator ',' />`);
28
+ let open = yield eatMatch(m`openSpecifiersToken: <*Punctuator '{' { balanced: '}' } />`, o({}), o({
29
+ bind: true
30
+ }));
31
+ if (open) {
32
+ let first = true;
33
+ while (first || sep) {
34
+ spec = yield eatMatch(m`specifiers[]$: <ImportSpecifier />`);
35
+ sep = yield eatMatch(m`separators[]: <*Punctuator ',' />`);
36
+ first = false;
37
+ }
38
+ yield eat(m`closeSpecifiersToken: <*Punctuator '}' { balancer: true } />`);
39
+ } else {
40
+ yield eat(m`closeSpecifiersToken: null`);
41
+ }
42
+ yield eat(m`fromToken: <*Keyword 'from' />`);
43
+ }
44
+ yield eat(m`source$: <String />`);
45
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, o({}), o({
46
+ bind: true
47
+ }));
48
+ }
49
+ *ImportSpecifier() {
50
+ let str;
51
+ if (str = yield eatMatch(m`imported$: <String /['"]/ />`)) {} else {
52
+ yield eat(m`imported$: <Identifier />`);
53
+ }
54
+ if (str || (yield match('as'))) {
55
+ yield eat(m`mapOperator: <*Keyword 'as' />`);
56
+ yield eat(m`local$: <Identifier />`);
57
+ } else {
58
+ yield eat(m`mapOperator: null`);
59
+ yield eat(m`local$: null`);
60
+ }
61
+ }
62
+ *ImportDefaultSpecifier() {
63
+ yield eat(m`local: <Identifier />`);
64
+ }
65
+ *ImportNamespaceSpecifier() {
66
+ yield eat(m`sigilToken: <*Punctuator '*' />`);
67
+ yield eat(m`mapOperator: <*Keyword 'as' />`);
68
+ yield eat(m`local$: <Identifier />`);
69
+ }
70
+ *ExportDeclaration() {
71
+ yield eat(m`sigilToken: <*Keyword 'export' />`);
72
+ let curly, defSpec, spec, def, from, sep;
73
+ yield eatMatch(m`declaration$: null`);
74
+ if (def = yield match('default')) {
75
+ yield eatMatch(m`defaultToken: <*Keyword 'default' />`);
76
+ if (yield eatMatch(m`declaration$: <ClassDeclaration 'class' />`)) {} else if (yield eatMatch(m`declaration: <FunctionStatement /function|async/ />`)) {} else {
77
+ yield eat(m`declaration$: <__Expression />`);
78
+ }
79
+ } else {
80
+ yield eat(m`defaultToken: null`);
81
+ }
82
+ defSpec = spec = yield eatMatch(m`specifiers[]$: <ExportDefaultSpecifier />`);
83
+ defSpec = defSpec || (yield eatMatch(m`specifiers[]$: <ExportAllSpecifier '*' />`));
84
+ if (spec) {
85
+ sep = yield eatMatch(m`specifierSeparatorTokens[]: <*Punctuator ',' />`);
86
+ }
87
+ if ((!defSpec || sep) && (curly = yield match('{'))) {
88
+ yield eat(m`openSpecifiersToken: <*Punctuator '{' { balanced: '}' } />`);
89
+ let first = true;
90
+ while (first || spec && sep) {
91
+ spec = yield eat(m`specifiers[]$: <ExportSpecifier />`);
92
+ sep = yield eatMatch(m`specifierSeparatorTokens[]: <*Punctuator ',' />`);
93
+ first = false;
94
+ }
95
+ yield eat(m`closeSpecifiersToken: <*Punctuator '}' { balancer: true } />`);
96
+ } else {
97
+ yield eat(m`openSpecifiersToken: null />`);
98
+ yield eat(m`specifiers[]$: []`);
99
+ yield eat(m`specifierSeparatorTokens[]: []`);
100
+ yield eat(m`closeSpecifiersToken: null />`);
101
+ }
102
+ if ((defSpec || curly) && (from = yield match('from'))) {
103
+ yield eatMatch(m`fromToken: <*Keyword 'from' />`);
104
+ yield eat(m`source$: <String />`);
105
+ } else {
106
+ yield eatMatch(m`fromToken: null`);
107
+ yield eat(m`source$: null`);
108
+ }
109
+ if (!def && !defSpec && !curly && !from) {
110
+ if (yield eatMatch(m`declaration: <VariableDeclarationStatement /var|const|let/ />`)) {} else if (yield eatMatch(m`declaration: <ClassDeclaration 'class' />`)) {} else if (yield eatMatch(m`declaration: <FunctionStatement />`)) {} else {
111
+ yield fail();
112
+ }
113
+ }
114
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, o({}), o({
115
+ bind: true
116
+ }));
117
+ }
118
+ *ExportDefaultSpecifier() {
119
+ yield eat(m`local$: <Identifier />`);
120
+ }
121
+ *ExportAllSpecifier() {
122
+ yield eat(m`sigilToken: <*Keyword '*' />`);
123
+ }
124
+ *ExportSpecifier() {
125
+ yield eat(m`local$: <Identifier />`);
126
+ let as_ = yield eatMatch(m`mapOperator: <*Keyword 'as' />`, o({}), o({
127
+ bind: true
128
+ }));
129
+ if (as_) {
130
+ if (yield eatMatch(m`imported$: <String /['"]/ />`)) {} else {
131
+ yield eat(m`imported$: <Identifier />`);
132
+ }
133
+ } else {
134
+ yield eat(m`imported$: null`);
135
+ }
136
+ }
137
+ };
138
+ };
@@ -0,0 +1,160 @@
1
+ import { spam as m } from '@bablr/boot';
2
+ import { Node } from '@bablr/helpers/decorators';
3
+ import { o, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
4
+
5
+ export const mixin = (Base) =>
6
+ class ES6ImportGrammar extends Base {
7
+ @Node
8
+ *ImportDeclaration() {
9
+ yield eat(m`sigilToken: <*Keyword 'import' />`);
10
+
11
+ if (yield eatMatch(m`specifiers[]$: <ImportNamespaceSpecifier '*' />`)) {
12
+ yield eat(m`fromToken: <*Keyword 'from' />`);
13
+ } else {
14
+ let spec = yield eatMatch(m`specifiers[]$: <ImportDefaultSpecifier />`);
15
+ let sep = spec ? null : yield eatMatch(m`separators[]: <*Punctuator ',' />`);
16
+
17
+ let open = yield eatMatch(
18
+ m`openSpecifiersToken: <*Punctuator '{' { balanced: '}' } />`,
19
+ o({}),
20
+ o({ bind: true }),
21
+ );
22
+
23
+ if (open) {
24
+ let first = true;
25
+ while (first || sep) {
26
+ spec = yield eatMatch(m`specifiers[]$: <ImportSpecifier />`);
27
+ sep = yield eatMatch(m`separators[]: <*Punctuator ',' />`);
28
+ first = false;
29
+ }
30
+
31
+ yield eat(m`closeSpecifiersToken: <*Punctuator '}' { balancer: true } />`);
32
+ } else {
33
+ yield eat(m`closeSpecifiersToken: null`);
34
+ }
35
+
36
+ yield eat(m`fromToken: <*Keyword 'from' />`);
37
+ }
38
+ yield eat(m`source$: <String />`);
39
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, o({}), o({ bind: true }));
40
+ }
41
+
42
+ @Node
43
+ *ImportSpecifier() {
44
+ let str;
45
+
46
+ if ((str = yield eatMatch(m`imported$: <String /['"]/ />`))) {
47
+ } else {
48
+ yield eat(m`imported$: <Identifier />`);
49
+ }
50
+
51
+ if (str || (yield match('as'))) {
52
+ yield eat(m`mapOperator: <*Keyword 'as' />`);
53
+ yield eat(m`local$: <Identifier />`);
54
+ } else {
55
+ yield eat(m`mapOperator: null`);
56
+ yield eat(m`local$: null`);
57
+ }
58
+ }
59
+
60
+ @Node
61
+ *ImportDefaultSpecifier() {
62
+ yield eat(m`local: <Identifier />`);
63
+ }
64
+
65
+ @Node
66
+ *ImportNamespaceSpecifier() {
67
+ yield eat(m`sigilToken: <*Punctuator '*' />`);
68
+ yield eat(m`mapOperator: <*Keyword 'as' />`);
69
+ yield eat(m`local$: <Identifier />`);
70
+ }
71
+
72
+ @Node
73
+ *ExportDeclaration() {
74
+ yield eat(m`sigilToken: <*Keyword 'export' />`);
75
+
76
+ let curly, defSpec, spec, def, from, sep;
77
+
78
+ yield eatMatch(m`declaration$: null`);
79
+
80
+ if ((def = yield match('default'))) {
81
+ yield eatMatch(m`defaultToken: <*Keyword 'default' />`);
82
+
83
+ if (yield eatMatch(m`declaration$: <ClassDeclaration 'class' />`)) {
84
+ } else if (yield eatMatch(m`declaration: <FunctionStatement /function|async/ />`)) {
85
+ } else {
86
+ yield eat(m`declaration$: <__Expression />`);
87
+ }
88
+ } else {
89
+ yield eat(m`defaultToken: null`);
90
+ }
91
+
92
+ defSpec = spec = yield eatMatch(m`specifiers[]$: <ExportDefaultSpecifier />`);
93
+ defSpec = defSpec || (yield eatMatch(m`specifiers[]$: <ExportAllSpecifier '*' />`));
94
+
95
+ if (spec) {
96
+ sep = yield eatMatch(m`specifierSeparatorTokens[]: <*Punctuator ',' />`);
97
+ }
98
+
99
+ if ((!defSpec || sep) && (curly = yield match('{'))) {
100
+ yield eat(m`openSpecifiersToken: <*Punctuator '{' { balanced: '}' } />`);
101
+
102
+ let first = true;
103
+ while (first || (spec && sep)) {
104
+ spec = yield eat(m`specifiers[]$: <ExportSpecifier />`);
105
+ sep = yield eatMatch(m`specifierSeparatorTokens[]: <*Punctuator ',' />`);
106
+ first = false;
107
+ }
108
+ yield eat(m`closeSpecifiersToken: <*Punctuator '}' { balancer: true } />`);
109
+ } else {
110
+ yield eat(m`openSpecifiersToken: null />`);
111
+ yield eat(m`specifiers[]$: []`);
112
+ yield eat(m`specifierSeparatorTokens[]: []`);
113
+ yield eat(m`closeSpecifiersToken: null />`);
114
+ }
115
+
116
+ if ((defSpec || curly) && (from = yield match('from'))) {
117
+ yield eatMatch(m`fromToken: <*Keyword 'from' />`);
118
+ yield eat(m`source$: <String />`);
119
+ } else {
120
+ yield eatMatch(m`fromToken: null`);
121
+ yield eat(m`source$: null`);
122
+ }
123
+
124
+ if (!def && !defSpec && !curly && !from) {
125
+ if (yield eatMatch(m`declaration: <VariableDeclarationStatement /var|const|let/ />`)) {
126
+ } else if (yield eatMatch(m`declaration: <ClassDeclaration 'class' />`)) {
127
+ } else if (yield eatMatch(m`declaration: <FunctionStatement />`)) {
128
+ } else {
129
+ yield fail();
130
+ }
131
+ }
132
+ yield eatMatch(m`endToken: <*Punctuator ';' />`, o({}), o({ bind: true }));
133
+ }
134
+
135
+ @Node
136
+ *ExportDefaultSpecifier() {
137
+ yield eat(m`local$: <Identifier />`);
138
+ }
139
+
140
+ @Node
141
+ *ExportAllSpecifier() {
142
+ yield eat(m`sigilToken: <*Keyword '*' />`);
143
+ }
144
+
145
+ @Node
146
+ *ExportSpecifier() {
147
+ yield eat(m`local$: <Identifier />`);
148
+
149
+ let as_ = yield eatMatch(m`mapOperator: <*Keyword 'as' />`, o({}), o({ bind: true }));
150
+
151
+ if (as_) {
152
+ if (yield eatMatch(m`imported$: <String /['"]/ />`)) {
153
+ } else {
154
+ yield eat(m`imported$: <Identifier />`);
155
+ }
156
+ } else {
157
+ yield eat(m`imported$: null`);
158
+ }
159
+ }
160
+ };
package/lib/regex.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@bablr/language-en-es5/regex';
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@bablr/language-en-es6",
3
+ "version": "0.1.0",
4
+ "description": "A BABLR language for ES6 (JavaScript)",
5
+ "engines": {
6
+ "node": ">=12.0.0"
7
+ },
8
+ "type": "module",
9
+ "exports": {
10
+ ".": "./lib/grammar.js",
11
+ "./regex": "./lib/regex.js",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "files": [
15
+ "lib/**/*.js"
16
+ ],
17
+ "scripts": {
18
+ "build": "macrome build",
19
+ "watch": "macrome watch",
20
+ "clean": "macrome clean",
21
+ "test": "mocha test/*.test.js"
22
+ },
23
+ "sideEffects": false,
24
+ "dependencies": {
25
+ "@babel/runtime": "7.24.6",
26
+ "@bablr/agast-vm-helpers": "0.8.0",
27
+ "@bablr/boot": "0.9.0",
28
+ "@bablr/helpers": "0.23.0",
29
+ "@bablr/language-en-c-comments": "0.8.0",
30
+ "@bablr/language-en-es5": "0.1.0"
31
+ },
32
+ "devDependencies": {
33
+ "@bablr/agast-helpers": "^0.8.0",
34
+ "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
35
+ "@bablr/macrome": "0.1.3",
36
+ "@bablr/macrome-generator-bablr": "0.3.2",
37
+ "@qnighy/dedent": "0.1.1",
38
+ "bablr": "0.9.0",
39
+ "enhanced-resolve": "^5.12.0",
40
+ "eslint": "^7.32.0",
41
+ "eslint-import-resolver-enhanced-resolve": "^1.0.5",
42
+ "eslint-plugin-import": "^2.27.5",
43
+ "expect": "29.7.0",
44
+ "iter-tools-es": "^7.5.3",
45
+ "mocha": "10.4.0",
46
+ "prettier": "^2.0.5"
47
+ },
48
+ "keywords": [
49
+ "bablr-language",
50
+ "grammar",
51
+ "english",
52
+ "es6",
53
+ "ecmascript"
54
+ ],
55
+ "repository": "git@github.com:bablr-lang/language-en-es6.git",
56
+ "homepage": "https://github.com/bablr-lang/language-en-es6",
57
+ "author": "Conrad Buck <conartist6@gmail.com>",
58
+ "license": "MIT"
59
+ }