#tree-sitter #device-tree #incremental #parser

tree-sitter-devicetree

Tree-sitter parser for Devicetree files, with support for Zephyr's superset of Devicetree syntax

5 unstable releases

0.12.1 Oct 19, 2024
0.12.0 Oct 19, 2024
0.11.1 Sep 26, 2024
0.11.0 Sep 26, 2024
0.10.0 Mar 16, 2024

#134 in Text editors

Download history 8/week @ 2024-07-14 12/week @ 2024-07-21 53/week @ 2024-07-28 39/week @ 2024-08-04 1/week @ 2024-08-25 1/week @ 2024-09-01 14/week @ 2024-09-15 268/week @ 2024-09-22 76/week @ 2024-09-29 3/week @ 2024-10-06 186/week @ 2024-10-13 123/week @ 2024-10-20 52/week @ 2024-10-27

366 downloads per month
Used in dts-lsp

MIT license

1MB
37K SLoC

C 36K SLoC JavaScript 557 SLoC // 0.0% comments Scheme 66 SLoC Rust 27 SLoC // 0.3% comments

tree-sitter-devicetree

A tree-sitter grammar for Devicetree with support for Zephyr's superset of Devicetree syntax.

Some parts of the grammar are adapted from tree-sitter-c.


lib.rs:

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

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

let code = r#"
"#;
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_devicetree::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading Devicetree parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Dependencies

~2–400KB