12 unstable releases (5 breaking)

new 0.6.1 Mar 3, 2025
0.5.0 Jun 5, 2024
0.4.3 Mar 19, 2024
0.4.1 Nov 8, 2023
0.0.3 Jul 8, 2022

#480 in Parser implementations

Download history 622/week @ 2024-11-15 627/week @ 2024-11-22 709/week @ 2024-11-29 741/week @ 2024-12-06 825/week @ 2024-12-13 699/week @ 2024-12-20 705/week @ 2024-12-27 1244/week @ 2025-01-03 2422/week @ 2025-01-10 2258/week @ 2025-01-17 2484/week @ 2025-01-24 3165/week @ 2025-01-31 3323/week @ 2025-02-07 1985/week @ 2025-02-14 3123/week @ 2025-02-21 2132/week @ 2025-02-28

11,064 downloads per month
Used in 5 crates (3 directly)

MIT license

525KB
19K SLoC

C 19K SLoC JavaScript 83 SLoC Rust 32 SLoC // 0.1% comments

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

lib.rs:

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());

Dependencies

~4–310KB