@willbooster/tree-sitter-dart 1.0.0 → 2.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 +15 -14
- package/grammar.js +11 -9
- package/package.json +8 -9
- package/tree-sitter-dart.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,33 +5,34 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-dart/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-dart/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-dart)
|
|
10
10
|
|
|
11
11
|
Dart grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
12
12
|
[nielsenko/tree-sitter-dart](https://github.com/nielsenko/tree-sitter-dart). We are grateful
|
|
13
13
|
to its authors and contributors. This is not an official release of that project.
|
|
14
14
|
|
|
15
|
-
This fork
|
|
16
|
-
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI number (`
|
|
17
|
-
version
|
|
15
|
+
This fork extends upstream's version 0.2.0 grammar, retains its external scanner, and generates the parser with the
|
|
16
|
+
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI number (`0x57420006`), so it loads only with the fork's runtime,
|
|
17
|
+
version 7.0.5 or later in the 7.x series; upstream's runtime rejects it, and the fork's runtime rejects parsers generated by upstream's CLI.
|
|
18
18
|
|
|
19
19
|
## Differences from upstream's parser
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Known differences from upstream's 0.2.0 parser include:
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
- Arrow function bodies include trailing selectors. For `(x) => a.b(x)`, the call belongs inside the
|
|
24
|
+
`function_expression_body`; upstream attaches it to the arrow function instead. Nested arrow functions follow the
|
|
25
|
+
same rule. Block-bodied function literals still support immediate calls and member access. Public node names and
|
|
26
|
+
the `parameters:` and `body:` fields are preserved.
|
|
27
|
+
- Error recovery on invalid input can differ from upstream.
|
|
28
|
+
[Issue #4](https://github.com/WillBooster/tree-sitter-dart/issues/4) tracks these differences.
|
|
29
29
|
- A NUL character in a line comment or between tokens parses as ordinary text, where upstream's lexer reports an error.
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
33
|
The npm package ships `tree-sitter-dart.wasm` for
|
|
34
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
34
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 7.0.5 or later in the 7.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
|
|
35
|
+
In Node.js and Bun, load the grammar from its path:
|
|
35
36
|
|
|
36
37
|
```js
|
|
37
38
|
import { fileURLToPath } from 'node:url';
|
|
@@ -77,8 +78,8 @@ fuzzed with:
|
|
|
77
78
|
|
|
78
79
|
```toml
|
|
79
80
|
[dependencies]
|
|
80
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
81
|
-
tree-sitter-dart = { package = "willbooster-tree-sitter-dart", version = "
|
|
81
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
|
|
82
|
+
tree-sitter-dart = { package = "willbooster-tree-sitter-dart", version = "2" }
|
|
82
83
|
```
|
|
83
84
|
|
|
84
85
|
```rust
|
package/grammar.js
CHANGED
|
@@ -145,9 +145,6 @@ module.exports = grammar({
|
|
|
145
145
|
[$._primary, $.assignable_expression],
|
|
146
146
|
[$._primary, $.labeled_statement],
|
|
147
147
|
// Assignable-vs-wrapper: same chain reduces under either name; lookahead picks
|
|
148
|
-
[$.assignable_expression, $.member_expression, $._unary_expression],
|
|
149
|
-
[$.assignable_expression, $.index_expression, $._unary_expression],
|
|
150
|
-
[$.assignable_expression, $.null_aware_member_expression, $._unary_expression],
|
|
151
148
|
[$.assignable_expression, $.null_aware_index_expression, $._unary_expression],
|
|
152
149
|
// Type name ambiguities
|
|
153
150
|
[$._type_name],
|
|
@@ -200,7 +197,6 @@ module.exports = grammar({
|
|
|
200
197
|
[$.type_arguments, $.relational_operator, $.type_parameters],
|
|
201
198
|
// Generic call/instantiation vs comparisons (TS-style GLR fork on `<`)
|
|
202
199
|
[$._unary_expression, $.instantiation_expression],
|
|
203
|
-
[$._unary_expression, $.call_expression],
|
|
204
200
|
// Record literal vs record field / record type
|
|
205
201
|
[$._record_literal_no_const, $.record_field],
|
|
206
202
|
[$.record_type, $._record_literal_no_const],
|
|
@@ -1149,7 +1145,7 @@ module.exports = grammar({
|
|
|
1149
1145
|
_unary_expression: ($) =>
|
|
1150
1146
|
prec(
|
|
1151
1147
|
PREC.UNARY_PREFIX,
|
|
1152
|
-
choice($._postfix_expression, $.unary_expression),
|
|
1148
|
+
choice($._postfix_expression, $.unary_expression, $.function_expression),
|
|
1153
1149
|
),
|
|
1154
1150
|
|
|
1155
1151
|
unary_expression: ($) =>
|
|
@@ -1274,7 +1270,7 @@ module.exports = grammar({
|
|
|
1274
1270
|
choice(
|
|
1275
1271
|
$._literal,
|
|
1276
1272
|
$.identifier,
|
|
1277
|
-
$.function_expression,
|
|
1273
|
+
alias($._function_primary, $.function_expression),
|
|
1278
1274
|
$._instantiation,
|
|
1279
1275
|
$.parenthesized_expression,
|
|
1280
1276
|
"this",
|
|
@@ -1293,11 +1289,17 @@ module.exports = grammar({
|
|
|
1293
1289
|
),
|
|
1294
1290
|
|
|
1295
1291
|
function_expression_body: ($) =>
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1292
|
+
seq(optional("async"), "=>", $._expression),
|
|
1293
|
+
|
|
1294
|
+
_function_primary: ($) =>
|
|
1295
|
+
seq(
|
|
1296
|
+
field("parameters", $._formal_parameter_part),
|
|
1297
|
+
field("body", alias($._function_primary_body, $.function_expression_body)),
|
|
1299
1298
|
),
|
|
1300
1299
|
|
|
1300
|
+
_function_primary_body: ($) =>
|
|
1301
|
+
seq(optional(choice("async", "async*", "sync*")), $.block),
|
|
1302
|
+
|
|
1301
1303
|
// Hidden supertype: any expression that constructs an instance. Lets
|
|
1302
1304
|
// queries address the three forms (new/const/implicit) uniformly via
|
|
1303
1305
|
// (_instantiation) without alternation. Does not add an AST layer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-dart",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Dart grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -46,22 +46,21 @@
|
|
|
46
46
|
"@vitest/browser-playwright": "5.0.3",
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
-
"@willbooster/wb": "22.
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
49
|
+
"@willbooster/wb": "22.26.1",
|
|
50
|
+
"@willbooster/web-tree-sitter": "7.0.5",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
|
-
"lefthook": "2.1
|
|
53
|
-
"oxfmt": "0.
|
|
54
|
-
"oxlint": "1.
|
|
55
|
-
"oxlint-tsgolint": "7.0.
|
|
52
|
+
"lefthook": "2.2.1",
|
|
53
|
+
"oxfmt": "0.72.0",
|
|
54
|
+
"oxlint": "1.87.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
56
56
|
"playwright": "1.63.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
|
-
"typescript": "7.0.2",
|
|
60
59
|
"vitest": "5.0.3",
|
|
61
60
|
"wrangler": "4.147.0"
|
|
62
61
|
},
|
|
63
62
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
63
|
+
"@willbooster/web-tree-sitter": "^7.0.5"
|
|
65
64
|
},
|
|
66
65
|
"peerDependenciesMeta": {
|
|
67
66
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-dart.wasm
CHANGED
|
Binary file
|