treesitter_types/runtime/mod.rs
1pub mod error;
2pub mod from_node;
3pub mod span;
4
5pub use error::ParseError;
6pub use from_node::{FromNode, LeafNode, Spanned};
7pub use span::Span;
8
9/// Grow the stack on demand to prevent overflow in deeply nested ASTs.
10///
11/// This is called by generated `FromNode` implementations at every recursive
12/// call site. When the remaining stack space drops below the red-zone (32 KiB),
13/// a new 1 MiB stack segment is allocated transparently. The overhead on the
14/// happy path (enough stack left) is a single pointer comparison.
15#[inline(always)]
16pub fn maybe_grow_stack<R>(f: impl FnOnce() -> R) -> R {
17 stacker::maybe_grow(32 * 1024, 1024 * 1024, f)
18}