This is a tree-sitter grammar for CMake.
Note: This repository is a fork of uyha/tree-sitter-cmake. If you encounter any issues or have questions, please submit them to the issue tracker.
Installation
You can install the Python binding via pip:
pip install tree-sitter-cmake
Usage
Here’s a simple example of how to use this grammar to parse CMake code in Python:
import tree_sitter_cmake
import tree_sitter
# Load the CMake language
cmake_language = tree_sitter.Language(tree_sitter_cmake.language())
# Initialize the parser
parser = tree_sitter.Parser(cmake_language)
# Parse some CMake code
source_code = b"""
cmake_minimum_required(VERSION 3.10)
project(Test)
set(CMAKE_CXX_STANDARD 17)
add_executable(main main.cpp)
"""
tree = parser.parse(source_code)
root_node = tree.root_node
# Print the syntax tree as an S-expression
print(str(root_node))
Parsed Syntax
This grammar supports most CMake constructs, including:
Commands: General commands, flow control (if, while, foreach), functions, and macros.
Arguments: Quoted, bracket, and unquoted arguments.
Variables: Normal, cache, and environment variable references.
Comments: Line and bracket comments.
Requirements
Python >= 3.10
tree-sitter ~= 0.24
License
MIT
Metadata
Release files for tree-sitter-cmake 0.7.2.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tree_sitter_cmake-0.7.2.post1.tar.gz | 47.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tree_sitter_cmake-0.7.2.post1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
Total release size: 75.2 kB
Release files / tree_sitter_cmake-0.7.2.post1.tar.gz
| Download URL | tree_sitter_cmake-0.7.2.post1.tar.gz |
|---|---|
| Size | 47.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64a3751ca67f37112821d67057b8de6ecab5c7e94d6053467a4b78ceab348640
|
|
BLAKE2b-256 checksum How to use checksums |
d0f4928d5378ef701577ef1b19658fc626a8c70b32447148898771a17c3c66a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.13.7 Windows/11
|
Release files / tree_sitter_cmake-0.7.2.post1-cp310-abi3-win_amd64.whl
| Download URL | tree_sitter_cmake-0.7.2.post1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 28.0 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c1b7a754e17442087df3efccea6535a9f2a8c4b4bf558e31fd3caccd8d1ce830
|
|
BLAKE2b-256 checksum How to use checksums |
f80b820ab5f8581f3b39e4bb6837e9f8573d70cfa71e8530a7a97355898b8751
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.13.7 Windows/11
|
Security for tree-sitter-cmake 0.7.2.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.