-
-
Notifications
You must be signed in to change notification settings - Fork 42
Description
We will need to update the parser to track when multiple groups are defined with the same name. This is so the caller can decide how to react when the same name is used to declare multiple groups. We need this to be able to match Oniguruma behavior:
- with backrefs referring to a named group with more than one declaration
When backreferencing with a name that is assigned to more than one group, the last group with the name is checked first, if not matched then the previous one with the name, and so on, until there is a match.
- with subroutine calls referring to a named group with more than one declaration (to be a compile error)
Calls with a name that is assigned to more than one group are not allowed.
For this issue we can just handle the changes to the parser, and resolve it to a single numbered group when compiling, to match the current behavior. This will keep the changes smaller - we can then work on updating the backref behavior to more closely match Oniguruma afterwards.
Possible approaches:
- change the type of the
named_groups
on the Parser (less invasive) - or emit a separate
Expr
variant for named groups (more invasive)