Skip to main content

graphcal_compiler/syntax/
mod.rs

1//! Graphcal Syntax: lexer, parser, and AST definitions.
2
3pub mod ast;
4pub mod attribute;
5pub mod comments;
6pub mod desugar;
7pub mod dimension;
8pub mod lexer;
9pub mod module_resolve;
10pub mod names;
11pub mod nat;
12pub mod non_empty;
13pub mod parser;
14pub mod phase;
15pub mod span;
16pub mod token;
17pub mod visitor;
18
19use std::sync::Arc;
20
21/// Build a [`miette::NamedSource`] from `(name, source)`.
22///
23/// The source is shared through `Arc` so diagnostics built from the same file
24/// do not re-copy it. Prefer this helper over `NamedSource::new(name, Arc::new(source))`
25/// at call sites — it centralizes the wrapping convention.
26#[must_use]
27pub fn named_source<N: Into<String>, S: Into<Arc<String>>>(
28    name: N,
29    source: S,
30) -> miette::NamedSource<Arc<String>> {
31    miette::NamedSource::new(name.into(), source.into())
32}