#cmake #incremental #parser

tree-sitter-cmake

cmake grammar for the tree-sitter parsing library

10 releases

0.5.0 Jun 5, 2024
0.4.3 Mar 19, 2024
0.4.2 Feb 22, 2024
0.4.1 Nov 8, 2023
0.0.3 Jul 8, 2022

#105 in Text editors

Download history 1304/week @ 2024-04-04 961/week @ 2024-04-11 781/week @ 2024-04-18 814/week @ 2024-04-25 627/week @ 2024-05-02 641/week @ 2024-05-09 856/week @ 2024-05-16 784/week @ 2024-05-23 1235/week @ 2024-05-30 1657/week @ 2024-06-06 1273/week @ 2024-06-13 1242/week @ 2024-06-20 830/week @ 2024-06-27 777/week @ 2024-07-04 771/week @ 2024-07-11 594/week @ 2024-07-18

3,108 downloads per month
Used in neocmakelsp

MIT license

525KB
19K SLoC

C 19K SLoC JavaScript 83 SLoC Rust 36 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 function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = "";
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_cmake::language()).expect("Error loading cmake grammar");
let tree = parser.parse(code, None).unwrap();

Dependencies

~2.7–4MB
~71K SLoC