Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Knowing if a group in the pattern is matched and group name #100

Open
lieene opened this issue Oct 22, 2019 · 3 comments
Open

Knowing if a group in the pattern is matched and group name #100

lieene opened this issue Oct 22, 2019 · 3 comments

Comments

@lieene
Copy link

lieene commented Oct 22, 2019

Summary

CaptureIndex should contain info to tell if a subgroup is matched and group name on a named group.

Motivation

group name and subgroup match state are needed in some cases.

Describe alternatives you've considered

As unmatched group always has a 0 start position and 0 lengths. So when full-match is not started at 0, comparing subgroup start with full-match start can tell if there is a match. but that does not solve the case when full-match starts at 0. And 0 length(anchor alike) subgroup will have 0 lengths, so testing length against 0 can only solve none-0-length groups.

the group name can be collected by parsing pattern sources.
it would be very helpful if group name and subgroup match state can be provided by CaptureIndex.

Additional context

@rsese
Copy link

rsese commented Oct 23, 2019

Thanks for the suggestion - we're not currently prioritizing new functionality but just to clarify, would this idea be useful for Atom in particular or are you using this module outside of Atom?

@Aerijo
Copy link

Aerijo commented Oct 23, 2019

@rsese It’s for TextMate grammars; more recent oniguruma versions have a conditional regex, but that feature doesn’t appear to have been implemented when this repo was made.

@lieene
Copy link
Author

lieene commented Oct 28, 2019

@rsese, for now, I'm working on a vscode extension on injection grammar. the extension uses oniguruma to sync with TM grammars. And I need group names and anchor matcher. And it can be adapted to Atom with not much effort. I have a working pattern search for group names. but 0 pos anchor is still a problem.

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

No branches or pull requests

3 participants