Conversation
The generated core parsers repair values silently: an unknown enum literal falls back to the first variant, numbers are clamped into range, unreadable text becomes a default, and a missing lyric-language/@xml:lang becomes "und". Carry a ParseContext through every generated parser and report those repairs with their XML path. Value types gain a parse overload that says whether the text was invalid or adjusted, so valid alternate spellings are not reported. MusicXml::fromFile and fromStream take an optional Diagnostics that the same collector can then pass to getScore. Parsing produces the same document either way.
Contributor
gen-quality
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human Summary
TODO: human writes here
Summary
The generated
mx::coreparsers are strict about structure but lenient about values: an unknownenum literal falls back to the first variant, a number is clamped into its schema range, malformed
text becomes a default, and a missing
lyric-language/@xml:langis filled in withund. Until nowall of that happened silently.
MusicXml::fromFileandfromStreamgainDiagnostics &overloads, so the collector from #437 canbe handed to the parse and then on to
getScore, gathering both layers' reports in one place. Theexisting overloads are unchanged and stay silent.
Inside core, a new
ParseContextis carried through every generated parser. Core keeps its ownDiagnostictype with an XML path, andmx::apimaps it to the public one, so core still does notdepend on
mx::api. Value types gain aparse(text, outcome)overload that says whether the text wasunreadable or was adjusted. That is what lets
+01or1pass quietly while12for an octaveis reported as adjusted to
9. Two new public codes,invalidValueandmissingValueDefaulted,join the existing
valueAdjusted. All import reports are warnings.Serialization is untouched, and parsing produces the same document with or without a collector.
Not yet reported: the bespoke value types (color, yyyy-mm-dd, comma-separated text and font family,
time-only, ending number, the SMuFL glyph names) and the
Token/NameTokenidentity wrappers stillrepair silently. They can be added as report sites later using the same
parse(text, outcome)shape.Testing
fromFile,fromStream, a collection reused acrossfromStreamandgetScore, identical output without a collector, and a throwing handler becominginternalErrormake test-allmake wasm-testmake gen-test,make gen-quality,make gen-lintmake fmtReferences