module Regexp::Syntax
def self.load(name)
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)
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 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 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 else raise UnknownSyntaxError.new(name) end end