@bablr/language-en-esnext 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/es2016.js +1 -0
- package/lib/es2017.js +1 -0
- package/lib/es2018.js +55 -52
- package/lib/es2019.js +1 -0
- package/lib/es2020.js +68 -77
- package/lib/grammar.js +1 -0
- package/lib/regex.js +1 -1
- package/package.json +13 -15
- package/lib/es2018.macro.js +0 -80
- package/lib/es2020.macro.js +0 -101
package/lib/es2016.js
CHANGED
package/lib/es2017.js
CHANGED
package/lib/es2018.js
CHANGED
|
@@ -1,66 +1,69 @@
|
|
|
1
|
-
/* @macrome
|
|
2
|
-
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./es2018.macro.js#2a257f8c5cef6055c314c2fe5668662cee068d42
|
|
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
1
|
import { spam as m } from '@bablr/boot';
|
|
11
|
-
import {
|
|
12
|
-
import { o, eat, eatMatch } from '@bablr/helpers/grammar';
|
|
2
|
+
import { eat, eatMatch } from '@bablr/helpers/grammar';
|
|
13
3
|
import { triviaEnhancer } from '@bablr/helpers/trivia';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
import Space from '@bablr/language-en-blank-space';
|
|
5
|
+
import Comment from '@bablr/language-en-c-comments';
|
|
6
|
+
import Regex from '@bablr/language-en-es6/regex';
|
|
7
|
+
import { List } from '@bablr/helpers/productions';
|
|
8
|
+
|
|
9
|
+
import es2017 from './es2017.js';
|
|
10
|
+
|
|
11
|
+
export const dependencies = { Comment, Space, Regex };
|
|
12
|
+
|
|
13
|
+
export const defaultMatcher = m`_+: <_Expression />`;
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
powerLevels,
|
|
17
|
+
reservedWords,
|
|
18
|
+
assignmentOperators,
|
|
19
|
+
assignmentOperatorAlternatives,
|
|
20
|
+
unaryPrefixOperators,
|
|
21
|
+
unaryPrefixOperatorAlternatives,
|
|
22
|
+
unaryPostfixOperators,
|
|
23
|
+
unaryPostfixOperatorAlternatives,
|
|
24
|
+
getBinaryOperatorAlternatives,
|
|
25
|
+
} from './es2017.js';
|
|
26
|
+
|
|
21
27
|
export const canonicalURL = 'https://bablr.org/languages/universe/es6';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
yield eat(m`
|
|
32
|
-
yield eat(m`properties[]$: <__List />`, o({
|
|
33
|
-
element: m`<_ObjectMember />`,
|
|
34
|
-
separator: m`#separatorTokens[]: <*Punctuator ',' />`,
|
|
35
|
-
allowTrailingSeparator: true
|
|
36
|
-
}));
|
|
37
|
-
yield eat(m`close: <*Punctuator '}' { balancer: true } />`);
|
|
28
|
+
|
|
29
|
+
const atrivial = class ES2018Grammar extends es2017.grammar.atrivial {
|
|
30
|
+
*Object() {
|
|
31
|
+
yield eat(m`openToken*: <* '{' />`);
|
|
32
|
+
yield* List({
|
|
33
|
+
element: m`properties[]: <_ObjectMember />`,
|
|
34
|
+
separator: m`#separatorTokens: <* ',' />`,
|
|
35
|
+
allowTrailingSeparator: true,
|
|
36
|
+
});
|
|
37
|
+
yield eat(m`closeToken*: <* '}' />`);
|
|
38
38
|
}
|
|
39
|
+
|
|
39
40
|
*ObjectMember() {
|
|
40
|
-
if (yield eatMatch(m`<SpreadElement '...' />`)) {
|
|
41
|
+
if (yield eatMatch(m`<SpreadElement '...' />`)) {
|
|
42
|
+
} else {
|
|
41
43
|
yield eat(m`<Property />`);
|
|
42
44
|
}
|
|
43
45
|
}
|
|
46
|
+
|
|
44
47
|
*ObjectPattern() {
|
|
45
|
-
yield eat(m`openToken
|
|
46
|
-
yield
|
|
47
|
-
element: m
|
|
48
|
+
yield eat(m`openToken*: <* '{' />`);
|
|
49
|
+
yield* List({
|
|
50
|
+
element: m`params[]+$: <PropertyPattern />`,
|
|
48
51
|
allowTrailingSeparator: true,
|
|
49
|
-
separator: m`#separatorTokens
|
|
50
|
-
})
|
|
52
|
+
separator: m`#separatorTokens: <* ',' />`,
|
|
53
|
+
});
|
|
51
54
|
if (yield eatMatch(m`params[]+$: <SpreadElement '...' />`)) {
|
|
52
|
-
yield eatMatch(m`#separatorTokens
|
|
55
|
+
yield eatMatch(m`#separatorTokens: <* ',' />`);
|
|
53
56
|
}
|
|
54
|
-
yield eat(m`closeToken
|
|
55
|
-
}
|
|
56
|
-
*SpreadElement() {
|
|
57
|
-
yield eat(m`sigilToken: <*Punctuator '...' />`);
|
|
58
|
-
yield eat(m`value+$: <_Expression />`, o({
|
|
59
|
-
power: 32
|
|
60
|
-
}));
|
|
57
|
+
yield eat(m`closeToken*: <* '}' />`);
|
|
61
58
|
}
|
|
62
59
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
|
|
61
|
+
export const grammar = triviaEnhancer(
|
|
62
|
+
{
|
|
63
|
+
triviaIsAllowed: (s) => s.span === 'Bare',
|
|
64
|
+
triviaMatcher: m`#: <__Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
|
|
65
|
+
},
|
|
66
|
+
atrivial,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export default { canonicalURL, dependencies, grammar, defaultMatcher };
|
package/lib/es2019.js
CHANGED
package/lib/es2020.js
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
|
-
/* @macrome
|
|
2
|
-
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./es2020.macro.js#219556c33d9f9d0d57628a75f4098a53b669f2fb
|
|
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
1
|
import { re, spam as m } from '@bablr/boot';
|
|
11
|
-
import {
|
|
12
|
-
import { o, defineAttribute, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
|
|
2
|
+
import { o, eat, eatMatch, match, fail, eatHeld } from '@bablr/helpers/grammar';
|
|
13
3
|
import { triviaEnhancer } from '@bablr/helpers/trivia';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export
|
|
4
|
+
import Space from '@bablr/language-en-blank-space';
|
|
5
|
+
import Comment from '@bablr/language-en-c-comments';
|
|
6
|
+
import Regex from '@bablr/language-en-es6/regex';
|
|
7
|
+
import es2019 from './es2019.js';
|
|
8
|
+
import { printSource } from '@bablr/agast-helpers/tree';
|
|
9
|
+
|
|
10
|
+
export const dependencies = { Comment, Space, Regex };
|
|
11
|
+
|
|
12
|
+
export const defaultMatcher = m`_+: <_Expression />`;
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
powerLevels,
|
|
16
|
+
reservedWords,
|
|
17
|
+
assignmentOperators,
|
|
18
|
+
assignmentOperatorAlternatives,
|
|
19
|
+
unaryPrefixOperators,
|
|
20
|
+
unaryPrefixOperatorAlternatives,
|
|
21
|
+
unaryPostfixOperators,
|
|
22
|
+
unaryPostfixOperatorAlternatives,
|
|
23
|
+
getBinaryOperatorAlternatives,
|
|
24
|
+
} from './es2019.js';
|
|
25
|
+
|
|
21
26
|
export const canonicalURL = 'https://bablr.org/languages/universe/es6';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
constructor(...args) {
|
|
27
|
-
super(...args);
|
|
28
|
-
_initProto(this);
|
|
29
|
-
}
|
|
30
|
-
*[(_MemberExpressionDecs = [UndefinedAttributes(['power']), CoveredBy('Expression'), CoveredBy('LogicExpression'), Node], "LogicExpression")](args) {
|
|
27
|
+
|
|
28
|
+
const atrivial = class ES2020Grammar extends es2019.grammar.atrivial {
|
|
29
|
+
*LogicExpression(args) {
|
|
31
30
|
let {
|
|
32
|
-
props: {
|
|
33
|
-
power = 34
|
|
34
|
-
}
|
|
31
|
+
props: { power = 34 },
|
|
35
32
|
} = args;
|
|
36
33
|
let res;
|
|
37
34
|
if (power >= 2) {
|
|
38
|
-
res = yield eatMatch(m`<MemberExpression
|
|
39
|
-
power
|
|
40
|
-
}));
|
|
35
|
+
res = yield eatMatch(m`<MemberExpression /\?\./ />`, o({ power }));
|
|
41
36
|
if (!res) {
|
|
42
37
|
yield* super.LogicExpression(args);
|
|
43
38
|
}
|
|
@@ -45,55 +40,51 @@ export const atrivialGrammar = class ES2020Grammar extends (_es2019$atrivialGram
|
|
|
45
40
|
yield* super.LogicExpression(args);
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
power: 2
|
|
53
|
-
}));
|
|
54
|
-
yield defineAttribute('power', 2);
|
|
43
|
+
|
|
44
|
+
*MemberExpression() {
|
|
45
|
+
yield eatHeld(m`object+$: <_Expression />`);
|
|
46
|
+
|
|
55
47
|
let sigil = yield match(re`/\?\.|[[.]/`);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}))) {
|
|
63
|
-
yield eat(m`property+$: <_Expression />`);
|
|
64
|
-
yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
|
|
65
|
-
} else {
|
|
66
|
-
yield eat(m`property+$: <_Expression />`, o({
|
|
67
|
-
power: 2
|
|
68
|
-
}));
|
|
69
|
-
yield eat(m`closeToken: null`);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
case '.':
|
|
74
|
-
{
|
|
75
|
-
yield eat(m`dotToken: <*Punctuator '.' />`);
|
|
76
|
-
yield eat(m`openToken: null`);
|
|
77
|
-
yield eat(m`property+$: <Identifier />`, o({
|
|
78
|
-
scoped: false
|
|
79
|
-
}));
|
|
80
|
-
yield eat(m`closeToken: null`);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case '[':
|
|
84
|
-
{
|
|
85
|
-
yield eat(m`dotToken: null`);
|
|
86
|
-
yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
|
|
48
|
+
|
|
49
|
+
switch (printSource(sigil)) {
|
|
50
|
+
case '?.': {
|
|
51
|
+
yield eat(m`dotToken*: <* '?.' />`);
|
|
52
|
+
|
|
53
|
+
if (yield eatMatch(m`openToken*: <* '[' />`)) {
|
|
87
54
|
yield eat(m`property+$: <_Expression />`);
|
|
88
|
-
yield eat(m`closeToken
|
|
89
|
-
|
|
55
|
+
yield eat(m`closeToken*: <* ']' />`);
|
|
56
|
+
} else {
|
|
57
|
+
yield eat(m`property+$: <Identifier />`, o({ scoped: false }));
|
|
90
58
|
}
|
|
59
|
+
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
case '.': {
|
|
64
|
+
yield eat(m`dotToken*: <* '.' />`);
|
|
65
|
+
yield eat(m`property+$: <Identifier />`, o({ scoped: false }));
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
case '[': {
|
|
70
|
+
yield eat(m`openToken*: <* '[' />`);
|
|
71
|
+
yield eat(m`property+$: <_Expression />`);
|
|
72
|
+
yield eat(m`closeToken*: <* ']' />`);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
91
76
|
default:
|
|
92
77
|
yield fail();
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
80
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
|
|
82
|
+
export const grammar = triviaEnhancer(
|
|
83
|
+
{
|
|
84
|
+
triviaIsAllowed: (s) => s.span === 'Bare',
|
|
85
|
+
triviaMatcher: m`#: <__Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
|
|
86
|
+
},
|
|
87
|
+
atrivial,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export default { canonicalURL, dependencies, grammar, defaultMatcher };
|
package/lib/grammar.js
CHANGED
package/lib/regex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default } from '@bablr/language-en-es6/regex';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/language-en-esnext",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A BABLR language tracking the most current approved EcmaScript specification",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12.0.0"
|
|
@@ -15,27 +15,22 @@
|
|
|
15
15
|
"lib/**/*.js"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "macrome build",
|
|
19
|
-
"watch": "macrome watch",
|
|
20
|
-
"clean": "macrome clean",
|
|
21
18
|
"test": "mocha test/*.test.js"
|
|
22
19
|
},
|
|
23
20
|
"sideEffects": false,
|
|
24
21
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@bablr/
|
|
27
|
-
"@bablr/
|
|
28
|
-
"@bablr/
|
|
29
|
-
"@bablr/language-en-c-comments": "0.
|
|
30
|
-
"@bablr/language-en-es6": "0.
|
|
22
|
+
"@bablr/agast-vm-helpers": "0.10.0",
|
|
23
|
+
"@bablr/boot": "0.11.0",
|
|
24
|
+
"@bablr/helpers": "0.25.0",
|
|
25
|
+
"@bablr/language-en-blank-space": "0.10.0",
|
|
26
|
+
"@bablr/language-en-c-comments": "0.10.0",
|
|
27
|
+
"@bablr/language-en-es6": "0.3.0"
|
|
31
28
|
},
|
|
32
29
|
"devDependencies": {
|
|
33
|
-
"@bablr/agast-helpers": "^0.
|
|
30
|
+
"@bablr/agast-helpers": "^0.10.0",
|
|
34
31
|
"@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
32
|
"@qnighy/dedent": "0.1.1",
|
|
38
|
-
"bablr": "0.
|
|
33
|
+
"bablr": "^0.11.0",
|
|
39
34
|
"enhanced-resolve": "^5.12.0",
|
|
40
35
|
"eslint": "^7.32.0",
|
|
41
36
|
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|
|
@@ -55,7 +50,10 @@
|
|
|
55
50
|
"js",
|
|
56
51
|
"es"
|
|
57
52
|
],
|
|
58
|
-
"repository":
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+ssh://git@github.com/bablr-lang/language-en-esnext.git"
|
|
56
|
+
},
|
|
59
57
|
"homepage": "https://github.com/bablr-lang/language-en-esnext",
|
|
60
58
|
"author": "Conrad Buck <conartist6@gmail.com>",
|
|
61
59
|
"license": "MIT"
|
package/lib/es2018.macro.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { spam as m } from '@bablr/boot';
|
|
2
|
-
import { CoveredBy, Node } from '@bablr/helpers/decorators';
|
|
3
|
-
import { o, eat, eatMatch } 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 const defaultMatcher = m`.+: <_Expression />`;
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
powerLevels,
|
|
14
|
-
reservedWords,
|
|
15
|
-
assignmentOperators,
|
|
16
|
-
assignmentOperatorAlternatives,
|
|
17
|
-
unaryPrefixOperators,
|
|
18
|
-
unaryPrefixOperatorAlternatives,
|
|
19
|
-
unaryPostfixOperators,
|
|
20
|
-
unaryPostfixOperatorAlternatives,
|
|
21
|
-
getBinaryOperatorAlternatives,
|
|
22
|
-
} from './es2017.js';
|
|
23
|
-
|
|
24
|
-
export const canonicalURL = 'https://bablr.org/languages/universe/es6';
|
|
25
|
-
|
|
26
|
-
export const atrivialGrammar = class ES2018Grammar extends es2017.atrivialGrammar {
|
|
27
|
-
@CoveredBy('JSONExpression')
|
|
28
|
-
@CoveredBy('Expression')
|
|
29
|
-
@Node
|
|
30
|
-
*Object() {
|
|
31
|
-
yield eat(m`open: <*Punctuator '{' { balanced: '}' } />`);
|
|
32
|
-
yield eat(
|
|
33
|
-
m`properties[]$: <__List />`,
|
|
34
|
-
o({
|
|
35
|
-
element: m`<_ObjectMember />`,
|
|
36
|
-
separator: m`#separatorTokens[]: <*Punctuator ',' />`,
|
|
37
|
-
allowTrailingSeparator: true,
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
|
-
yield eat(m`close: <*Punctuator '}' { balancer: true } />`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
*ObjectMember() {
|
|
44
|
-
if (yield eatMatch(m`<SpreadElement '...' />`)) {
|
|
45
|
-
} else {
|
|
46
|
-
yield eat(m`<Property />`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Node
|
|
51
|
-
*ObjectPattern() {
|
|
52
|
-
yield eat(m`openToken: <*Punctuator '{' { balanced: '}' } />`);
|
|
53
|
-
yield eat(
|
|
54
|
-
m`params[]+$: <__List />`,
|
|
55
|
-
o({
|
|
56
|
-
element: m`<PropertyPattern />`,
|
|
57
|
-
allowTrailingSeparator: true,
|
|
58
|
-
separator: m`#separatorTokens[]: <*Punctuator ',' />`,
|
|
59
|
-
}),
|
|
60
|
-
);
|
|
61
|
-
if (yield eatMatch(m`params[]+$: <SpreadElement '...' />`)) {
|
|
62
|
-
yield eatMatch(m`#separatorTokens[]: <*Punctuator ',' />`);
|
|
63
|
-
}
|
|
64
|
-
yield eat(m`closeToken: <*Punctuator '}' { balancer: true } />`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Node
|
|
68
|
-
*SpreadElement() {
|
|
69
|
-
yield eat(m`sigilToken: <*Punctuator '...' />`);
|
|
70
|
-
yield eat(m`value+$: <_Expression />`, o({ power: 32 }));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export const grammar = triviaEnhancer(
|
|
75
|
-
{
|
|
76
|
-
triviaIsAllowed: (s) => s.span === 'Bare',
|
|
77
|
-
triviaMatcher: m`#: :Comment: <__Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
|
|
78
|
-
},
|
|
79
|
-
atrivialGrammar,
|
|
80
|
-
);
|
package/lib/es2020.macro.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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 const defaultMatcher = m`.+: <_Expression />`;
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
powerLevels,
|
|
14
|
-
reservedWords,
|
|
15
|
-
assignmentOperators,
|
|
16
|
-
assignmentOperatorAlternatives,
|
|
17
|
-
unaryPrefixOperators,
|
|
18
|
-
unaryPrefixOperatorAlternatives,
|
|
19
|
-
unaryPostfixOperators,
|
|
20
|
-
unaryPostfixOperatorAlternatives,
|
|
21
|
-
getBinaryOperatorAlternatives,
|
|
22
|
-
} from './es2019.js';
|
|
23
|
-
|
|
24
|
-
export const canonicalURL = 'https://bablr.org/languages/universe/es6';
|
|
25
|
-
|
|
26
|
-
export const atrivialGrammar = class ES2020Grammar extends es2019.atrivialGrammar {
|
|
27
|
-
*LogicExpression(args) {
|
|
28
|
-
let {
|
|
29
|
-
props: { power = 34 },
|
|
30
|
-
} = args;
|
|
31
|
-
let res;
|
|
32
|
-
if (power >= 2) {
|
|
33
|
-
res = yield eatMatch(m`<MemberExpression /\g\?\./ />`, o({ power }));
|
|
34
|
-
if (!res) {
|
|
35
|
-
yield* super.LogicExpression(args);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
yield* super.LogicExpression(args);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@UndefinedAttributes(['power'])
|
|
43
|
-
@CoveredBy('Expression')
|
|
44
|
-
@CoveredBy('LogicExpression')
|
|
45
|
-
@Node
|
|
46
|
-
*MemberExpression({ ctx }) {
|
|
47
|
-
yield eat(m`object+$: <_Expression />`, o({ power: 2 }));
|
|
48
|
-
yield defineAttribute('power', 2);
|
|
49
|
-
|
|
50
|
-
let sigil = yield match(re`/\?\.|[[.]/`);
|
|
51
|
-
|
|
52
|
-
switch (ctx.sourceTextFor(sigil)) {
|
|
53
|
-
case '?.': {
|
|
54
|
-
yield eat(m`dotToken: <*Punctuator '?.' />`);
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
yield eatMatch(
|
|
58
|
-
m`openToken: <*Punctuator '[' { balanced: ']' } />`,
|
|
59
|
-
o({}),
|
|
60
|
-
o({ bind: true }),
|
|
61
|
-
)
|
|
62
|
-
) {
|
|
63
|
-
yield eat(m`property+$: <_Expression />`);
|
|
64
|
-
yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
|
|
65
|
-
} else {
|
|
66
|
-
yield eat(m`property+$: <_Expression />`, o({ power: 2 }));
|
|
67
|
-
yield eat(m`closeToken: null`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
case '.': {
|
|
74
|
-
yield eat(m`dotToken: <*Punctuator '.' />`);
|
|
75
|
-
yield eat(m`openToken: null`);
|
|
76
|
-
yield eat(m`property+$: <Identifier />`, o({ scoped: false }));
|
|
77
|
-
yield eat(m`closeToken: null`);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
case '[': {
|
|
82
|
-
yield eat(m`dotToken: null`);
|
|
83
|
-
yield eat(m`openToken: <*Punctuator '[' { balanced: ']' } />`);
|
|
84
|
-
yield eat(m`property+$: <_Expression />`);
|
|
85
|
-
yield eat(m`closeToken: <*Punctuator ']' { balancer: true } />`);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
default:
|
|
90
|
-
yield fail();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const grammar = triviaEnhancer(
|
|
96
|
-
{
|
|
97
|
-
triviaIsAllowed: (s) => s.span === 'Bare',
|
|
98
|
-
triviaMatcher: m`#: :Comment: <__Trivia /[ \n\r\t]|\/\/|\/\*/ />`,
|
|
99
|
-
},
|
|
100
|
-
atrivialGrammar,
|
|
101
|
-
);
|