@bablr/language-en-es6 0.3.4 → 0.3.6
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 +4 -1
- package/lib/mixins/function.js +5 -11
- package/package.json +3 -3
package/lib/grammar.js
CHANGED
|
@@ -158,7 +158,7 @@ const atrivial = class ES6Grammar extends importMixin(
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
*Statement(args) {
|
|
161
|
-
let res = yield match(re`/import|export|class|var|const|let/`);
|
|
161
|
+
let res = yield match(re`/import|export|class|var|const|let|async/`);
|
|
162
162
|
switch (printSource(res)) {
|
|
163
163
|
case 'import':
|
|
164
164
|
yield eat(m`<ImportDeclaration />`);
|
|
@@ -169,6 +169,9 @@ const atrivial = class ES6Grammar extends importMixin(
|
|
|
169
169
|
case 'class':
|
|
170
170
|
yield eat(m`<ClassDeclaration />`);
|
|
171
171
|
break;
|
|
172
|
+
case 'async':
|
|
173
|
+
yield eat(m`<FunctionDeclaration />`);
|
|
174
|
+
break;
|
|
172
175
|
case 'var':
|
|
173
176
|
case 'const':
|
|
174
177
|
case 'let':
|
package/lib/mixins/function.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spam as m, re } from '@bablr/boot';
|
|
2
|
-
import { o, r, eat, eatMatch,
|
|
2
|
+
import { o, r, eat, eatMatch, match, shiftMatch, eatHeld } from '@bablr/helpers/grammar';
|
|
3
3
|
import { reservedWords } from '@bablr/language-en-es5';
|
|
4
4
|
import { List } from '@bablr/helpers/productions';
|
|
5
5
|
import { printSource } from '@bablr/agast-helpers/tree';
|
|
@@ -9,14 +9,11 @@ let reservedWords_ = new Set(reservedWords);
|
|
|
9
9
|
const mixin = (Base) =>
|
|
10
10
|
class es6FunctionGrammar extends Base {
|
|
11
11
|
*FunctionExpression({ props: { shorthand } }) {
|
|
12
|
+
yield eatMatch(m`asyncToken*: <*Keyword 'async' />`);
|
|
12
13
|
if (!shorthand) {
|
|
13
14
|
yield eat(m`sigilToken*: <*Keyword 'function' />`);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
let a = yield eatMatch(m`asyncToken*: <*Keyword 'async' />`);
|
|
17
|
-
let gen = yield eatMatch(m`starToken*: <* '*' />`);
|
|
18
|
-
|
|
19
|
-
if (a && gen) yield fail();
|
|
16
|
+
yield eatMatch(m`starToken*: <* '*' />`);
|
|
20
17
|
|
|
21
18
|
if (!shorthand) {
|
|
22
19
|
yield eatMatch(m`name$: <Identifier />`, o({}), o({ bind: true }));
|
|
@@ -43,12 +40,9 @@ const mixin = (Base) =>
|
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
*FunctionDeclaration() {
|
|
43
|
+
yield eatMatch(m`asyncToken*: <*Keyword 'async' />`);
|
|
46
44
|
yield eat(m`sigilToken*: <*Keyword 'function' />`);
|
|
47
|
-
|
|
48
|
-
let a = yield eatMatch(m`asyncToken*: <*Keyword 'async' />`);
|
|
49
|
-
let gen = yield eatMatch(m`starToken*: <* '*' />`);
|
|
50
|
-
|
|
51
|
-
if (a && gen) yield fail();
|
|
45
|
+
yield eatMatch(m`starToken*: <* '*' />`);
|
|
52
46
|
|
|
53
47
|
yield eat(m`name$: <Identifier />`, o({}), o({ bind: true }));
|
|
54
48
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/language-en-es6",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "A BABLR language for ES6 (JavaScript)",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12.0.0"
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"@bablr/agast-vm-helpers": "0.10.4",
|
|
25
25
|
"@bablr/boot": "0.11.3",
|
|
26
26
|
"@bablr/coroutine": "0.1.0",
|
|
27
|
-
"@bablr/helpers": "0.25.
|
|
27
|
+
"@bablr/helpers": "0.25.3",
|
|
28
28
|
"@bablr/language-en-blank-space": "0.10.12",
|
|
29
29
|
"@bablr/language-en-c-comments": "0.10.2",
|
|
30
|
-
"@bablr/language-en-es5": "0.3.
|
|
30
|
+
"@bablr/language-en-es5": "0.3.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
|