goldstein 5.5.2 → 5.6.1
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 +11 -0
- package/README.md +3 -3
- package/package.json +1 -1
- package/packages/goldstein/parser.js +2 -5
- package/packages/keyword-fn/index.js +19 -6
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2024.05.09, v5.6.1
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- ecd46b4 goldstein: override keywords
|
|
5
|
+
|
|
6
|
+
2024.05.08, v5.6.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 4be8b79 goldstein: keyword-fn: add constant
|
|
10
|
+
- f0b7d54 goldstein: keyword-fn: add ability to use "fn" as function name
|
|
11
|
+
|
|
1
12
|
2024.05.08, v5.5.2
|
|
2
13
|
|
|
3
14
|
fix:
|
package/README.md
CHANGED
|
@@ -111,14 +111,14 @@ const source = `
|
|
|
111
111
|
const {keywordFn} = keywords;
|
|
112
112
|
|
|
113
113
|
compile(source, {
|
|
114
|
-
keywords:
|
|
114
|
+
keywords: {
|
|
115
115
|
keywordFn,
|
|
116
|
-
|
|
116
|
+
keywordId(Parser) {
|
|
117
117
|
const {keywordTypes} = Parser.acorn;
|
|
118
118
|
|
|
119
119
|
return class extends Parser {};
|
|
120
120
|
},
|
|
121
|
-
|
|
121
|
+
},
|
|
122
122
|
rules: {
|
|
123
123
|
declare: ['on', {
|
|
124
124
|
declarations: {
|
package/package.json
CHANGED
|
@@ -30,11 +30,8 @@ const defaultKeywords = {
|
|
|
30
30
|
|
|
31
31
|
export const keywords = defaultKeywords;
|
|
32
32
|
|
|
33
|
-
export const parse = (source, options = {}
|
|
34
|
-
const {parse} = extendParser(Object.values(
|
|
35
|
-
...options.keywords,
|
|
36
|
-
...keywords,
|
|
37
|
-
}));
|
|
33
|
+
export const parse = (source, options = {}) => {
|
|
34
|
+
const {parse} = extendParser(Object.values(options.keywords || defaultKeywords));
|
|
38
35
|
|
|
39
36
|
const ast = parse(source);
|
|
40
37
|
|
|
@@ -1,29 +1,42 @@
|
|
|
1
1
|
import {addKeyword, TokenType} from '../operator/index.js';
|
|
2
2
|
|
|
3
|
+
const KEYWORD_FN = 'fn';
|
|
4
|
+
|
|
3
5
|
export default function fn(Parser) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
const {keywordTypes} = Parser.acorn;
|
|
7
|
+
|
|
8
|
+
keywordTypes.fn = new TokenType(KEYWORD_FN, {
|
|
9
|
+
keyword: KEYWORD_FN,
|
|
6
10
|
});
|
|
7
11
|
|
|
8
12
|
return class extends Parser {
|
|
9
13
|
parse() {
|
|
10
|
-
this.keywords = addKeyword(
|
|
14
|
+
this.keywords = addKeyword(KEYWORD_FN, this.keywords);
|
|
11
15
|
|
|
12
16
|
return super.parse();
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
parseStatement(context, topLevel, exports) {
|
|
16
|
-
if (this.type ===
|
|
17
|
-
this.type =
|
|
20
|
+
if (this.type === keywordTypes.fn)
|
|
21
|
+
this.type = keywordTypes.function;
|
|
18
22
|
|
|
19
23
|
return super.parseStatement(context, topLevel, exports);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
shouldParseExportStatement() {
|
|
23
|
-
if (this.type ===
|
|
27
|
+
if (this.type === keywordTypes.fn)
|
|
24
28
|
return true;
|
|
25
29
|
|
|
26
30
|
return super.shouldParseExportStatement();
|
|
27
31
|
}
|
|
32
|
+
|
|
33
|
+
checkUnreserved(ref) {
|
|
34
|
+
const {name} = ref;
|
|
35
|
+
|
|
36
|
+
if (name === KEYWORD_FN)
|
|
37
|
+
return;
|
|
38
|
+
|
|
39
|
+
return super.checkUnreserved(ref);
|
|
40
|
+
}
|
|
28
41
|
};
|
|
29
42
|
}
|