#incremental #parsing #c

tree-sitter-c

C grammar for the tree-sitter parsing library

7 releases

0.20.6 Aug 13, 2023
0.20.5 Aug 9, 2023
0.20.4 Jul 24, 2023
0.20.2 Aug 1, 2022
0.20.1 Sep 20, 2021

#43 in Text editors

Download history 2743/week @ 2023-08-14 2332/week @ 2023-08-21 1560/week @ 2023-08-28 1490/week @ 2023-09-04 1659/week @ 2023-09-11 1797/week @ 2023-09-18 2067/week @ 2023-09-25 2159/week @ 2023-10-02 2559/week @ 2023-10-09 2229/week @ 2023-10-16 2446/week @ 2023-10-23 2433/week @ 2023-10-30 2417/week @ 2023-11-06 2568/week @ 2023-11-13 2233/week @ 2023-11-20 2534/week @ 2023-11-27

10,078 downloads per month
Used in 14 crates (13 directly)

MIT license

4MB
114K SLoC

C 113K SLoC JavaScript 1K SLoC // 0.0% comments Scheme 71 SLoC Rust 33 SLoC // 0.1% comments

tree-sitter-c

This crate provides a C grammar for the tree-sitter parsing library. To use this crate, add it to the [dependencies] section of your Cargo.toml file. (Note that you will probably also need to depend on the tree-sitter crate to use the parsed result in any useful way.)

[dependencies]
tree-sitter = "0.20.10"
tree-sitter-c = "0.20.6"

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

let code = r#"
    int double(int x) {
        return x * 2;
    }
"#;
let mut parser = Parser::new();
parser.set_language(tree_sitter_c::language()).expect("Error loading C grammar");
let parsed = parser.parse(code, None);

If you have any questions, please reach out to us in the tree-sitter discussions page.

Dependencies

~2.6–3.5MB
~68K SLoC