goldstein 4.0.0 → 4.0.2

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 CHANGED
@@ -1,3 +1,13 @@
1
+ 2023.08.30, v4.0.2
2
+
3
+ feature:
4
+ - 6f46703 parser options
5
+
6
+ 2023.08.29, v4.0.1
7
+
8
+ fix:
9
+ - 999445f goldstein: get back sync
10
+
1
11
  2023.08.28, v4.0.0
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -78,7 +78,7 @@ When you need to compile **Goldstein** to **JavaScript** use:
78
78
  ```js
79
79
  import {compile} from 'goldstein';
80
80
 
81
- await compile(`
81
+ compile(`
82
82
  fn hello() {
83
83
  guard text !== "world" else {
84
84
  return ""
@@ -117,7 +117,7 @@ const source = `
117
117
 
118
118
  const {keywordFn} = keywords;
119
119
 
120
- await compile(source, {
120
+ compile(source, {
121
121
  keywords: [
122
122
  keywordFn,
123
123
  function id(Parser) {
package/bin/gs.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  writeFileSync,
7
7
  unlinkSync,
8
8
  } from 'node:fs';
9
+ import process from 'node:process';
9
10
  import {compile} from '../packages/goldstein/index.js';
10
11
 
11
12
  const [arg] = process.argv.slice(2);
package/build/parser.cjs CHANGED
@@ -5365,17 +5365,23 @@ var extendParser = (keywords3) => {
5365
5365
  };
5366
5366
  };
5367
5367
  var createParse = (parser) => (source) => {
5368
+ const comments = [];
5368
5369
  const options = {
5369
5370
  ecmaVersion: "latest",
5370
5371
  sourceType: "module",
5371
5372
  locations: true,
5372
- comment: true
5373
+ comment: true,
5374
+ ranges: true,
5375
+ onComment: (a) => {
5376
+ comments.push(a);
5377
+ }
5373
5378
  };
5374
5379
  const result = parser.parse(source, options);
5375
5380
  const tokens = Array.from(parser.tokenizer(source, options));
5376
5381
  return {
5377
5382
  ...result,
5378
- tokens
5383
+ tokens,
5384
+ comments
5379
5385
  };
5380
5386
  };
5381
5387
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstein",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "JavaScript with no limits",
@@ -29,6 +29,9 @@
29
29
  "wisdom": "madrun wisdom"
30
30
  },
31
31
  "dependencies": {
32
+ "@putout/plugin-declare": "^2.0.1",
33
+ "@putout/plugin-logical-expressions": "^4.0.0",
34
+ "@putout/plugin-try-catch": "^3.0.0",
32
35
  "@putout/printer": "^3.6.0",
33
36
  "acorn": "^8.7.1",
34
37
  "esbuild": "^0.19.2",
@@ -43,7 +46,7 @@
43
46
  "c8": "^8.0.0",
44
47
  "check-dts": "^0.7.1",
45
48
  "escover": "^3.4.0",
46
- "eslint": "^8.0.0-beta.1",
49
+ "eslint": "^8.48.0",
47
50
  "eslint-plugin-n": "^16.0.1",
48
51
  "eslint-plugin-putout": "^19.0.3",
49
52
  "madrun": "^9.0.0",
@@ -1,20 +1,23 @@
1
- import {transformAsync} from 'putout';
1
+ import {transform} from 'putout';
2
2
  import {print} from '@putout/printer';
3
3
  import {parse} from './parser.js';
4
4
  import estreeToBabel from 'estree-to-babel';
5
+ import tryCatchPlugin from '@putout/plugin-try-catch';
6
+ import declarePlugin from '@putout/plugin-declare';
7
+ import logicalExpressionsPlugin from '@putout/plugin-logical-expressions';
5
8
 
6
9
  export * from './parser.js';
7
- export const compile = async (source, options = {}) => {
10
+ export const compile = (source, options = {}) => {
8
11
  const ast = estreeToBabel(parse(source, options));
9
12
 
10
- await transformAsync(ast, source, {
13
+ transform(ast, source, {
11
14
  rules: {
12
15
  ...options.rules,
13
16
  },
14
17
  plugins: [
15
- 'try-catch',
16
- 'declare',
17
- 'logical-expressions',
18
+ ['try-catch', tryCatchPlugin],
19
+ ['declare', declarePlugin],
20
+ ['logical-expressions', logicalExpressionsPlugin],
18
21
  ],
19
22
  });
20
23
 
@@ -2,7 +2,6 @@ import {Parser} from 'acorn';
2
2
 
3
3
  export const extendParser = (keywords) => {
4
4
  const parser = Parser.extend(...keywords);
5
-
6
5
  const parse = createParse(parser);
7
6
 
8
7
  return {
@@ -11,11 +10,16 @@ export const extendParser = (keywords) => {
11
10
  };
12
11
 
13
12
  const createParse = (parser) => (source) => {
13
+ const comments = [];
14
14
  const options = {
15
15
  ecmaVersion: 'latest',
16
16
  sourceType: 'module',
17
17
  locations: true,
18
18
  comment: true,
19
+ ranges: true,
20
+ onComment: (a) => {
21
+ comments.push(a);
22
+ },
19
23
  };
20
24
 
21
25
  const result = parser.parse(source, options);
@@ -24,5 +28,6 @@ const createParse = (parser) => (source) => {
24
28
  return {
25
29
  ...result,
26
30
  tokens,
31
+ comments,
27
32
  };
28
33
  };