pub fn parse<'a, P: SourceProvider>(
arena: &'a Bump,
root_path: &Path,
provider: P,
config: ElaborateConfig,
) -> Result<Diagram, ParseError<'a>>Expand description
Parse an Orrery file into a semantic diagram.
This is the main entry point for parsing Orrery diagram source code. It orchestrates the complete parsing pipeline:
- Resolve — Recursively load the root file and all its imports via
the
SourceProvider, building a virtual address space in theSourceMapand populating the import tree. For each file:- Tokenize — Convert source text to tokens
- Parse — Build an AST from tokens
- Desugar — Normalize syntax sugar and flatten imported types
- Validate — Check semantic validity
- Elaborate — Transform to semantic model
§Arguments
arena— ABumparena that owns all source text. The arena must outlive the returned error (if any), sinceParseErrorborrows source data from it.root_path— Path to the root/entry Orrery file.provider— ASourceProviderimplementation that resolves import paths and reads source text.config— Configuration for the elaboration phase.
§Returns
Returns the parsed orrery_core::semantic::Diagram on success,
or a ParseError with location information on failure.
§Example
let arena = Bump::new();
let mut provider = InMemorySourceProvider::new();
provider.add_file("main.orr", "diagram component; box: Rectangle;");
let diagram = parse(&arena, Path::new("main.orr"), provider, ElaborateConfig::default())
.map_err(|e| e.to_string())?;