Sha256: c6448505c6a9cb40eedee31b3cad592ab32ea28c07e38a622d81fdccf5a47f2b

Contents?: true

Size: 1.61 KB

Versions: 6

Compression:

Stored size: 1.61 KB

Contents

module Regexp::Expression
  # TODO: unify name with token :backref, one way or the other, in v3.0.0
  module Backreference
    class Base < Regexp::Expression::Base
      attr_accessor :referenced_expression

      def initialize_copy(orig)
        self.referenced_expression = orig.referenced_expression.dup
        super
      end
    end

    class Number < Backreference::Base
      attr_reader :number
      alias reference number

      def initialize(token, options = {})
        @number = token.text[token.token.equal?(:number) ? 1..-1 : 3..-2].to_i
        super
      end
    end

    class Name < Backreference::Base
      attr_reader :name
      alias reference name

      def initialize(token, options = {})
        @name = token.text[3..-2]
        super
      end
    end

    class NumberRelative     < Backreference::Number
      attr_accessor :effective_number
      alias reference effective_number
    end

    class NumberCall         < Backreference::Number; end
    class NameCall           < Backreference::Name; end
    class NumberCallRelative < Backreference::NumberRelative; end

    class NumberRecursionLevel < Backreference::Number
      attr_reader :recursion_level

      def initialize(token, options = {})
        super
        @number, @recursion_level = token.text[3..-2].split(/(?=[+-])/).map(&:to_i)
      end
    end

    class NameRecursionLevel < Backreference::Name
      attr_reader :recursion_level

      def initialize(token, options = {})
        super
        @name, recursion_level = token.text[3..-2].split(/(?=[+-])/)
        @recursion_level = recursion_level.to_i
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/regexp_parser-2.5.0/lib/regexp_parser/expression/classes/backreference.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/regexp_parser-2.5.0/lib/regexp_parser/expression/classes/backreference.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/regexp_parser-2.5.0/lib/regexp_parser/expression/classes/backreference.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/regexp_parser-2.5.0/lib/regexp_parser/expression/classes/backreference.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/regexp_parser-2.5.0/lib/regexp_parser/expression/classes/backreference.rb
regexp_parser-2.5.0 lib/regexp_parser/expression/classes/backreference.rb