goldstein 5.5.2 → 5.6.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/ChangeLog +6 -0
- package/package.json +1 -1
- package/packages/keyword-fn/index.js +23 -6
package/ChangeLog
CHANGED
package/package.json
CHANGED
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
import {addKeyword, TokenType} from '../operator/index.js';
|
|
2
|
+
import {tokTypes as tt} from 'acorn';
|
|
3
|
+
|
|
4
|
+
const KEYWORD_FN = 'fn';
|
|
2
5
|
|
|
3
6
|
export default function fn(Parser) {
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
const {keywordTypes} = Parser.acorn;
|
|
8
|
+
|
|
9
|
+
keywordTypes.fn = new TokenType(KEYWORD_FN, {
|
|
10
|
+
keyword: KEYWORD_FN,
|
|
6
11
|
});
|
|
7
12
|
|
|
8
13
|
return class extends Parser {
|
|
9
14
|
parse() {
|
|
10
|
-
this.keywords = addKeyword(
|
|
15
|
+
this.keywords = addKeyword(KEYWORD_FN, this.keywords);
|
|
11
16
|
|
|
12
17
|
return super.parse();
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
parseStatement(context, topLevel, exports) {
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const isParen = this.eat(tt.parenL);
|
|
22
|
+
|
|
23
|
+
if (!isParen && this.type === keywordTypes.fn)
|
|
24
|
+
this.type = keywordTypes.function;
|
|
18
25
|
|
|
19
26
|
return super.parseStatement(context, topLevel, exports);
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
shouldParseExportStatement() {
|
|
23
|
-
if (this.type ===
|
|
30
|
+
if (this.type === keywordTypes.fn)
|
|
24
31
|
return true;
|
|
25
32
|
|
|
26
33
|
return super.shouldParseExportStatement();
|
|
27
34
|
}
|
|
35
|
+
|
|
36
|
+
checkUnreserved(ref) {
|
|
37
|
+
const {name} = ref;
|
|
38
|
+
|
|
39
|
+
if (name === KEYWORD_FN)
|
|
40
|
+
return;
|
|
41
|
+
|
|
42
|
+
return super.checkUnreserved(ref);
|
|
43
|
+
}
|
|
28
44
|
};
|
|
29
45
|
}
|
|
46
|
+
|