Sha256: 94ea8fb1b459d1b6eb6183a44ed1771fe4442bd3c9c6bc8850ddcb4781f0810f

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

module Regexp::Expression
  module Group
    class Base < Regexp::Expression::Subexpression
      def to_s(format = :full)
        "#{text}#{expressions.join})#{quantifier_affix(format)}"
      end

      def capturing?; false end

      def comment?; false end
    end

    class Passive < Group::Base
      attr_writer :implicit

      def to_s(format = :full)
        if implicit?
          "#{expressions.join}#{quantifier_affix(format)}"
        else
          super
        end
      end

      def implicit?
        @implicit ||= false
      end
    end

    class Absence < Group::Base; end
    class Atomic  < Group::Base; end
    class Options < Group::Base
      attr_accessor :option_changes
    end

    class Capture < Group::Base
      attr_accessor :number, :number_at_level
      alias identifier number

      def capturing?; true end
    end

    class Named < Group::Capture
      attr_reader :name
      alias identifier name

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

      def initialize_clone(orig)
        @name = orig.name.dup
        super
      end
    end

    class Comment < Group::Base
      def to_s(_format = :full)
        text.dup
      end

      def comment?; true end
    end
  end

  module Assertion
    class Base < Regexp::Expression::Group::Base; end

    class Lookahead           < Assertion::Base; end
    class NegativeLookahead   < Assertion::Base; end

    class Lookbehind          < Assertion::Base; end
    class NegativeLookbehind  < Assertion::Base; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
regexp_parser-2.0.1 lib/regexp_parser/expression/classes/group.rb
regexp_parser-2.0.0 lib/regexp_parser/expression/classes/group.rb