Expand description
AST (Abstract Syntax Tree) definitions for ASS scripts
Provides zero-copy AST nodes using lifetime-generic design for maximum performance. All nodes reference spans in the original source text to avoid allocations.
§Thread Safety
All AST nodes are immutable after construction and implement Send + Sync
for safe multi-threaded access.
§Performance
- Zero allocations via
&'a strspans - Memory usage ~1.1x input size
- Validation via pointer arithmetic for span checking
§Examples
use ass_core::parser::ast::{Section, ScriptInfo, Event, EventType, Span};
// Create script info
let info = ScriptInfo { fields: vec![("Title", "Test")], span: Span::new(0, 0, 0, 0) };
let section = Section::ScriptInfo(info);
// Create dialogue event
let event = Event {
event_type: EventType::Dialogue,
start: "0:00:05.00",
end: "0:00:10.00",
text: "Hello World!",
..Event::default()
};Structs§
- Event
- Event from
[Events\]section (dialogue, comments, etc.) - Font
- Embedded font from
[Fonts\]section - Graphic
- Embedded graphic from
[Graphics\]section - Script
Info - Script Info section containing metadata and headers
- Span
- Represents a span in the source text with position information
- Style
- Style definition from [V4+ Styles] section
Enums§
- Event
Type - Event type discriminant for different kinds of timeline events
- Section
- Top-level section in an ASS script
- Section
Type - Section type discriminant for efficient lookup and filtering