Skip to main content

CMake grammar for tree-sitter

Project description

PyPI License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_cmake-0.7.2.post1.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_cmake-0.7.2.post1-cp310-abi3-win_amd64.whl (28.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

File details

Details for the file tree_sitter_cmake-0.7.2.post1.tar.gz.

File metadata

  • Download URL: tree_sitter_cmake-0.7.2.post1.tar.gz
  • Upload date:
  • Size: 47.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Windows/11

File hashes

Hashes for tree_sitter_cmake-0.7.2.post1.tar.gz
Algorithm Hash digest
SHA256 64a3751ca67f37112821d67057b8de6ecab5c7e94d6053467a4b78ceab348640
MD5 fd4c9b30140918bc536e6af7fb6286a5
BLAKE2b-256 d0f4928d5378ef701577ef1b19658fc626a8c70b32447148898771a17c3c66a1

See more details on using hashes here.

File details

Details for the file tree_sitter_cmake-0.7.2.post1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_cmake-0.7.2.post1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c1b7a754e17442087df3efccea6535a9f2a8c4b4bf558e31fd3caccd8d1ce830
MD5 03a72f7f552fa32bdcf95ef089a7ee34
BLAKE2b-256 f80b820ab5f8581f3b39e4bb6837e9f8573d70cfa71e8530a7a97355898b8751

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page