@willbooster/tree-sitter-javascript 18.0.0 → 19.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 +4 -5
- package/grammar.js +29 -20
- package/package.json +5 -5
- package/tree-sitter-javascript.wasm +0 -0
- package/tree-sitter-javascript_script.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](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
|
-
```
|
|
86
|
-
|
|
87
|
-
|
|
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
|
@@ -1039,7 +1039,7 @@ module.exports = grammar({
|
|
|
1039
1039
|
'template_call',
|
|
1040
1040
|
seq(
|
|
1041
1041
|
field('function', alias($._assignment_call_primary, $.primary_expression)),
|
|
1042
|
-
field('arguments', $.template_string)
|
|
1042
|
+
field('arguments', alias($._tagged_template_string, $.template_string))
|
|
1043
1043
|
)
|
|
1044
1044
|
),
|
|
1045
1045
|
|
|
@@ -1149,7 +1149,7 @@ module.exports = grammar({
|
|
|
1149
1149
|
'template_call',
|
|
1150
1150
|
seq(
|
|
1151
1151
|
field('function', alias($._constructor_chain_base, $.primary_expression)),
|
|
1152
|
-
field('arguments', $.template_string)
|
|
1152
|
+
field('arguments', alias($._tagged_template_string, $.template_string))
|
|
1153
1153
|
)
|
|
1154
1154
|
),
|
|
1155
1155
|
|
|
@@ -1373,23 +1373,10 @@ module.exports = grammar({
|
|
|
1373
1373
|
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
|
1374
1374
|
comment: () => token(choice(seq('//', /[^\r\n\u2028\u2029]*/), seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
|
|
1375
1375
|
|
|
1376
|
-
template_string: ($) =>
|
|
1377
|
-
|
|
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
|
-
),
|
|
1376
|
+
template_string: ($) => templateString($, false),
|
|
1377
|
+
|
|
1378
|
+
_tagged_template_string: ($) => templateString($, true),
|
|
1389
1379
|
|
|
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
1380
|
_invalid_template_escape: () => token.immediate(seq('\\', /[xu]/)),
|
|
1394
1381
|
|
|
1395
1382
|
template_substitution: ($) => seq('${', $._expressions, '}'),
|
|
@@ -1754,14 +1741,17 @@ function contextualIdentifier($, heritage) {
|
|
|
1754
1741
|
}
|
|
1755
1742
|
|
|
1756
1743
|
/**
|
|
1757
|
-
* @param {GrammarSymbols<'import' | 'arguments' | 'template_string' | 'optional_chain'>} $
|
|
1744
|
+
* @param {GrammarSymbols<'import' | 'arguments' | '_tagged_template_string' | 'template_string' | 'optional_chain'>} $
|
|
1758
1745
|
* @param {RuleOrLiteral} callee
|
|
1759
1746
|
* @param {RuleOrLiteral} primary
|
|
1760
1747
|
*/
|
|
1761
1748
|
function callExpression($, callee, primary) {
|
|
1762
1749
|
return choice(
|
|
1763
1750
|
prec('call', seq(field('function', choice(callee, $.import)), field('arguments', $.arguments))),
|
|
1764
|
-
prec(
|
|
1751
|
+
prec(
|
|
1752
|
+
'template_call',
|
|
1753
|
+
seq(field('function', primary), field('arguments', alias($._tagged_template_string, $.template_string)))
|
|
1754
|
+
),
|
|
1765
1755
|
prec(
|
|
1766
1756
|
'member',
|
|
1767
1757
|
seq(field('function', primary), field('optional_chain', $.optional_chain), field('arguments', $.arguments))
|
|
@@ -1872,3 +1862,22 @@ function functionScope(async, content, kind = 'function_signature') {
|
|
|
1872
1862
|
const name = kind === 'function' && !async ? 'sync_function' : `${async ? 'async_' : ''}${kind}`;
|
|
1873
1863
|
return seq(sym(`_${name}_start`), content, sym('_function_context_end'));
|
|
1874
1864
|
}
|
|
1865
|
+
|
|
1866
|
+
/**
|
|
1867
|
+
* @param {GrammarSymbols<'escape_sequence' | '_invalid_template_escape' | 'template_substitution'>} $
|
|
1868
|
+
* @param {boolean} tagged
|
|
1869
|
+
*/
|
|
1870
|
+
function templateString($, tagged) {
|
|
1871
|
+
return seq(
|
|
1872
|
+
'`',
|
|
1873
|
+
repeat(
|
|
1874
|
+
choice(
|
|
1875
|
+
alias(sym('_template_chars'), sym('string_fragment')),
|
|
1876
|
+
$.escape_sequence,
|
|
1877
|
+
...(tagged ? [alias($._invalid_template_escape, $.escape_sequence)] : []),
|
|
1878
|
+
$.template_substitution
|
|
1879
|
+
)
|
|
1880
|
+
),
|
|
1881
|
+
'`'
|
|
1882
|
+
);
|
|
1883
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-javascript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.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.
|
|
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": "
|
|
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.
|
|
64
|
+
"vite": "8.3.5",
|
|
65
65
|
"vitest": "5.0.5",
|
|
66
|
-
"wrangler": "4.
|
|
66
|
+
"wrangler": "4.152.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@willbooster/web-tree-sitter": "^15.0.0"
|
|
Binary file
|
|
Binary file
|