@willbooster/tree-sitter-javascript 18.0.0 → 20.0.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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.51.1-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-21.3.0-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-javascript.svg)](https://crates.io/crates/willbooster-tree-sitter-javascript)
10
10
 
11
11
  JavaScript and JSX grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -82,10 +82,9 @@ array/formal and object-rest extension hooks. The crate ships `tree-sitter.json`
82
82
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-javascript) and the
83
83
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 15.5.4:
84
84
 
85
- ```toml
86
- [dependencies]
87
- tree-sitter = { package = "willbooster-tree-sitter", version = "15.5.4" }
88
- tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "16" }
85
+ ```sh
86
+ cargo add willbooster-tree-sitter@15.5.4 --rename tree-sitter
87
+ cargo add willbooster-tree-sitter-javascript --rename tree-sitter-javascript
89
88
  ```
90
89
 
91
90
  ```rust
package/grammar.js CHANGED
@@ -134,6 +134,7 @@ module.exports = grammar({
134
134
  sym('_class_heritage_end'),
135
135
  sym('_class_heritage_yield_identifier'),
136
136
  sym('_class_heritage_await_identifier'),
137
+ sym('_template_escape_sequence'),
137
138
  ],
138
139
 
139
140
  extras: ($) => [$.comment, sym('html_comment'), /[\s\p{Zs}\uFEFF\u2028\u2029\u2060\u200B]/u],
@@ -1039,7 +1040,7 @@ module.exports = grammar({
1039
1040
  'template_call',
1040
1041
  seq(
1041
1042
  field('function', alias($._assignment_call_primary, $.primary_expression)),
1042
- field('arguments', $.template_string)
1043
+ field('arguments', alias($._tagged_template_string, $.template_string))
1043
1044
  )
1044
1045
  ),
1045
1046
 
@@ -1149,7 +1150,7 @@ module.exports = grammar({
1149
1150
  'template_call',
1150
1151
  seq(
1151
1152
  field('function', alias($._constructor_chain_base, $.primary_expression)),
1152
- field('arguments', $.template_string)
1153
+ field('arguments', alias($._tagged_template_string, $.template_string))
1153
1154
  )
1154
1155
  ),
1155
1156
 
@@ -1373,23 +1374,10 @@ module.exports = grammar({
1373
1374
  // http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
1374
1375
  comment: () => token(choice(seq('//', /[^\r\n\u2028\u2029]*/), seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
1375
1376
 
1376
- template_string: ($) =>
1377
- seq(
1378
- '`',
1379
- repeat(
1380
- choice(
1381
- alias(sym('_template_chars'), sym('string_fragment')),
1382
- $.escape_sequence,
1383
- alias($._invalid_template_escape, $.escape_sequence),
1384
- $.template_substitution
1385
- )
1386
- ),
1387
- '`'
1388
- ),
1377
+ template_string: ($) => templateString($, false),
1378
+
1379
+ _tagged_template_string: ($) => templateString($, true),
1389
1380
 
1390
- // Tagged templates allow `\x` and `\u` without the hex digits an escape_sequence needs (the cooked string is
1391
- // undefined). The lexer prefers the longer escape_sequence when the digits follow. Untagged templates reject these
1392
- // escapes, but the lexer cannot tell the two apart.
1393
1381
  _invalid_template_escape: () => token.immediate(seq('\\', /[xu]/)),
1394
1382
 
1395
1383
  template_substitution: ($) => seq('${', $._expressions, '}'),
@@ -1754,14 +1742,17 @@ function contextualIdentifier($, heritage) {
1754
1742
  }
1755
1743
 
1756
1744
  /**
1757
- * @param {GrammarSymbols<'import' | 'arguments' | 'template_string' | 'optional_chain'>} $
1745
+ * @param {GrammarSymbols<'import' | 'arguments' | '_tagged_template_string' | 'template_string' | 'optional_chain'>} $
1758
1746
  * @param {RuleOrLiteral} callee
1759
1747
  * @param {RuleOrLiteral} primary
1760
1748
  */
1761
1749
  function callExpression($, callee, primary) {
1762
1750
  return choice(
1763
1751
  prec('call', seq(field('function', choice(callee, $.import)), field('arguments', $.arguments))),
1764
- prec('template_call', seq(field('function', primary), field('arguments', $.template_string))),
1752
+ prec(
1753
+ 'template_call',
1754
+ seq(field('function', primary), field('arguments', alias($._tagged_template_string, $.template_string)))
1755
+ ),
1765
1756
  prec(
1766
1757
  'member',
1767
1758
  seq(field('function', primary), field('optional_chain', $.optional_chain), field('arguments', $.arguments))
@@ -1872,3 +1863,22 @@ function functionScope(async, content, kind = 'function_signature') {
1872
1863
  const name = kind === 'function' && !async ? 'sync_function' : `${async ? 'async_' : ''}${kind}`;
1873
1864
  return seq(sym(`_${name}_start`), content, sym('_function_context_end'));
1874
1865
  }
1866
+
1867
+ /**
1868
+ * @param {GrammarSymbols<'escape_sequence' | '_invalid_template_escape' | 'template_substitution'>} $
1869
+ * @param {boolean} tagged
1870
+ */
1871
+ function templateString($, tagged) {
1872
+ return seq(
1873
+ '`',
1874
+ repeat(
1875
+ choice(
1876
+ alias(sym('_template_chars'), sym('string_fragment')),
1877
+ tagged ? $.escape_sequence : alias(sym('_template_escape_sequence'), $.escape_sequence),
1878
+ ...(tagged ? [alias($._invalid_template_escape, $.escape_sequence)] : []),
1879
+ $.template_substitution
1880
+ )
1881
+ ),
1882
+ '`'
1883
+ );
1884
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "18.0.0",
3
+ "version": "20.0.0",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -46,12 +46,12 @@
46
46
  "verify-full": "bun wb verify --full"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/parser": "8.0.7",
49
+ "@babel/parser": "8.0.8",
50
50
  "@tsconfig/bun": "1.0.11",
51
51
  "@types/bun": "1.4.4",
52
52
  "@vitest/browser-playwright": "5.0.5",
53
53
  "@willbooster/oxlint-config": "1.4.9",
54
- "@willbooster/wb": "22.32.3",
54
+ "@willbooster/wb": "23.0.2",
55
55
  "@willbooster/web-tree-sitter": "15.5.4",
56
56
  "acorn": "8.19.0",
57
57
  "acorn-jsx": "5.3.2",
@@ -61,9 +61,9 @@
61
61
  "oxlint-tsgolint": "7.0.2005",
62
62
  "playwright": "1.64.1",
63
63
  "semantic-release": "25.0.9",
64
- "vite": "8.3.4",
64
+ "vite": "8.3.5",
65
65
  "vitest": "5.0.5",
66
- "wrangler": "4.151.1"
66
+ "wrangler": "4.152.0"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@willbooster/web-tree-sitter": "^15.0.0"
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,8 @@
13
13
  ],
14
14
  "injection-regex": "^(js|javascript)$",
15
15
  "external-files": [
16
- "src/function_context.h"
16
+ "src/function_context.h",
17
+ "src/literal.h"
17
18
  ]
18
19
  },
19
20
  {
@@ -27,12 +28,13 @@
27
28
  "injection-regex": "^javascript-script$",
28
29
  "external-files": [
29
30
  "src/scanner.c",
30
- "src/function_context.h"
31
+ "src/function_context.h",
32
+ "src/literal.h"
31
33
  ]
32
34
  }
33
35
  ],
34
36
  "metadata": {
35
- "version": "18.0.0",
37
+ "version": "20.0.0",
36
38
  "license": "MIT",
37
39
  "description": "JavaScript grammar for tree-sitter",
38
40
  "authors": [