#tree-sitter #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

#143 in Text editors

Download history 727/week @ 2024-08-07 774/week @ 2024-08-14 571/week @ 2024-08-21 792/week @ 2024-08-28 634/week @ 2024-09-04 1460/week @ 2024-09-11 601/week @ 2024-09-18 771/week @ 2024-09-25 876/week @ 2024-10-02 901/week @ 2024-10-09 633/week @ 2024-10-16 683/week @ 2024-10-23 714/week @ 2024-10-30 612/week @ 2024-11-06 624/week @ 2024-11-13 483/week @ 2024-11-20

2,576 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.8–4MB
~78K SLoC