@bablr/language-en-esnext 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) 2025 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/es2016.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@bablr/language-en-es6';
package/lib/es2017.js ADDED
@@ -0,0 +1 @@
1
+ export * from './es2016.js';
package/lib/es2018.js ADDED
@@ -0,0 +1,53 @@
1
+ /* @macrome
2
+ * @generatedby @bablr/macrome-generator-bablr
3
+ * @generatedfrom ./es2018.macro.js#31e96c73e70e3eb8e8000d079299b3a5770eaed7
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 _es2017$atrivialGramm;
9
+ let _initProto, _ObjectDecs;
10
+ import { re, spam as m } from '@bablr/boot';
11
+ import { CoveredBy, Node, UndefinedAttributes } from '@bablr/helpers/decorators';
12
+ import { o, defineAttribute, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
13
+ import { triviaEnhancer } from '@bablr/helpers/trivia';
14
+ import * as Comment from '@bablr/language-en-c-comments';
15
+ import * as es2017 from './es2017.js';
16
+ export const dependencies = {
17
+ Comment
18
+ };
19
+ export { powerLevels, reservedWords, assignmentOperators, assignmentOperatorAlternatives, unaryPrefixOperators, unaryPrefixOperatorAlternatives, unaryPostfixOperators, unaryPostfixOperatorAlternatives, getBinaryOperatorAlternatives } from './es2017.js';
20
+ export const canonicalURL = 'https://bablr.org/languages/universe/es6';
21
+ export const atrivialGrammar = class ES2018Grammar extends (_es2017$atrivialGramm = es2017.atrivialGrammar) {
22
+ static {
23
+ [_initProto] = _applyDecs(this, [[_ObjectDecs, 2, "Object"], [Node, 2, "SpreadElement"]], [], 0, void 0, _es2017$atrivialGramm).e;
24
+ }
25
+ constructor(...args) {
26
+ super(...args);
27
+ _initProto(this);
28
+ }
29
+ *[(_ObjectDecs = [CoveredBy('JSONExpression'), CoveredBy('Expression'), Node], "Object")]() {
30
+ yield eat(m`open: <*Punctuator '{' { balanced: '}' } />`);
31
+ yield eat(m`properties[]$: <_List />`, o({
32
+ element: m`<__ObjectMember />`,
33
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
34
+ allowTrailingSeparator: true
35
+ }));
36
+ yield eat(m`close: <*Punctuator '}' { balancer: true } />`);
37
+ }
38
+ *ObjectMember() {
39
+ if (yield eatMatch(m`<SpreadElement '...' />`)) {} else {
40
+ yield eat(m`<Property />`);
41
+ }
42
+ }
43
+ *SpreadElement() {
44
+ yield eat(m`sigilToken: <*Punctuator '...' />`);
45
+ yield eat(m`value+$: <__Expression />`, o({
46
+ power: 32
47
+ }));
48
+ }
49
+ };
50
+ export const grammar = triviaEnhancer({
51
+ triviaIsAllowed: s => s.span === 'Bare',
52
+ triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`
53
+ }, atrivialGrammar);
@@ -0,0 +1,61 @@
1
+ import { re, spam as m } from '@bablr/boot';
2
+ import { CoveredBy, Node, UndefinedAttributes } from '@bablr/helpers/decorators';
3
+ import { o, defineAttribute, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
4
+ import { triviaEnhancer } from '@bablr/helpers/trivia';
5
+ import * as Comment from '@bablr/language-en-c-comments';
6
+ import * as es2017 from './es2017.js';
7
+
8
+ export const dependencies = { Comment };
9
+
10
+ export {
11
+ powerLevels,
12
+ reservedWords,
13
+ assignmentOperators,
14
+ assignmentOperatorAlternatives,
15
+ unaryPrefixOperators,
16
+ unaryPrefixOperatorAlternatives,
17
+ unaryPostfixOperators,
18
+ unaryPostfixOperatorAlternatives,
19
+ getBinaryOperatorAlternatives,
20
+ } from './es2017.js';
21
+
22
+ export const canonicalURL = 'https://bablr.org/languages/universe/es6';
23
+
24
+ export const atrivialGrammar = class ES2018Grammar extends es2017.atrivialGrammar {
25
+ @CoveredBy('JSONExpression')
26
+ @CoveredBy('Expression')
27
+ @Node
28
+ *Object() {
29
+ yield eat(m`open: <*Punctuator '{' { balanced: '}' } />`);
30
+ yield eat(
31
+ m`properties[]$: <_List />`,
32
+ o({
33
+ element: m`<__ObjectMember />`,
34
+ separator: m`separatorTokens[]: <*Punctuator ',' />`,
35
+ allowTrailingSeparator: true,
36
+ }),
37
+ );
38
+ yield eat(m`close: <*Punctuator '}' { balancer: true } />`);
39
+ }
40
+
41
+ *ObjectMember() {
42
+ if (yield eatMatch(m`<SpreadElement '...' />`)) {
43
+ } else {
44
+ yield eat(m`<Property />`);
45
+ }
46
+ }
47
+
48
+ @Node
49
+ *SpreadElement() {
50
+ yield eat(m`sigilToken: <*Punctuator '...' />`);
51
+ yield eat(m`value+$: <__Expression />`, o({ power: 32 }));
52
+ }
53
+ };
54
+
55
+ export const grammar = triviaEnhancer(
56
+ {
57
+ triviaIsAllowed: (s) => s.span === 'Bare',
58
+ triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
59
+ },
60
+ atrivialGrammar,
61
+ );
package/lib/es2019.js ADDED
@@ -0,0 +1 @@
1
+ export * from './es2018.js';
package/lib/es2020.js ADDED
@@ -0,0 +1,98 @@
1
+ /* @macrome
2
+ * @generatedby @bablr/macrome-generator-bablr
3
+ * @generatedfrom ./es2020.macro.js#fb3e777fcd923bee4d14c1e1a2bc7ba2cb03c659
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 _es2019$atrivialGramm;
9
+ let _initProto, _MemberExpressionDecs;
10
+ import { re, spam as m } from '@bablr/boot';
11
+ import { CoveredBy, Node, UndefinedAttributes } from '@bablr/helpers/decorators';
12
+ import { o, defineAttribute, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
13
+ import { triviaEnhancer } from '@bablr/helpers/trivia';
14
+ import * as Comment from '@bablr/language-en-c-comments';
15
+ import * as es2019 from './es2019.js';
16
+ export const dependencies = {
17
+ Comment
18
+ };
19
+ export { powerLevels, reservedWords, assignmentOperators, assignmentOperatorAlternatives, unaryPrefixOperators, unaryPrefixOperatorAlternatives, unaryPostfixOperators, unaryPostfixOperatorAlternatives, getBinaryOperatorAlternatives } from './es2019.js';
20
+ export const canonicalURL = 'https://bablr.org/languages/universe/es6';
21
+ export const atrivialGrammar = class ES2020Grammar extends (_es2019$atrivialGramm = es2019.atrivialGrammar) {
22
+ static {
23
+ [_initProto] = _applyDecs(this, [[_MemberExpressionDecs, 2, "MemberExpression"]], [], 0, void 0, _es2019$atrivialGramm).e;
24
+ }
25
+ constructor(...args) {
26
+ super(...args);
27
+ _initProto(this);
28
+ }
29
+ *[(_MemberExpressionDecs = [UndefinedAttributes(['power']), CoveredBy('Expression'), CoveredBy('LogicExpression'), Node], "LogicExpression")](args) {
30
+ let {
31
+ props: {
32
+ power = 34
33
+ }
34
+ } = args;
35
+ let res;
36
+ if (power >= 2) {
37
+ res = yield eatMatch(m`<MemberExpression /\g\?\./ />`, o({
38
+ power
39
+ }));
40
+ if (!res) {
41
+ yield* super.LogicExpression(args);
42
+ }
43
+ } else {
44
+ yield* super.LogicExpression(args);
45
+ }
46
+ }
47
+ *MemberExpression({
48
+ ctx
49
+ }) {
50
+ yield eat(m`object+$: <__Expression />`, o({
51
+ power: 2
52
+ }));
53
+ yield defineAttribute('power', 2);
54
+ let sigil = yield match(re`/\?\.|[[.]/`);
55
+ switch (ctx.sourceTextFor(sigil)) {
56
+ case '?.':
57
+ {
58
+ yield eat(m`dotToken: <*Punctuator '?.' />`);
59
+ if (yield eatMatch(m`openToken: <*Punctuator '[' { balanced: ']' } />`, o({}), o({
60
+ bind: true
61
+ }))) {
62
+ yield eat(m`property+$: <__Expression />`);
63
+ yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
64
+ } else {
65
+ yield eat(m`property+$: <__Expression />`, o({
66
+ power: 2
67
+ }));
68
+ yield eat(m`closeToken: null`);
69
+ }
70
+ break;
71
+ }
72
+ case '.':
73
+ {
74
+ yield eat(m`dotToken: <*Punctuator '.' />`);
75
+ yield eat(m`openToken: null`);
76
+ yield eat(m`property+$: <Identifier />`, o({
77
+ scoped: false
78
+ }));
79
+ yield eat(m`closeToken: null`);
80
+ break;
81
+ }
82
+ case '[':
83
+ {
84
+ yield eat(m`dotToken: null`);
85
+ yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
86
+ yield eat(m`property+$: <__Expression />`);
87
+ yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
88
+ break;
89
+ }
90
+ default:
91
+ yield fail();
92
+ }
93
+ }
94
+ };
95
+ export const grammar = triviaEnhancer({
96
+ triviaIsAllowed: s => s.span === 'Bare',
97
+ triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`
98
+ }, atrivialGrammar);
@@ -0,0 +1,99 @@
1
+ import { re, spam as m } from '@bablr/boot';
2
+ import { CoveredBy, Node, UndefinedAttributes } from '@bablr/helpers/decorators';
3
+ import { o, defineAttribute, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
4
+ import { triviaEnhancer } from '@bablr/helpers/trivia';
5
+ import * as Comment from '@bablr/language-en-c-comments';
6
+ import * as es2019 from './es2019.js';
7
+
8
+ export const dependencies = { Comment };
9
+
10
+ export {
11
+ powerLevels,
12
+ reservedWords,
13
+ assignmentOperators,
14
+ assignmentOperatorAlternatives,
15
+ unaryPrefixOperators,
16
+ unaryPrefixOperatorAlternatives,
17
+ unaryPostfixOperators,
18
+ unaryPostfixOperatorAlternatives,
19
+ getBinaryOperatorAlternatives,
20
+ } from './es2019.js';
21
+
22
+ export const canonicalURL = 'https://bablr.org/languages/universe/es6';
23
+
24
+ export const atrivialGrammar = class ES2020Grammar extends es2019.atrivialGrammar {
25
+ *LogicExpression(args) {
26
+ let {
27
+ props: { power = 34 },
28
+ } = args;
29
+ let res;
30
+ if (power >= 2) {
31
+ res = yield eatMatch(m`<MemberExpression /\g\?\./ />`, o({ power }));
32
+ if (!res) {
33
+ yield* super.LogicExpression(args);
34
+ }
35
+ } else {
36
+ yield* super.LogicExpression(args);
37
+ }
38
+ }
39
+
40
+ @UndefinedAttributes(['power'])
41
+ @CoveredBy('Expression')
42
+ @CoveredBy('LogicExpression')
43
+ @Node
44
+ *MemberExpression({ ctx }) {
45
+ yield eat(m`object+$: <__Expression />`, o({ power: 2 }));
46
+ yield defineAttribute('power', 2);
47
+
48
+ let sigil = yield match(re`/\?\.|[[.]/`);
49
+
50
+ switch (ctx.sourceTextFor(sigil)) {
51
+ case '?.': {
52
+ yield eat(m`dotToken: <*Punctuator '?.' />`);
53
+
54
+ if (
55
+ yield eatMatch(
56
+ m`openToken: <*Punctuator '[' { balanced: ']' } />`,
57
+ o({}),
58
+ o({ bind: true }),
59
+ )
60
+ ) {
61
+ yield eat(m`property+$: <__Expression />`);
62
+ yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
63
+ } else {
64
+ yield eat(m`property+$: <__Expression />`, o({ power: 2 }));
65
+ yield eat(m`closeToken: null`);
66
+ }
67
+
68
+ break;
69
+ }
70
+
71
+ case '.': {
72
+ yield eat(m`dotToken: <*Punctuator '.' />`);
73
+ yield eat(m`openToken: null`);
74
+ yield eat(m`property+$: <Identifier />`, o({ scoped: false }));
75
+ yield eat(m`closeToken: null`);
76
+ break;
77
+ }
78
+
79
+ case '[': {
80
+ yield eat(m`dotToken: null`);
81
+ yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
82
+ yield eat(m`property+$: <__Expression />`);
83
+ yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
84
+ break;
85
+ }
86
+
87
+ default:
88
+ yield fail();
89
+ }
90
+ }
91
+ };
92
+
93
+ export const grammar = triviaEnhancer(
94
+ {
95
+ triviaIsAllowed: (s) => s.span === 'Bare',
96
+ triviaMatcher: m`#: :Comment: <_Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
97
+ },
98
+ atrivialGrammar,
99
+ );
package/lib/grammar.js ADDED
@@ -0,0 +1 @@
1
+ export * from './es2020.js';
package/lib/regex.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@bablr/language-en-es6/regex';
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@bablr/language-en-esnext",
3
+ "version": "0.1.0",
4
+ "description": "A BABLR language tracking the most current approved EcmaScript specification",
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-es6": "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
+ "esnext",
53
+ "ecmascript",
54
+ "javascript",
55
+ "js",
56
+ "es"
57
+ ],
58
+ "repository": "git@github.com:bablr-lang/language-en-esnext.git",
59
+ "homepage": "https://github.com/bablr-lang/language-en-esnext",
60
+ "author": "Conrad Buck <conartist6@gmail.com>",
61
+ "license": "MIT"
62
+ }