module Regexp::Syntax

def self.load(name)

it if it does. Downcases names, and adds the .rb extension if omitted.
Checks if the named syntax has a specification class file, and requires
def self.load(name)
  full = "#{SYNTAX_SPEC_ROOT}/#{name.downcase}"
  full = (full[-1, 3] == '.rb') ? full : "#{full}.rb"
  raise MissingSyntaxSpecError.new(name) unless File.exist?(full)
  require full
end

def self.new(name)

instance of Syntax::Any. See below for more details.
the given syntax flavor name. The special names 'any' and '*' returns a
Loads, and instantiates an instance of the syntax specification class for
def self.new(name)
  return Regexp::Syntax::Any.new if
    ['*', 'any'].include?( name.to_s )
  self.load(name)
  case name
    # Ruby 1.8.x (NOTE: 1.8.6 is no longer a supported runtime,
    # but its regex features are still recognized.)
    when 'ruby/1.8.6';  syntax = Regexp::Syntax::Ruby::V186.new
    when 'ruby/1.8.7';  syntax = Regexp::Syntax::Ruby::V187.new
    # alias for the latest 1.8 implementation
    when 'ruby/1.8';    syntax = Regexp::Syntax::Ruby::V18.new
    # Ruby 1.9.x
    when 'ruby/1.9.1';  syntax = Regexp::Syntax::Ruby::V191.new
    when 'ruby/1.9.2';  syntax = Regexp::Syntax::Ruby::V192.new
    when 'ruby/1.9.3';  syntax = Regexp::Syntax::Ruby::V193.new
    # alias for the latest 1.9 implementation
    when 'ruby/1.9';    syntax = Regexp::Syntax::Ruby::V19.new
    # Ruby 2.0.x
    when 'ruby/2.0.0';  syntax = Regexp::Syntax::Ruby::V200.new
    # aliases for the latest 2.0 implementations
    when 'ruby/2.0';    syntax = Regexp::Syntax::Ruby::V20.new
    # Ruby 2.1.x
    when 'ruby/2.1.0';  syntax = Regexp::Syntax::Ruby::V210.new
    when 'ruby/2.1.2';  syntax = Regexp::Syntax::Ruby::V212.new
    when 'ruby/2.1.3';  syntax = Regexp::Syntax::Ruby::V213.new
    when 'ruby/2.1.4';  syntax = Regexp::Syntax::Ruby::V214.new
    when 'ruby/2.1.5';  syntax = Regexp::Syntax::Ruby::V215.new
    when 'ruby/2.1.6';  syntax = Regexp::Syntax::Ruby::V216.new
    # aliases for the latest 2.1 implementations
    when 'ruby/2.1';    syntax = Regexp::Syntax::Ruby::V21.new
    # Ruby 2.2.x
    when 'ruby/2.2.0';  syntax = Regexp::Syntax::Ruby::V220.new
    when 'ruby/2.2.1';  syntax = Regexp::Syntax::Ruby::V221.new
    when 'ruby/2.2.2';  syntax = Regexp::Syntax::Ruby::V222.new
    # aliases for the latest 2.2 implementations
    when 'ruby/2.2';    syntax = Regexp::Syntax::Ruby::V22.new
    else
      raise UnknownSyntaxError.new(name)
  end
end