4 releases

0.0.4 May 7, 2024
0.0.3 Jan 23, 2023
0.0.2 Jan 19, 2023
0.0.1 Jan 19, 2023

#75 in Text editors

Download history 667/week @ 2024-06-18 612/week @ 2024-06-25 519/week @ 2024-07-02 592/week @ 2024-07-09 483/week @ 2024-07-16 521/week @ 2024-07-23 616/week @ 2024-07-30 984/week @ 2024-08-06 1066/week @ 2024-08-13 1127/week @ 2024-08-20 1073/week @ 2024-08-27 1186/week @ 2024-09-03 818/week @ 2024-09-10 552/week @ 2024-09-17 505/week @ 2024-09-24 479/week @ 2024-10-01

2,503 downloads per month
Used in ast-grep-language

MIT license

5MB
154K SLoC

C 151K SLoC JavaScript 2K SLoC // 0.2% comments Scheme 153 SLoC // 0.2% comments Rust 34 SLoC // 0.4% comments

tree-sitter-dart

This is a tree-sitter grammar written for the dart programming language. I attempted to adhere as closely as possible to the dart language spec. Initially I started with a copy of the tree-sitter Java grammar which is why there may be a few relics included in here. For the sake of simplifying the syntax tree, many items were made inlined with tree-sitter's "underscore" method of writing rules.

Getting Started

  • Go to the project directory
  • run npm install (first time)
  • run npm run build_init (first time) npm run build (subsequent times)
  • run npm run test

To test a single highlight file

  • run tree-sitter highlight test/highlight/types.dart

To test a single test file

  • run tree-sitter test -f 'testcasefilter'
  • for example tree-sitter test -f 'dart string literals'

To show the output of a parse for a sample file (for example while debugging highlight issues)

  • run tree-sitter parse path/to/file.dart

lib.rs:

This crate provides dart language support for the tree-sitter parsing library.

Typically, you will use the language function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = "";
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_dart::language()).expect("Error loading dart grammar");
let tree = parser.parse(code, None).unwrap();

Dependencies

~3–4MB
~77K SLoC