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

Gaps and Queries #24

Open
Tracked by #38
conartist6 opened this issue Dec 7, 2022 · 4 comments
Open
Tracked by #38

Gaps and Queries #24

conartist6 opened this issue Dec 7, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@conartist6
Copy link
Member

This powerful feature allows some nodes of a complete tree to be missing. It will be possible to drag and drop fragments of existing code into a gap, and it should not be possible to accidentally create invalid programs this way.

It is expected that gaps in programs will be represented in serialized text as \x00 (the null byte). This way it will be possible to store code with gaps as plain text (i.e. not a CST json structure). We will be able to rehydrate those null bytes with information from the grammar, parsing them into a gap token so that it is clear what they reference.

@conartist6
Copy link
Member Author

Should CSTs include type: 'Gap' nodes? I think so. I think it will be necessary in order to implement path.replaceWith().

In particular path for a gap needs to know what the target of replacement in the tree is. Paths store this information as path.refToken.value, which means that the parent should have that refToken in its cstTokens already. But we also need a place to store the gap token, particularly since trivial printing requires the \x00 value to exist in the tokens tree somewhere. It seems obvious to me to create a temporary child with cstTokens: [gapToken]. That would also eliminate problems caused by the alternative: path.node === null

@conartist6
Copy link
Member Author

conartist6 commented Dec 7, 2022

Gaps are going to need to be implemented at the same time as #27 because parsers are going to be the only reasonable way of creating trees with gaps in them, and no existing parsers will be able to do this for us.

@conartist6
Copy link
Member Author

It's nearly time!

@conartist6 conartist6 mentioned this issue Jun 16, 2023
9 tasks
@conartist6 conartist6 changed the title Gaps Gaps and Queries Jun 16, 2023
@conartist6
Copy link
Member Author

Adding queries to this issue as they'll be necessary for working with gapped trees

@conartist6 conartist6 added the enhancement New feature or request label Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant