gd_lilypond =========== .. rust:crate:: gd_lilypond :synopsis: Reads notation into a music model. Reads notation into a music model. Never runs Scheme, external programs or file I/O. Includes are lexical and require an explicit caller-supplied policy callback. .. rubric:: Re-exports .. rust:use:: pub use gd_score::Error .. rust:use:: pub use gd_score::ErrorKind .. rust:use:: pub use gd_score::FileId .. rust:use:: pub use gd_score::Severity .. rust:use:: pub use gd_score::Span .. rubric:: Structs .. rust:struct:: pub struct Command One command in the versioned Guidedog notation profile. .. rubric:: Fields .. rust:field:: pub name: &'static str Name without its backslash. .. rust:field:: pub phase: u8 GDS phase that introduces the construct, or zero for refused commands. .. rust:field:: pub status: CommandStatus Explicit current support status. .. rust:struct:: pub struct Failed A failed parse or interpretation that keeps enough source to place its diagnostic. .. rubric:: Fields .. rust:field:: pub error: Error The first fatal problem. .. rust:field:: pub files: SourceFiles Every file read before the failure. .. rubric:: Trait Implementations .. rust:impl:: impl std::fmt::Display for Failed :noindex: :for: Failed :trait: std::fmt::Display .. rust:method:: fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result :noindex: .. rust:impl:: impl std::error::Error for Failed :noindex: :for: Failed :trait: std::error::Error .. rust:struct:: pub struct SourceFile Retained input text. The name is resolved by the adapter, not by this library. .. rubric:: Fields .. rust:field:: pub name: String Display and dependency identity. .. rust:field:: pub text: String Original UTF-8 text, before tokenization. .. rust:struct:: pub struct SourceFiles Sources indexed by FileId; file zero is the directive's supplied source. .. rubric:: Fields .. rust:field:: pub files: Vec Files in first-read order, including files that caused an error. .. rubric:: Implementations .. rust:impl:: impl SourceFiles :noindex: :for: SourceFiles .. rust:method:: pub fn file(&self, id: FileId) -> Option<&SourceFile> Borrows one file, returning None for an unknown identifier. .. rust:struct:: pub struct Limits Bounds for one load, including includes, variable expansion and repeats. .. rubric:: Fields .. rust:field:: pub source_bytes: usize Source bytes, charging repeated includes each time. .. rust:field:: pub depth: usize Recursive syntax and expansion depth. .. rust:field:: pub files: usize Included source files, excluding the main source. .. rust:field:: pub work: usize Token and syntax-node visits, including expansions. .. rust:field:: pub events: usize Rhythmic and notation events after expansion. .. rust:field:: pub memory_bytes: usize Conservative allocation allowance for expanded notation, including copied text. .. rubric:: Trait Implementations .. rust:impl:: impl Default for Limits :noindex: :for: Limits :trait: Default .. rust:method:: fn default() -> Self :noindex: .. rust:struct:: pub struct Expr A syntax node in a flat arena. Children own indices, never recursive boxes. .. rubric:: Fields .. rust:field:: pub kind: ExprKind Grouping or atomic notation. .. rust:field:: pub span: Span Original source range. .. rust:struct:: pub struct Syntax Parsed input and its original files. It contains no engraving decisions. .. rubric:: Fields .. rust:field:: pub nodes: Vec Nodes addressed by SyntaxId. .. rust:field:: pub roots: Vec Top-level expressions in lexical order. .. rust:field:: pub files: SourceFiles Original file text retained for reports. .. rubric:: Implementations .. rust:impl:: impl Syntax :noindex: :for: Syntax .. rust:method:: pub fn node(&self, id: SyntaxId) -> Option<&Expr> Borrows a node, returning None for an invalid identifier. .. rust:struct:: pub struct SyntaxId(pub u32) An index into the syntax arena. .. rust:struct:: pub struct Token A notation token with no inferred musical meaning. .. rubric:: Fields .. rust:field:: pub kind: TokenKind Lexical category and owned spelling. .. rust:field:: pub span: Span Exact byte location in a retained file. .. rust:struct:: pub struct IncludeRequest<'a> An include name and the file in which it appeared. .. rubric:: Fields .. rust:field:: pub from: FileId File whose directory is the first search location. .. rust:field:: pub name: &'a str Name written in the include command. .. rust:struct:: pub struct IncludedFile Source text returned by a confined caller-supplied include reader. .. rubric:: Fields .. rust:field:: pub name: String Resolved name retained in diagnostics and dependency tracking. .. rust:field:: pub text: String UTF-8 file contents. .. rust:struct:: pub struct IncludeRefusal A caller's refusal to read an included file. .. rubric:: Fields .. rust:field:: pub message: String Why the path could not be read. .. rust:field:: pub hint: String How to make the include valid. .. rust:struct:: pub struct Options<'a> Reader bounds and explicit file policy. The default refuses filesystem includes. .. rubric:: Fields .. rust:field:: pub limits: Limits Finite resource bounds. .. rust:field:: pub include: Option<&'a mut Include<'a>> Caller-owned include reader, borrowed only during parsing. .. rust:field:: pub reserve: Option<&'a dyn Fn(usize) -> bool> Reserves the complete conservative reader allowance before expansion. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Options<'_> :noindex: :for: Options<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct Loaded A successful load, including retained files and nonfatal diagnostics. .. rubric:: Fields .. rust:field:: pub score: gd_score::Score Reader-independent music model. .. rust:field:: pub files: SourceFiles All files read, indexed by FileId. .. rust:field:: pub warnings: Vec Failed bar checks, ignored metadata and unused lyrics. .. rubric:: Enums .. rust:enum:: pub enum CommandStatus The explicitly implemented, planned or refused status of a notation command. .. rubric:: Variants .. rust:variant:: Implemented Fully read and interpreted by the current implementation. .. rust:variant:: Planned Listed in the GDS, but not yet implemented; always diagnosed as unsupported. .. rust:variant:: Ignored Metadata accepted without producing marks. .. rust:variant:: Refused Engraver programming or constructs outside the profile. .. rust:enum:: pub enum ExprKind Structural grouping before pitch, duration or context interpretation. .. rubric:: Variants .. rust:variant:: Atom(TokenKind) An ungrouped token. .. rust:variant:: Sequence(Vec) A brace-delimited sequence. .. rust:variant:: Simultaneous(Vec) A double-angle-delimited simultaneous expression. .. rust:variant:: Chord(Vec) A single-angle-delimited chord. .. rust:enum:: pub enum TokenKind Lexical categories; numeric values are checked during interpretation. .. rubric:: Variants .. rust:variant:: Word(String) A note name, identifier or metadata word. .. rust:variant:: Number(String) Digits, without sign or punctuation. .. rust:variant:: Text(String) A decoded quoted string. .. rust:variant:: Command(String) A backslash command, without its initial backslash. .. rust:variant:: Symbol(char) A single punctuation character, including octave marks and Scheme introducers. .. rust:variant:: SimultaneousStart A pair of opening angle brackets. .. rust:variant:: SimultaneousEnd A pair of closing angle brackets. .. rubric:: Functions .. rust:function:: pub fn command(name: &str) -> Option<&'static Command> Borrows a command descriptor, or returns None for a spelling outside the table. .. rust:function:: pub fn error_report(error: &Error, files: &SourceFiles) -> gd_report::Report Borrows a shared diagnostic and retained source to create an owned report. Missing file identifiers produce an unplaced report rather than a panic. .. rust:function:: pub fn interpret_syntax(syntax: &Syntax, limits: &Limits) -> Result Interprets a borrowed syntax arena under explicit expansion and event bounds. Returns a separate score and retained source, or the first placed diagnostic. .. rust:function:: pub fn parse_lilypond(source: &str, name: &str, options: &mut Options<'_>) -> Result Parses borrowed notation into a bounded syntax arena without interpreting music. Includes use the explicit callback; failures retain every source read so far. .. rust:function:: pub fn load_score(source: &str, name: &str, options: &mut Options<'_>) -> Result Parses and interprets borrowed source under the supplied bounds and include policy. Returns an owned score or a diagnostic with all files read before the failure. .. rubric:: Type Aliases .. rust:type:: pub type Include<'a> = dyn FnMut(IncludeRequest<'_>) -> Result + 'a Decides a lexical include. Called synchronously; never stored after a load. .. rubric:: Constants .. rust:const:: pub const COMMANDS: &[Command] Known commands in a stable order, shared by diagnostics and profile tests.