oak_core/tree/mod.rs
1//! Red-green tree implementation for efficient kind tree representation.
2//!
3//! This module provides the core red-green tree data structures that enable
4//! efficient incremental parsing and kind tree manipulation. The red-green
5//! tree architecture separates immutable structure (green) from position-aware
6//! representation (red), enabling optimal sharing and incremental updates.
7//!
8//! # Key Components
9//!
10//! - **Green Trees**: Immutable, position-agnostic kind tree nodes that can be
11//!   cached and shared across different parse trees
12//! - **Red Trees**: Position-aware kind tree nodes computed from green trees
13//!   with absolute offsets for error reporting and diagnostics
14//! - **Green Builder**: Utility for constructing green trees incrementally
15//!
16//! # Architecture
17//!
18//! The red-green tree design enables:
19//! - **Incremental Parsing**: Only re-parse changed regions of source code
20//! - **Memory Efficiency**: Share immutable green nodes across parse trees
21//! - **Position Tracking**: Provide accurate source locations for diagnostics
22//! - **Performance**: Minimize allocations through reference counting and caching
23
24mod green_tree;
25pub(crate) mod incremental;
26mod red_tree;
27
28pub use self::{
29    green_tree::{GreenLeaf, GreenNode, GreenTree},
30    incremental::{GreenBuilder, IncrementalCache},
31    red_tree::{RedChildren, RedLeaf, RedNode, RedTree},
32};
33pub use triomphe::Arc;