Skip to main content

ass_core/parser/ast/
mod.rs

1//! AST (Abstract Syntax Tree) definitions for ASS scripts
2//!
3//! Provides zero-copy AST nodes using lifetime-generic design for maximum performance.
4//! All nodes reference spans in the original source text to avoid allocations.
5//!
6//! # Thread Safety
7//!
8//! All AST nodes are immutable after construction and implement `Send + Sync`
9//! for safe multi-threaded access.
10//!
11//! # Performance
12//!
13//! - Zero allocations via `&'a str` spans
14//! - Memory usage ~1.1x input size
15//! - Validation via pointer arithmetic for span checking
16//!
17//! # Examples
18//!
19//! ```rust
20//! use ass_core::parser::ast::{Section, ScriptInfo, Event, EventType, Span};
21//!
22//! // Create script info
23//! let info = ScriptInfo { fields: vec![("Title", "Test")], span: Span::new(0, 0, 0, 0) };
24//! let section = Section::ScriptInfo(info);
25//!
26//! // Create dialogue event
27//! let event = Event {
28//!     event_type: EventType::Dialogue,
29//!     start: "0:00:05.00",
30//!     end: "0:00:10.00",
31//!     text: "Hello World!",
32//!     ..Event::default()
33//! };
34//! ```
35
36#[cfg(not(feature = "std"))]
37extern crate alloc;
38
39mod event;
40mod media;
41mod script_info;
42mod section;
43mod span;
44mod style;
45
46#[cfg(test)]
47mod span_tests;
48
49// Re-export all public types to maintain API compatibility
50pub use event::{Event, EventType};
51pub use media::{Font, Graphic};
52pub use script_info::ScriptInfo;
53pub use section::{Section, SectionType};
54pub use span::Span;
55pub use style::Style;