Skip to main content

Module alloc

Module alloc 

Source
Expand description

Arena-backed AST construction.

BorrowedAllocator<'a> is the sole AST builder for the crate::borrowed AST. It owns an Interner so byte-equal strings (ruby readings, container labels, kaeriten marks) share a single arena allocation.

§Naming convention

  • make_* methods build payload references (&'a Gaiji<'a>, &'a Annotation<'a>) without wrapping them in a node.
  • Variant-named methods (ruby, bouten, gaiji, …) build the final borrowed::AozoraNode<'a>. The gaiji and annotation node constructors take the payload reference (built via make_gaiji / make_annotation) so a payload can be shared between a Segment and a Node without recomputing the string interns.
  • seg_* methods build segment elements for content_segments.

§Canonicalisation

Both content_plain("") and content_segments(&[]) return borrowed::Content::EMPTY (i.e. Segments(&[])). content_segments collapses an all-Text input into a single concatenated Plain (the concatenation is interned). The legacy owned Content::from / Content::from_segments helpers used the same canonicalisation; preserving it keeps the determinism + sentinel-alignment proptests in aozora-lex/tests/property_borrowed_arena.rs honest across edits.

Structs§

BorrowedAllocator
Arena-backed builder for borrowed::AozoraNode<'a> and its payload types.