orrery-parser 0.3.0

Parser for the Orrery diagram language
Documentation

Orrery Parser

Parser for the Orrery diagram language. This crate provides the complete parsing pipeline from source text to semantic diagram representation.

Overview

The parser processes Orrery source code through a multi-stage pipeline:

  1. Resolve — Recursively load the root file and all its imports via a SourceProvider, building a virtual address space and populating the import tree. For each file:
    • Tokenize — Convert source text to tokens
    • Parse — Build an AST from tokens
  2. Desugar — Normalize syntax sugar and flatten imported types
  3. Validate — Check semantic validity
  4. Elaborate — Transform to the semantic model (orrery_core::semantic::Diagram)

Quick Example

use std::path::Path;
use orrery_parser::{parse, ElaborateConfig, InMemorySourceProvider, error::ParseError};

fn main() -> Result<(), ParseError> {
    let source = r#"
        diagram component;
        user: Rectangle;
        server: Rectangle;
        user -> server: "Request";
    "#;

    let mut provider = InMemorySourceProvider::new();
    provider.add_file("main.orr", source);

    let diagram = parse(Path::new("main.orr"), provider, ElaborateConfig::default())?;
    println!("Diagram kind: {:?}", diagram.kind());
    Ok(())
}

Documentation

License

Licensed under either of Apache License 2.0 or MIT license at your option.