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

Support integration with cstree #96

Open
zesterer opened this issue Mar 3, 2022 · 4 comments
Open

Support integration with cstree #96

zesterer opened this issue Mar 3, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed interop An issue that affects interoperability with other crates

Comments

@zesterer
Copy link
Owner

zesterer commented Mar 3, 2022

With the eventual merge of #82, it might be possible to have chumsky integrate with cstree, a library for lossless parsing using untyped syntax tree. This might be achieved by allowing implementers of the Input trait to specify functions that should be run when sequences of the input are consumed by the parser. For a dedicated Input implementation (that wraps another internally) we could specify these functions, allowing the emission of parse events.

@zesterer zesterer added enhancement New feature or request help wanted Extra attention is needed labels Mar 3, 2022
@zesterer
Copy link
Owner Author

This is probably possible with zero-copy, but it's not on the roadmap for release.

@zesterer zesterer added the interop An issue that affects interoperability with other crates label Feb 21, 2023
@robo9k
Copy link

robo9k commented May 2, 2023

What does zero-copy refer to (a Git branch?), the mentioned pull request has been merged already?
Are we talking about InputRef (not Input) here and if so, how would that work given it's not a trait?
What would chumsky's role be; parse input (possibly from a separate lexer) and output .. events to construct a cstree CST?

@CraftSpider
Copy link
Collaborator

zero-copy used to be a git branch, but has since been merged and is now the main branch of the repository, anything after 1.0.0-alpha.1 is zero-copy.

Most likely this would involve both Input and InputRef - InputRef would gain methods that the parsers call, that it delegates to implementors of the Input trait (or possible a new sub-trait of it, similar to SliceInput or ValueInput, if I understand the original idea correctly.

I can't answer this one as zesterer, but personally, that sounds about right, given my limited knowledge of cstree.

@zesterer
Copy link
Owner Author

zesterer commented May 3, 2023

Yep, that's about right: we'd expand the input traits to allow collecting 'parsing events'. For most imputs, this would just be a stub that does nothing, allowing the optimiser to swallow the overhead. For a cstree input, these parsing events could be consumed by cstree's node builder and used to track token inputs.

Unfortunately I don't have the time to put together a proof of concept for this at the moment, but it probably wouldn't be the most difficult thing in the world to do (for those that understand how cstree works well).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed interop An issue that affects interoperability with other crates
Projects
None yet
Development

No branches or pull requests

3 participants