-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add support for Perl(PCRE) named and unnamed group capturing order #43
base: master
Are you sure you want to change the base?
Conversation
In other words maintain the order of capture groups.
Thanks for submitting this! It'll take me a bit to review and gather my thoughts on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On first pass I have a few questions, it'd be great to get your perspective on them.
@@ -386,7 +417,11 @@ func (p *parser) countCaptures() error { | |||
} | |||
} else { | |||
if !p.useOptionN() && !p.ignoreNextParen { | |||
p.noteCaptureSlot(p.consumeAutocap(), pos) | |||
if p.useMaintainCaptureOrder() { | |||
p.noteCaptureName(fmt.Sprint(p.autocap), pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not consumeAutocap()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because consumeAutocap
is called inside noteCaptureName
when MaintainCaptureOrder
is enabled.
Does this need a comment somewhere?
- Document MaintainCaptureOrder option - Use return in `assignNameSlots` and remove else - Add test with MaintainCaptureOrder not provided - Change the MaintainCaptureOrder value to `0x0400` - Remove the `o` inline option - Add comment to explain why `autocap` is consumed
Is there anyway get named group? like I want get |
@yywing Don't know why you asked that question here, as it's not relevant to the pull request. But you can do |
In other words maintain the order of capture groups. With the
MaintainCaptureOrder
regexp option.I also added inline option
o
. It's useful if you only have access to the pattern, but not the regex. But it only is useful if used at the start of the pattern, I couldn't find a way to prevent it from being used elsewhere.I've never liked nor have been good with bitwise operations. So I don't know if I should've picked another number.