Skip to main content

parse

Function parse 

Source
pub fn parse(input: &str) -> Result<Song, ParseError>
Expand description

Parses a ChordPro source string into a Song AST.

This is a convenience function that runs the lexer and parser in sequence. Metadata directives populate Song::metadata automatically.

§Errors

Returns a ParseError if the input contains structural problems.

§Examples

use chordsketch_core::parser::parse;

let song = parse("{title: Hello World}\n[Am]La la la").unwrap();
assert_eq!(song.metadata.title.as_deref(), Some("Hello World"));
assert_eq!(song.lines.len(), 2);