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 backrefs in included contexts #288

Merged
merged 5 commits into from Apr 20, 2020

Conversation

keith-hall
Copy link
Collaborator

fixes #104 - when building the syntax set, after the contexts are linked to direct references, it now checks if any included contexts use backreferences in their match patterns, and if so, marks the base context as using backreferences.

@sharkdp
Copy link
Contributor

sharkdp commented Apr 14, 2020

I can confirm that this fixes sharkdp/bat#914 - thank you very much!

Copy link
Collaborator

@robinst robinst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a stylistic comment, otherwise LGTM.

src/parsing/syntax_set.rs Outdated Show resolved Hide resolved
@keith-hall
Copy link
Collaborator Author

I pushed a new commit because I noticed that it didn't support nested includes which use backreferences - so I added a test case for it. Please could you review the new changes @robinst? Maybe you can think of a better way of doing it than the "loop multiple times through each context to check if it needs to be marked as using backrefs until no new included contexts are found" approach that I have implemented...

Copy link
Owner

@trishume trishume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I streamlined the match statement even more and added a comment that I benchmarked the non-fancy graph flood fill locally and it was negligibly slower than linking previously.

However you don't seem to have enabled the maintainers can push to the branch for this PR so I can't push the commits. If you're around you can see if you can enable that otherwise I'll just manually merge and the Github UI may just look like I closed this PR instead of merging it.

@trishume
Copy link
Owner

Another question: Should we regenerate pack files? That is, does this change actually affect anything in the default syntax sets or do no default syntaxes include a context with backreferences? I notice that when I try regenerating the pack files no syntax tests change.

@keith-hall
Copy link
Collaborator Author

However you don't seem to have enabled the maintainers can push to the branch for this PR so I can't push the commits. If you're around you can see if you can enable that

sorry about that, but as far as I can tell, GitHub is no longer offering this option - because my fork is owned by a "group" maybe? I certainly used to have this option set. Anyway, I have offered you write access to my fork to work around this.

The default packages aren't affected at our current submodule version as I understand it, but in more recent commits, syntaxes like Ruby are affected by this. So no need to regenerate packs as part of this PR.

@trishume trishume merged commit c3927a6 into trishume:master Apr 20, 2020
@sharkdp
Copy link
Contributor

sharkdp commented Apr 20, 2020

Thank you all for your continued work on syntect!

@trishume If you find the time, a (bugfix) release with this PR included would be very much appreciated.

@trishume
Copy link
Owner

@sharkdp I released v4.1.1 with this fix

@sharkdp
Copy link
Contributor

sharkdp commented Apr 21, 2020

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

included contexts should still be able to pop using backrefs
4 participants