Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Serialization #10

Closed
kddnewton opened this issue Sep 28, 2022 · 0 comments
Closed

Serialization #10

kddnewton opened this issue Sep 28, 2022 · 0 comments

Comments

@kddnewton
Copy link
Collaborator

We want a binary serialization of the syntax tree such that it can be deserialized and read in any other language. This issue is to begin looking at how that would work and what the structure would be. I'm imagining something to the effect of the below design.

First, the header:

# bytes field
4 YARP
1 major version
1 minor version
1 patch version
8 comments offset into file

Next, the tree. For each node, it'll walk the tree starting from the top. It will dump:

# bytes field
4 type
8 offset of next node in tree*
8 start offset in source
8 end offset in source

Then for each child node from this node it will recurse. Each child node type will have to have its own kind of serialization. I'll discuss those next.

*I think this is a good idea to include so that folks can skip past this node if it's trivial for the implementation. For example, if it's a Self node and you don't care about offset in the source then you can just skip directly to the next node in the tree.

For a child node that is itself a node, it will use the schema defined above. For a child node that is a string, it will use:

# bytes field
8 start offset
8 end offset

For a child that is a node list, it will use:

# bytes field
4 number of elements in the list

and then for each node it will recurse.

Finally, at the end it will have a section for comments, which will look like:

# bytes field
4 number of comments in the file

then for each comment:

# bytes field
8 start offset
8 end offset

I believe this is enough information to get started. Certainly we're going to iterate on this.

@ruby ruby locked and limited conversation to collaborators Sep 28, 2022
@kddnewton kddnewton converted this issue into discussion #11 Sep 28, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant