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

Extend incremental reparsing to all braced blocks #66

Closed
matklad opened this issue Sep 8, 2018 · 3 comments
Closed

Extend incremental reparsing to all braced blocks #66

matklad opened this issue Sep 8, 2018 · 3 comments

Comments

@matklad
Copy link
Member

matklad commented Sep 8, 2018

The incremental reparsing model of libsyntax2 is curly-block based.

  • in the parser, we make sure that, for any pair of { and }, there's a syntax node for which curlys are the first and the last child.
  • this gives us corollary: if edit is inside a matching pair of braces, and the pair remains matching after the edit is applied, the effects of the edit are contained to a single block.
  • this gives a rise to incremental re parsing algorithm: find closest curly-block, verify its structure, reparse.

Currently only expr blocks and struct blocks participate in this algorithm, but it should be extended to any kind of braced block. Here's the relevant code:

https://github.com/matklad/libsyntax2/blob/4f647096665b2ca3725ba1f7415a21fbc46044bb/crates/libsyntax2/src/lib.rs#L145-L147

it should be extended to all braced blocks. The relevant tests are here:

https://github.com/matklad/libsyntax2/blob/4f647096665b2ca3725ba1f7415a21fbc46044bb/crates/libsyntax2/tests/test/main.rs#L42

It would be nice to use proptest or fuzzing to check incremental re parsing! (cc @killercup on the last one). Here's the top-level repasing API:

https://github.com/matklad/libsyntax2/blob/4f647096665b2ca3725ba1f7415a21fbc46044bb/crates/libsyntax2/src/lib.rs#L81

@darksv
Copy link
Contributor

darksv commented Sep 9, 2018

Hi! I want to take it.

@matklad
Copy link
Member Author

matklad commented Sep 10, 2018

Cool, if there's any question I can help with, don't hesitate to ask here, @darksv ! A good first start is perhaps to just add a single more block to the list of cases, for example, a match_arm_list.

@darksv
Copy link
Contributor

darksv commented Sep 10, 2018

Thank you. I have implemented reparsing for remaining blocks. Now I want to give proptest a go and add more tests.

bors bot added a commit that referenced this issue Sep 10, 2018
68: Implement incremental reparsing for remaining braced blocks r=matklad a=darksv

Fixes #66

Co-authored-by: darksv <darek969-12@o2.pl>
bors bot added a commit that referenced this issue Sep 10, 2018
68: Implement incremental reparsing for remaining braced blocks r=matklad a=darksv

Fixes #66

Co-authored-by: darksv <darek969-12@o2.pl>
bors bot added a commit that referenced this issue Sep 11, 2018
68: Implement incremental reparsing for remaining braced blocks r=matklad a=darksv

Fixes #66

Co-authored-by: darksv <darek969-12@o2.pl>
@bors bors bot closed this as completed in #68 Sep 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants