module Regexp::Scanner
def self.scan_options(p, data, ts, te)
ambiguity, so we just ask it to find the beginning of what looks
Ragel's regex-based scan of the group options introduced a lot of
def self.scan_options(p, data, ts, te) text = text(data, ts, te).first options_char, options_length = true, 0 # Copy while we have option characters, the maximum is 7, for (?mix-mix, # even though it doesn't make sense it is possible. while options_char and options_length < 7 if data[te + options_length] c = data[te + options_length].chr if c =~ /[-mix]/ text << c ; p += 1 ; options_length += 1 else options_char = false end else raise PrematureEndError.new("expression options `#{text}'") end end if data[te + options_length] c = data[te + options_length].chr if c == ':' # Include the ':' in the options text text << c ; p += 1 ; options_length += 1 emit(:group, :options, text, ts, te + options_length) elsif c == ')' # Don't include the closing ')', let group_close handle it. emit(:group, :options, text, ts, te + options_length) else # Plain Regexp reports this as 'undefined group option' raise ScannerError.new( "Unexpected `#{c}' in options sequence, ':' or ')' expected") end else raise PrematureEndError.new("expression options `#{text}'") end p # return the new value of the data pointer end