Sketch: Bytestring diagnostics preservation #143
Draft
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.
This is a quick hack to show what, based on #142, preservation of diagnostic notation style of strings could look like.
This preserves just the encoding style, i.e. whether it's hex or base64 encoded (with some roughness around ASCII encoding not being preserved right). It does not preserve how the diagnostic notation strings is composed of multiple chunks (all of which could have their own encoding), or comments inside the (eg. hex) string. The latter would be tempting to add, the former I don't see an urgent need for.
It already shows how I think it would make sense to run those diagnostic-representation things: The encoder would have a preference, and if the item doesn't state how it is to be expressed, that encoder style triggers. But if the item has a style choice, that is followed. Methods could be provided to clear the encoding style, or to apply one (maybe in a callback from a walker).
This is a sketch for two reasons:
This PR primarily serves to illustrate the road that can be taken after #142, and as a storage point for how the information can be passed around in the parser (took me a bit because I haven't used nom or similar before).