Skip to content

Releases: Muppetsg2/cpp-tree-sitter

v0.26.9

25 May 21:53
25b75a3

Choose a tag to compare

v0.26.9: Tree-sitter v0.26.9, Build Standardization & Wasmtime Automation

This release brings our underlying Tree-sitter core up to date, while heavily standardizing the CMake build environment, automating WebAssembly dependencies, and polishing the core API for legacy C++ standards.

🚀 Key Highlights

1. Core Tree-sitter Update

The underlying C library has been updated to match this release version.

  • Tree-sitter v0.26.9: Bumped the internal tree-sitter dependency via CPM to the latest 0.26.9 release.
  • You can read the official release notes and changes for the core library here: Tree-sitter v0.26.9 Release Notes.

2. Build System Standardization

The CMake integration has been thoroughly cleaned up and standardized to prevent namespace collisions in larger projects.

  • Namespace Prefixes: All CMake helper functions and compile-time defines have been unified under the cpp_ts_ / CPP_TS_ prefix.
  • CPM Update: Bumped the internal CPM dependency to version 0.42.3.
  • Presets & Flags: Added additional CMake presets and enabled stricter compiler error flags for better code quality.
  • Fixes: Corrected interface compile/link flags and fixed CMake function names in output messages.

3. Automated Wasmtime Integration

Managing WebAssembly dependencies is now completely frictionless.

  • Smart Downloads: Added automatic downloading of the wasmtime-c-api tailored to your specific platform and architecture.
  • Version Control: Introduced the CPP_TS_WASMTIME_VERSION CMake option, allowing developers to pin specific Wasmtime versions.
  • Backward Compatibility: Fixed testing issues when using Wasmtime versions older than 39.0.0.

⚠️ Windows Compiler Compatibility Note: Please note that the pre-compiled wasmtime-c-api library for Windows is built using MSVC. Therefore, it is not compatible with clang++ or g++ (MinGW) toolchains on Windows environments. In these cases, it is recommended to build the Wasmtime library manually from source and provide the path to your custom build using the CPP_TS_WASMTIME_PATH CMake option.

4. API Polish & Iterators

Refinements to the syntax tree traversal mechanics.

  • Bidirectional Traversal: Added the decrement operator (--) to ChildIterator.
  • Operator Fixes: Resolved bugs with ChildIterator comparison operators.

5. Legacy Compatibility & Tests

Ensuring the library remains robust across all supported C++ standards and architectures.

  • C++11/C++14 Fixes: Resolved maybe_unused warnings and fixed ChildIteratorSentinel compatibility issues in older standard environments.
  • Architecture-Aware Tests: Limited length_error overflow tests strictly to platforms where size_t exceeds uint32_t.
  • Documentation: General updates and improvements to the README.

👨‍💻 Installation

Update your CPM integration in CMakeLists.txt to point to the new version:

CPMAddPackage(
    NAME cpp-tree-sitter
    GIT_REPOSITORY https://github.com/Muppetsg2/cpp-tree-sitter.git
    VERSION 0.26.9
)

Full documentation for new CMake options and functions is available in the README.

Full Changelog: v0.26.8...v0.26.9

v0.26.8-r1

07 May 15:33

Choose a tag to compare

v0.26.8-r1: C++23 Support & API Refinements

This release is a robust follow-up to the major modernization update. It introduces C++23 support, significantly refines the core API for better exception safety and usability, and resolves several cross-compiler build issues.

🚀 Key Highlights

1. C++23 Support & Modernization

We are continuing to push forward with modern C++ standards.

  • C++23 Ready: Full support and optimizations for C++23 environments.
  • Factory Methods: Added static create functions for Parser, WasmStore, and Query exclusively for C++23.
  • Expected Integration: Introduced loadLanguageExpected utilizing the new C++23 error-handling paradigms.
  • Performance & Safety: Added noexcept tags to all non-throwing functions for better compiler optimization.

2. Safer & Richer Core API

Interacting with the syntax tree is now safer and more intuitive.

  • No More Exceptions for Children: Functions acquiring node children have been refactored. They now safely return a null Node on failure instead of throwing exceptions.
  • Enhanced Node API: Added a default constructor for the Node struct, along with new methods to easily retrieve named and unnamed children by their type or symbol.
  • Language Introspection: Added getAllFieldsNames to the ts::Language class.
  • Iterator Improvements: Fixed bugs in ChildIterator and added a size() function to ts::Children.
  • Better Defaults: Added default constructors for TreeCursor and QueryCapture.

