goldstein 5.6.0 → 5.7.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 +10 -0
- package/README.md +5 -4
- package/package.json +2 -2
- package/packages/goldstein/parser.js +6 -5
- package/packages/keyword-fn/index.js +2 -6
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -111,14 +111,15 @@ const source = `
|
|
|
111
111
|
const {keywordFn} = keywords;
|
|
112
112
|
|
|
113
113
|
compile(source, {
|
|
114
|
-
keywords:
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
keywords: {
|
|
115
|
+
...keywords,
|
|
116
|
+
keywordFn: null,
|
|
117
|
+
keywordId(Parser) {
|
|
117
118
|
const {keywordTypes} = Parser.acorn;
|
|
118
119
|
|
|
119
120
|
return class extends Parser {};
|
|
120
121
|
},
|
|
121
|
-
|
|
122
|
+
},
|
|
122
123
|
rules: {
|
|
123
124
|
declare: ['on', {
|
|
124
125
|
declarations: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goldstein",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "JavaScript with no limits",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@putout/plugin-try-catch": "^3.0.0",
|
|
33
33
|
"@putout/printer": "^8.0.1",
|
|
34
34
|
"acorn": "^8.7.1",
|
|
35
|
-
"esbuild": "^0.
|
|
35
|
+
"esbuild": "^0.21.1",
|
|
36
36
|
"esbuild-node-builtins": "^0.1.0",
|
|
37
37
|
"estree-to-babel": "^9.0.0",
|
|
38
38
|
"estree-util-attach-comments": "^3.0.0",
|
|
@@ -13,6 +13,8 @@ import keywordImport from '../keyword-import/index.js';
|
|
|
13
13
|
import keywordArrow from '../keyword-arrow/index.js';
|
|
14
14
|
import keywordAddArray from '../keyword-add-array/index.js';
|
|
15
15
|
|
|
16
|
+
const {values} = Object;
|
|
17
|
+
|
|
16
18
|
const defaultKeywords = {
|
|
17
19
|
keywordFn,
|
|
18
20
|
keywordGuard,
|
|
@@ -30,12 +32,11 @@ const defaultKeywords = {
|
|
|
30
32
|
|
|
31
33
|
export const keywords = defaultKeywords;
|
|
32
34
|
|
|
33
|
-
export const parse = (source, options = {}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
...keywords,
|
|
37
|
-
}));
|
|
35
|
+
export const parse = (source, options = {}) => {
|
|
36
|
+
const keywords = options.keywords || defaultKeywords;
|
|
37
|
+
const extensions = values(keywords).filter(Boolean);
|
|
38
38
|
|
|
39
|
+
const {parse} = extendParser(extensions);
|
|
39
40
|
const ast = parse(source);
|
|
40
41
|
|
|
41
42
|
if (options.type === 'estree')
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {addKeyword, TokenType} from '../operator/index.js';
|
|
2
|
-
import {tokTypes as tt} from 'acorn';
|
|
3
2
|
|
|
4
3
|
const KEYWORD_FN = 'fn';
|
|
5
4
|
|
|
6
|
-
export default function
|
|
5
|
+
export default function keywordFn(Parser) {
|
|
7
6
|
const {keywordTypes} = Parser.acorn;
|
|
8
7
|
|
|
9
8
|
keywordTypes.fn = new TokenType(KEYWORD_FN, {
|
|
@@ -18,9 +17,7 @@ export default function fn(Parser) {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
parseStatement(context, topLevel, exports) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!isParen && this.type === keywordTypes.fn)
|
|
20
|
+
if (this.type === keywordTypes.fn)
|
|
24
21
|
this.type = keywordTypes.function;
|
|
25
22
|
|
|
26
23
|
return super.parseStatement(context, topLevel, exports);
|
|
@@ -43,4 +40,3 @@ export default function fn(Parser) {
|
|
|
43
40
|
}
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
|
-
|