-
Notifications
You must be signed in to change notification settings - Fork 5
support named groups #8
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 named groups #8
Conversation
this is from named groups breaking length checks
|
I think it would be a good idea to also store a copy of the named group at the corresponding index. With your current solution, |
|
How about a separate |
jsregexp.c
Outdated
| } | ||
| lua_setfield(lstate, -2, "groups"); | ||
|
|
||
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.
whitespace
|
|
||
| const char* group_names = NULL; | ||
| if (named_groups) { | ||
| group_names = lre_get_groupnames(r->bc); |
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.
I think we can just push the table for named groups here so we don't have to pop it later. Need to switch the stack indexes -2 and -3 in the loop, of course.
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.
Uhh I’m not quite sure how to do this without having some sort of ternarys to specify stack position based on if named groups is true
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.
I should have made this clearer. If the table of the normal indexed matches is on top, one can always access it with rawseti(lstate, -2, ...). If named_groups is true, have the table of named groups below that so it is accessed with setfield(lstate, -3, ...). Just make sure you push a second table when named_groups is true.
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.
I have updated it to work somewhat as you describe. I'm pretty sure you have to do some branching for stack positions as is done here
|
I went ahead and merged because I thought it would be easier merging before #5. Thanks for the contribution! |
Allow named groups flag
"n"to be available