Skip to main content

parse_lenient

Function parse_lenient 

Source
pub fn parse_lenient(input: &str) -> ParseResult
Expand description

Parses a ChordPro source string leniently, collecting all errors.

Unlike parse, this function does not fail on the first error. It returns a ParseResult containing the partial AST and all errors encountered. The size limit from ParseOptions::default is enforced.

ยงExamples

use chordsketch_core::parser::parse_lenient;

let result = parse_lenient("{title: Test}\n{bad\n[G]Hello");
assert!(result.has_errors());
assert_eq!(result.song.metadata.title.as_deref(), Some("Test"));
// The valid lyrics line was still parsed.
assert!(result.song.lines.len() >= 2);