Releases: Muppetsg2/cpp-tree-sitter
v0.26.9
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-sitterdependency via CPM to the latest0.26.9release. - 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-apitailored to your specific platform and architecture. - Version Control: Introduced the
CPP_TS_WASMTIME_VERSIONCMake 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-compiledwasmtime-c-apilibrary for Windows is built using MSVC. Therefore, it is not compatible withclang++org++(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 theCPP_TS_WASMTIME_PATHCMake option.
4. API Polish & Iterators
Refinements to the syntax tree traversal mechanics.
- Bidirectional Traversal: Added the decrement operator (
--) toChildIterator. - Operator Fixes: Resolved bugs with
ChildIteratorcomparison operators.
5. Legacy Compatibility & Tests
Ensuring the library remains robust across all supported C++ standards and architectures.
- C++11/C++14 Fixes: Resolved
maybe_unusedwarnings and fixedChildIteratorSentinelcompatibility issues in older standard environments. - Architecture-Aware Tests: Limited
length_erroroverflow tests strictly to platforms wheresize_texceedsuint32_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
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
createfunctions forParser,WasmStore, andQueryexclusively for C++23. - Expected Integration: Introduced
loadLanguageExpectedutilizing the new C++23 error-handling paradigms. - Performance & Safety: Added
noexcepttags 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
Nodeon failure instead of throwing exceptions. - Enhanced Node API: Added a default constructor for the
Nodestruct, along with new methods to easily retrieve named and unnamed children by their type or symbol. - Language Introspection: Added
getAllFieldsNamesto thets::Languageclass. - Iterator Improvements: Fixed bugs in
ChildIteratorand added asize()function tots::Children. - Better Defaults: Added default constructors for
TreeCursorandQueryCapture.
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
Languageclass, and resolved bugs related to copying aTree. - Compiler Compliance: Added missing
static_casts and resolved various compilation errors specific to strictclang++andg++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
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++20conceptswhere available. - Fallbacks: Includes a custom
StringViewand 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_ptrforLanguageobjects, 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
WasmStoreandWasmEngine. - 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
forloops throughts::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.cfor 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