#incremental #parsing #cmake

tree-sitter-cmake

cmake grammar for the tree-sitter parsing library

5 unstable releases

0.2.0 Feb 28, 2023
0.1.0 Aug 26, 2022
0.0.3 Jul 8, 2022
0.0.2 Jul 6, 2022
0.0.1 Jul 5, 2022

#64 in Text editors

Download history 646/week @ 2023-02-05 673/week @ 2023-02-12 533/week @ 2023-02-19 692/week @ 2023-02-26 687/week @ 2023-03-05 589/week @ 2023-03-12 646/week @ 2023-03-19 609/week @ 2023-03-26 460/week @ 2023-04-02 497/week @ 2023-04-09 517/week @ 2023-04-16 425/week @ 2023-04-23 474/week @ 2023-04-30 496/week @ 2023-05-07 406/week @ 2023-05-14 507/week @ 2023-05-21

1,947 downloads per month
Used in neocmakelsp

MIT license

715KB
27K SLoC

C 26K SLoC JavaScript 101 SLoC C++ 81 SLoC Rust 41 SLoC // 0.3% 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 refences

    • Environment and cache variables
    • Normal variables
  • Generator expression


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

~1.4–2MB
~53K SLoC