@willbooster/tree-sitter-rust 1.0.0 → 1.1.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 +1 -1
- package/grammar.js +38 -5
- package/package.json +1 -1
- package/src/node-types.json +4 -0
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ cargo test
|
|
|
93
93
|
fail to parse exactly as listed in `script/known-failures.txt`. The first run clones the repositories. The example repositories are pinned to commits in
|
|
94
94
|
`script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites
|
|
95
95
|
it; review its diff before committing;
|
|
96
|
-
- a performance check (`test/unit/performance.test.ts`) that recovering from an error on each
|
|
96
|
+
- a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes
|
|
97
97
|
linear time, since consumers parse files while they are being edited. It loads the Wasm build through
|
|
98
98
|
@willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating the parser;
|
|
99
99
|
- checks that the Wasm build parses in Chromium (`test/unit/browser/`) and in Cloudflare Workers with and without
|
package/grammar.js
CHANGED
|
@@ -307,10 +307,41 @@ module.exports = grammar({
|
|
|
307
307
|
choice(';', field('body', $.declaration_list))
|
|
308
308
|
),
|
|
309
309
|
|
|
310
|
-
foreign_mod_item: ($) =>
|
|
310
|
+
foreign_mod_item: ($) =>
|
|
311
|
+
seq(
|
|
312
|
+
optional('unsafe'),
|
|
313
|
+
$.extern_modifier,
|
|
314
|
+
choice(';', field('body', alias($._foreign_declaration_list, $.declaration_list)))
|
|
315
|
+
),
|
|
311
316
|
|
|
312
317
|
declaration_list: ($) => seq('{', repeat($._declaration_statement), '}'),
|
|
313
318
|
|
|
319
|
+
// Items in `extern` blocks may be `safe` functions and `safe` or `unsafe` statics. `safe` is a keyword only where
|
|
320
|
+
// such an item starts: accepting it on every item would make it one wherever an item can start, breaking its uses as
|
|
321
|
+
// an identifier (`let safe = …; safe = …;`).
|
|
322
|
+
_foreign_declaration_list: ($) =>
|
|
323
|
+
seq(
|
|
324
|
+
'{',
|
|
325
|
+
repeat(
|
|
326
|
+
choice(
|
|
327
|
+
$._declaration_statement,
|
|
328
|
+
alias($._safe_function_signature_item, $.function_signature_item),
|
|
329
|
+
alias($._qualified_static_item, $.static_item)
|
|
330
|
+
)
|
|
331
|
+
),
|
|
332
|
+
'}'
|
|
333
|
+
),
|
|
334
|
+
|
|
335
|
+
_safe_function_signature_item: ($) =>
|
|
336
|
+
seq(optional($.visibility_modifier), alias($._safe_modifier, $.function_modifiers), $._function_signature),
|
|
337
|
+
|
|
338
|
+
// Aliasing the bare token instead would make `function_modifiers` a leaf without the `safe` child that other
|
|
339
|
+
// modifiers have.
|
|
340
|
+
_safe_modifier: () => 'safe',
|
|
341
|
+
|
|
342
|
+
_qualified_static_item: ($) =>
|
|
343
|
+
seq(optional($.visibility_modifier), choice('safe', 'unsafe'), $._static_declaration),
|
|
344
|
+
|
|
314
345
|
struct_item: ($) =>
|
|
315
346
|
seq(
|
|
316
347
|
optional($.visibility_modifier),
|
|
@@ -389,9 +420,10 @@ module.exports = grammar({
|
|
|
389
420
|
';'
|
|
390
421
|
),
|
|
391
422
|
|
|
392
|
-
static_item: ($) =>
|
|
423
|
+
static_item: ($) => seq(optional($.visibility_modifier), $._static_declaration),
|
|
424
|
+
|
|
425
|
+
_static_declaration: ($) =>
|
|
393
426
|
seq(
|
|
394
|
-
optional($.visibility_modifier),
|
|
395
427
|
'static',
|
|
396
428
|
|
|
397
429
|
// Not actual rust syntax, but made popular by the lazy_static crate.
|
|
@@ -432,9 +464,10 @@ module.exports = grammar({
|
|
|
432
464
|
),
|
|
433
465
|
|
|
434
466
|
function_signature_item: ($) =>
|
|
467
|
+
seq(optional($.visibility_modifier), optional($.function_modifiers), $._function_signature),
|
|
468
|
+
|
|
469
|
+
_function_signature: ($) =>
|
|
435
470
|
seq(
|
|
436
|
-
optional($.visibility_modifier),
|
|
437
|
-
optional($.function_modifiers),
|
|
438
471
|
'fn',
|
|
439
472
|
field('name', choice($.identifier, $.metavariable)),
|
|
440
473
|
field('type_parameters', optional($.type_parameters)),
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|