difftastic/vendored_parsers/tree-sitter-dart/tree_sitter
Wilfred Hughes d0cf8c6d0d Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
..
bin Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
example Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
lib Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
test Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
tree-sitter@be79158f7e Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
.gitignore Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
.pubignore Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
CHANGELOG.md Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
LICENSE Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
Makefile Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
README.md Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
analysis_options.yaml Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
api_config.yaml Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
parser_config.yaml Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00
pubspec.yaml Merge commit 'e398400a0b785af3cf571f5a57eccab242f0cdf9' 2023-08-08 23:28:07 +07:00

README.md

Tree Sitter Dart Library

This library provides Dart bindings for the Tree Sitter c parsing library. It allows parsing source code into a syntax tree that you can traverse and query.

Installation

You must have the tree sitter library available as a dynamic library on your system.

Then set the library location using:

TreeSitterConfig.setLibraryPath('/path/to/libtree-sitter.so');

Next create a parser for your language by first creating a dynamic library for your language's grammar.

Then load and use the parser:

import 'package:ffi/ffi.dart';
import 'package:tree_sitter/tree_sitter.dart';

void main() {
  final parser =
      Parser(sharedLibrary: 'libdart.dylib', entryPoint: 'tree_sitter_dart');
  final program = "class A {}";
  final tree = parser.parse(program);
  print(tree.root.string);
}

You can access other apis via the top level treeSitterApi ffi wrapper

Or you can help contribute to an idiomatic dart api on top of the ffi wrapper. Many of the apis are started but not complete.

Expect breaking changes while we figure out the best api