Module: Regexp::Syntax
- Included in:
- Parser
- Defined in:
- lib/regexp_parser/syntax/tokens.rb,
lib/regexp_parser/syntax.rb,
lib/regexp_parser/syntax/any.rb,
lib/regexp_parser/syntax/base.rb,
lib/regexp_parser/syntax/tokens.rb,
lib/regexp_parser/syntax/ruby/1.8.rb,
lib/regexp_parser/syntax/ruby/1.9.rb,
lib/regexp_parser/syntax/ruby/2.0.rb,
lib/regexp_parser/syntax/ruby/2.1.rb,
lib/regexp_parser/syntax/ruby/2.2.rb,
lib/regexp_parser/syntax/ruby/2.3.rb,
lib/regexp_parser/syntax/ruby/2.4.rb,
lib/regexp_parser/syntax/ruby/2.5.rb,
lib/regexp_parser/syntax/ruby/2.6.rb,
lib/regexp_parser/syntax/versions.rb,
lib/regexp_parser/syntax/ruby/1.8.6.rb,
lib/regexp_parser/syntax/ruby/1.8.7.rb,
lib/regexp_parser/syntax/ruby/1.9.1.rb,
lib/regexp_parser/syntax/ruby/1.9.2.rb,
lib/regexp_parser/syntax/ruby/1.9.3.rb,
lib/regexp_parser/syntax/ruby/2.0.0.rb,
lib/regexp_parser/syntax/ruby/2.1.0.rb,
lib/regexp_parser/syntax/ruby/2.1.2.rb,
lib/regexp_parser/syntax/ruby/2.1.3.rb,
lib/regexp_parser/syntax/ruby/2.1.4.rb,
lib/regexp_parser/syntax/ruby/2.1.5.rb,
lib/regexp_parser/syntax/ruby/2.1.6.rb,
lib/regexp_parser/syntax/ruby/2.1.7.rb,
lib/regexp_parser/syntax/ruby/2.1.8.rb,
lib/regexp_parser/syntax/ruby/2.1.9.rb,
lib/regexp_parser/syntax/ruby/2.2.0.rb,
lib/regexp_parser/syntax/ruby/2.2.1.rb,
lib/regexp_parser/syntax/ruby/2.2.2.rb,
lib/regexp_parser/syntax/ruby/2.2.3.rb,
lib/regexp_parser/syntax/ruby/2.2.4.rb,
lib/regexp_parser/syntax/ruby/2.2.5.rb,
lib/regexp_parser/syntax/ruby/2.2.6.rb,
lib/regexp_parser/syntax/ruby/2.2.7.rb,
lib/regexp_parser/syntax/ruby/2.2.8.rb,
lib/regexp_parser/syntax/ruby/2.2.9.rb,
lib/regexp_parser/syntax/ruby/2.3.0.rb,
lib/regexp_parser/syntax/ruby/2.3.1.rb,
lib/regexp_parser/syntax/ruby/2.3.2.rb,
lib/regexp_parser/syntax/ruby/2.3.3.rb,
lib/regexp_parser/syntax/ruby/2.3.4.rb,
lib/regexp_parser/syntax/ruby/2.3.5.rb,
lib/regexp_parser/syntax/ruby/2.3.6.rb,
lib/regexp_parser/syntax/ruby/2.4.0.rb,
lib/regexp_parser/syntax/ruby/2.4.1.rb,
lib/regexp_parser/syntax/ruby/2.4.2.rb,
lib/regexp_parser/syntax/ruby/2.4.3.rb,
lib/regexp_parser/syntax/ruby/2.5.0.rb,
lib/regexp_parser/syntax/ruby/2.6.0.rb,
lib/regexp_parser/syntax/ruby/2.1.10.rb,
lib/regexp_parser/syntax/tokens/keep.rb,
lib/regexp_parser/syntax/tokens/meta.rb,
lib/regexp_parser/syntax/tokens/group.rb,
lib/regexp_parser/syntax/tokens/anchor.rb,
lib/regexp_parser/syntax/tokens/escape.rb,
lib/regexp_parser/syntax/tokens/backref.rb,
lib/regexp_parser/syntax/tokens/assertion.rb,
lib/regexp_parser/syntax/tokens/quantifier.rb,
lib/regexp_parser/syntax/tokens/conditional.rb,
lib/regexp_parser/syntax/tokens/character_set.rb,
lib/regexp_parser/syntax/tokens/character_type.rb,
lib/regexp_parser/syntax/tokens/unicode_property.rb
Overview
Ruby 1.8.x is no longer a supported runtime, but its regex features are still recognized.
Aliases for the latest patch version are provided as ‘ruby/n.n’, e.g. ‘ruby/1.9’ refers to Ruby v1.9.3.
Defined Under Namespace
Modules: Ruby, Token Classes: Any, Base, InvalidVersionNameError, NotImplementedError, SyntaxError, UnknownSyntaxNameError
Constant Summary collapse
- VERSION_FORMAT =
'\Aruby/\d+\.\d+(\.\d+)?\z'
- VERSION_REGEXP =
/#{VERSION_FORMAT}/
- VERSIONS =
version_file_paths.map { |path| path[%r{(ruby/[^/]+)\.rb}, 1] }
Class Method Summary collapse
-
.new(name) ⇒ Object
Loads and instantiates an instance of the syntax specification class for the given syntax version name.
- .supported?(name) ⇒ Boolean
- .version_class(version) ⇒ Object
Class Method Details
.new(name) ⇒ Object
Loads and instantiates an instance of the syntax specification class for the given syntax version name. The special names ‘any’ and ‘*’ return an instance of Syntax::Any.
32 33 34 35 36 37 38 39 |
# File 'lib/regexp_parser/syntax.rb', line 32 def self.new(name) return Regexp::Syntax::Any.new if ['*', 'any'].include?( name.to_s ) raise UnknownSyntaxNameError.new(name) unless supported?(name) version_class(name).new end |
.supported?(name) ⇒ Boolean
41 42 43 |
# File 'lib/regexp_parser/syntax.rb', line 41 def self.supported?(name) VERSIONS.include?(name) end |
.version_class(version) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/regexp_parser/syntax.rb', line 45 def self.version_class(version) raise InvalidVersionNameError.new(version) unless version =~ VERSION_REGEXP version_const_name = version.scan(/\d+/).join const_name = "Regexp::Syntax::Ruby::V#{version_const_name}" if RUBY_VERSION >= '2.0.0' Kernel.const_get(const_name) else Object.module_eval(const_name, __FILE__, __LINE__) end end |