Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(len): add APIs to calculate component lengths #36

Merged
merged 1 commit into from
Apr 23, 2022
Merged

Conversation

zkat
Copy link
Member

@zkat zkat commented Apr 23, 2022

Fixes: #19

This adds some convenience methods that will make #19 possible, although it still needs some manual funging, unfortunately. There's no good way to maintain consistent spans across a document, partly due to limitations of how nom works, partly because, in practice, they would quickly go out of sync as soon as the KdlDocument or any of its components get edited.

So my suggestion is to use these new len() APIs to do manual offset calculations in your documents to come up with sensible spans and error messages for the particular failure cases of your KDL-based DSLs. You should then be able to throw the spans you come up with at miette to get some nice error message rendering, to boot! :)

Anyway, I hope this helps. It's unfortunate I couldn't come up with something that does more heavy lifting, and I'm always open to accepting patches to allow that, if anyone else ends up having any brilliant ideas on how to get that working right.

@zkat zkat merged commit 177c42c into main Apr 23, 2022
@zkat zkat deleted the zkat/lengths branch April 23, 2022 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store optional line number on KdlNode
1 participant