1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Dweve HEDL - Hierarchical Entity Data Language
//
// Copyright (c) 2025 Dweve IP B.V. and individual contributors.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the LICENSE file at the
// root of this repository or at: http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Comprehensive visitor pattern API for HEDL document traversal.
//!
//! This module provides a flexible, performance-oriented visitor API that supports:
//! - Multiple visitor styles (immutable, mutable, consuming, fallible)
//! - Fine-grained control flow (continue, skip children, early termination)
//! - Pre-order and post-order traversal strategies
//! - Specialized utility visitors for common patterns
//! - Visitor composition and chaining
//!
//! # Architecture
//!
//! The visitor pattern separates traversal logic from processing logic,
//! enabling reusable document analysis and transformation components.
//!
//! ## Visitor Traits
//!
//! - [`Visitor`]: Immutable visiting for read-only analysis
//! - [`VisitorMut`]: Mutable visiting for in-place modification
//! - [`Transformer`]: Consuming visitor that rebuilds trees
//! - [`FallibleVisitor`]: Result-based visiting with error propagation
//!
//! ## Control Flow
//!
//! All visitor methods return [`VisitDecision`] to control traversal:
//! - `Continue`: Visit this node and its children
//! - `SkipChildren`: Visit this node but skip children
//! - `Stop`: Terminate traversal immediately
//!
//! # Example: Simple Node Counter
//!
//! ```
//! use hedl_core::visitor::{Visitor, VisitDecision, VisitorContext};
//! use hedl_core::Node;
//!
//! struct NodeCounter {
//! count: usize,
//! }
//!
//! impl Visitor for NodeCounter {
//! fn visit_node(&mut self, _node: &Node, _ctx: &VisitorContext) -> VisitDecision {
//! self.count += 1;
//! VisitDecision::Continue
//! }
//! }
//! ```
//!
//! # Example: Early Termination Search
//!
//! ```
//! use hedl_core::visitor::{Visitor, VisitDecision, VisitorContext};
//! use hedl_core::Node;
//!
//! struct FindNode {
//! target_id: String,
//! found: bool,
//! }
//!
//! impl Visitor for FindNode {
//! fn visit_node(&mut self, node: &Node, _ctx: &VisitorContext) -> VisitDecision {
//! if node.id == self.target_id {
//! self.found = true;
//! VisitDecision::Stop // Early termination
//! } else {
//! VisitDecision::Continue
//! }
//! }
//! }
//! ```
/// Specialized utility visitors for common patterns.
pub use ;
pub use ;
pub use ;
pub use VisitDecision;
pub use FallibleVisitor;
pub use Visitor;
pub use Transformer;
pub use ;
pub use VisitorMut;