tree_sitter_dart 0.1.0 copy "tree_sitter_dart: ^0.1.0" to clipboard
tree_sitter_dart: ^0.1.0 copied to clipboard

Pure-Dart Tree-sitter table runtime, query engine, and scanner ports.

tree_sitter_dart #

A Tree-sitter-compatible parser and query runtime implemented in Dart. It decodes generated Tree-sitter parse tables, runs the lexer and GLR parser, executes Scheme highlight/locals/injection queries, supports incremental edits, and includes Dart ports of the external scanners required by the bundled grammars.

The runtime is a standalone package. It does not import Flutter, Lapce editor packages, JavaScript, WebAssembly, native libraries, or FFI. The Flutter editor depends on this package through its public API; this package never depends on the editor.

import 'dart:io';

import 'package:tree_sitter_dart/tree_sitter.dart';

final bundle = TreeSitterLanguageBundle.decode(
  await File('assets/grammars/javascript.json').readAsString(),
);
final tree = GeneratedTreeSitterParser(bundle.language).parse(
  'export class Example {}',
);

print(tree.rootNode.toSExpression());

Use tree_sitter_scanners.dart when constructing a registry that needs direct access to scanner implementations. Normal parser and query consumers should import only tree_sitter.dart.

The checked-in asset set contains 121 pinned grammar-table bundles and their source licenses. tool/tree_sitter_grammars.json records each repository and revision; the provenance, scanner coverage, query parity, and corpus tools make the generated surface reproducible.

The browser syntax worker is compiled from this package to WasmGC with a dart2js fallback before a Flutter web build:

dart run tool/build_syntax_worker.dart
flutter build web

The generated files are written to the Git-ignored assets/worker/ directory and bundled as ordinary Flutter package assets. After a Flutter web build, verify that all runtime files were copied and that the Wasm module is valid:

dart run tool/verify_syntax_worker_copy.dart ../../dist/cloudflare-editor
0
likes
140
points
152
downloads

Documentation

API reference

Publisher

verified publishermeshagent.com

Weekly Downloads

Pure-Dart Tree-sitter table runtime, query engine, and scanner ports.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, web

More

Packages that depend on tree_sitter_dart