class Regexp::Parser
def open_group(token)
def open_group(token) case token.token when :passive exp = Group::Passive.new(token, active_opts) when :atomic exp = Group::Atomic.new(token, active_opts) when :named exp = Group::Named.new(token, active_opts) when :capture exp = Group::Capture.new(token, active_opts) when :absence exp = Group::Absence.new(token, active_opts) when :lookahead exp = Assertion::Lookahead.new(token, active_opts) when :nlookahead exp = Assertion::NegativeLookahead.new(token, active_opts) when :lookbehind exp = Assertion::Lookbehind.new(token, active_opts) when :nlookbehind exp = Assertion::NegativeLookbehind.new(token, active_opts) else raise UnknownTokenError.new('Group type open', token) end if exp.capturing? exp.number = total_captured_group_count + 1 exp.number_at_level = captured_group_count_at_level + 1 count_captured_group end # Push the active options to the stack again. This way we can simply pop the # stack for any group we close, no matter if it had its own options or not. options_stack << active_opts nest(exp) end