13 unstable releases (6 breaking)

0.7.1 May 25, 2025
0.6.1 Mar 3, 2025
0.5.0 Jun 5, 2024
0.4.3 Mar 19, 2024
0.0.3 Jul 8, 2022

#365 in Parser implementations

Download history 1952/week @ 2025-09-15 1884/week @ 2025-09-22 2769/week @ 2025-09-29 2409/week @ 2025-10-06 1963/week @ 2025-10-13 2715/week @ 2025-10-20 2670/week @ 2025-10-27 2336/week @ 2025-11-03 3135/week @ 2025-11-10 2843/week @ 2025-11-17 3053/week @ 2025-11-24 2938/week @ 2025-12-01 2951/week @ 2025-12-08 2551/week @ 2025-12-15 2018/week @ 2025-12-22 2136/week @ 2025-12-29

9,985 downloads per month
Used in 10 crates (8 directly)

MIT license

565KB
21K SLoC

C 20K SLoC Scheme 226 SLoC JavaScript 93 SLoC Rust 32 SLoC // 0.1% comments

This crate provides Cmake 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_cmake::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading Cmake parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

============================== A Tree-sitter parser for CMake

This project provides a cmake parser. Its primary use case is to provide a cmake parser for nvim-treesitter.

Parsed syntax

  • Command

    • General commands
    • For and while loops
    • If conditions
    • Functions and macros
  • Arguments

    • Quoted arguments
    • Bracket arguments
    • Unquoted arguments
    • Parentheses
  • Variable references

    • Environment and cache variables
    • Normal variables

Dependencies

~16–250KB