3. Stability & Under-the-Hood Fixes

Significant improvements to memory semantics and cross-platform compilation.

  • Object Semantics: Fixed copy and move constructors/assignments for the Language class, and resolved bugs related to copying a Tree.
  • Compiler Compliance: Added missing static_casts and resolved various compilation errors specific to strict clang++ and g++ environments.
  • Test Suite: General improvements and fixes to the unit testing suite to ensure long-term stability.

4. CMake Enhancements

  • MSVC Static Runtime: Added support for static linking of MSVC runtime libraries on Windows.
  • Better Visibility: CMake now automatically prints the currently set configuration options during the generation phase for easier debugging.

👨‍💻 Installation

Update your CPM integration in CMakeLists.txt to point to the new revision:

CPMAddPackage(
    NAME cpp-tree-sitter
    GIT_REPOSITORY https://github.com/Muppetsg2/cpp-tree-sitter.git
    VERSION 0.26.8-r1
)

Full documentation for new CMake options and functions is available in the README.

Full Changelog: v0.26.8...v0.26.8-r1

v0.26.8

14 Apr 10:10
12116bb

Choose a tag to compare

v0.26.8: The Modernization & Wasm Update

This release represents a significant evolution of cpp-tree-sitter. The library has been rewritten and expanded to support modern C++ workflows, WebAssembly, and a complete RAII-compliant architecture while maintaining compatibility with legacy standards.

🚀 Key Highlights

1. Broad C++ Standard Support

The library is no longer restricted to C++17.

  • Compatibility: Full support for C++11, C++14, C++17, and C++20.
  • Smart Detection: Automatically leverages std::string_view, std::optional, and C++20 concepts where available.
  • Fallbacks: Includes a custom StringView and compatibility layers for older environments.

2. Full RAII & Memory Safety

Internal memory management has been completely overhauled.

  • Smart Pointers: All core Tree-sitter objects (Parser, Tree, Node, Query) now use RAII to prevent leaks.
  • Safe Languages: Introduced shared_ptr for Language objects, preventing use-after-free errors when multiple parsers share the same grammar.
  • FreeHelpers: Specialized functors ensure C-allocated strings (like S-Expressions) are always properly freed.

3. WebAssembly (Wasm) Integration

Added high-level C++ wrappers for the Tree-sitter Wasm API.

  • Support for WasmStore and WasmEngine.
  • Integration with Wasmtime for running grammars in Wasm environments.
  • Automatic binary downloading and management via CMake.

4. Advanced Tree Traversal

New ways to interact with the syntax tree:

  • Tree Visitor: Added ts::visit, a powerful Depth-First Search (DFS) utility.
  • STL Iterators: Support for standard for loops through ts::Children{node}.

5. Query Engine Support

Full implementation of the Tree-sitter Query API, allowing for sophisticated pattern matching and capture extraction directly in C++.


🛠 CMake Improvements

The build system has been modernized to act as a first-class citizen in modern CMake projects:

  • CPPTSAddGrammar: A new, versatile function to fetch, build, and link grammars (via Git or local paths) with a single command.
  • Wasm Automation: Options to automatically download and link Wasmtime binaries.
  • Cross-Platform: Fixed Windows-specific issues with Dot graph generation and DLL deployment (CPPTSCopyWasmtime).
  • Amalgamated Builds: Option to use lib.c for faster compilation times.

📋 Summary of Changes

Feature Before After (This Update)
C++ Standards C++17 Only C++11, 14, 17, 20
RAII Scope Partial Complete (Full Safety)
Wasm Support None Full Support
Queries None Full API
Traversal Manual Iterators & Visitor
Tests None Unit Test Suite Included

👨‍💻 Installation

Add this to your CMakeLists.txt using CPM:

CPMAddPackage(
    NAME cpp-tree-sitter
    GIT_REPOSITORY https://github.com/Muppetsg2/cpp-tree-sitter.git
    VERSION 0.26.8
)

Full documentation for new CMake options and functions is available in the README.

Full Changelog: https://github.com/Muppetsg2/cpp-tree-sitter/commits/v0.26.8