6 releases (3 stable)

1.2.0 May 25, 2024
1.1.0 Aug 14, 2023
1.0.0 Jun 20, 2023
0.0.3 Feb 27, 2023

#265 in Text editors

Download history 11/week @ 2024-02-24 1/week @ 2024-03-02 2/week @ 2024-03-09 18/week @ 2024-03-30 89/week @ 2024-04-13 173/week @ 2024-05-25 6/week @ 2024-06-01

179 downloads per month

MIT license

2.5MB
98K SLoC

C 98K SLoC // 0.0% comments Scheme 337 SLoC // 0.1% comments JavaScript 149 SLoC // 0.2% comments Rust 35 SLoC // 0.1% comments

tree-sitter-starlark

Build Status Discord

Starlark grammar for tree-sitter

Adapted from the official spec and the Google spec


lib.rs:

This crate provides Starlark 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:

use tree_sitter::Parser;

let code = r#"
load("//tools/build_defs/starlark:starlark.bzl", "starlark_library")
starlark_library(
    name = "example",
    srcs = ["example.star"],
)
"#;
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_starlark::language()).expect("Error loading Starlark grammar");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Dependencies

~2.8–4MB
~72K SLoC