Skip to content
New issue

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

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

Already on GitHub? # to your account

Add deserialization symmetrically to existing serialization #74

Open
abdulla-tuychi opened this issue Sep 28, 2020 · 1 comment
Open

Comments

@abdulla-tuychi
Copy link

I found no deserialization in feature serde1. Could this be added, please?

@CAD97
Copy link
Collaborator

CAD97 commented Sep 29, 2020

Deserialization is hard. The tree is deduplicated, so deserialization either reduplicates the tree (the way it is in the serialized form) or needs to thread context through in a difficult manner.

Additionally, Rowan is a library for textual parse trees. You already have a nice serialized format -- the text you're parsing -- and a way to convert that format into the tree. The tree contains the full text that you're parsing, so the serialized tree is strictly larger and contains more redundant information than the text that produced it. Even with the additional redundant information, parsing the tree from a tree serialization is likely not measurably faster than a well-written parser for the original text.

The serde serialization support exists mostly as a convenient simple way to perform snapshot testing (or a similar functionality) on the parsed trees that's (potentially) more readable, diffable, and useful than the debug output.

That's not to say it couldn't be done, though! In the (still experimental) reimplementation of the green tree layer, sorbus, I've implemented proper deserialization for green trees. It's messy, but a fairly good example of how to write an efficient allocation-minimizing implementation of cached DeserializeSeed.

I'm in grad school now so have very little time to spend on open source work currently. But if I find time, I do want to work on getting sorbus integrated into rowan (as the green tree design is better and enables faster "syntax pointers"), at which point it will be possible to get deserialization by asking sorbus for it. (But likely not Rowan, as, again, there's little reason Rowan sees for deserialization of a tree.)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants