Module ast

Module ast 

Source
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 str spans
  • 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
ScriptInfo
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§

EventType
Event type discriminant for different kinds of timeline events
Section
Top-level section in an ASS script
SectionType
Section type discriminant for efficient lookup and filtering