1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
# frozen_string_literal: true
module Regexp::Expression
module Group
class Base < Regexp::Expression::Subexpression
end
class Passive < Group::Base
attr_writer :implicit
def initialize(*)
@implicit = false
super
end
def implicit?
@implicit
end
end
class Absence < Group::Base; end
class Atomic < Group::Base; end
# TODO: should split off OptionsSwitch in v3.0.0. Maybe even make it no
# longer inherit from Group because it is effectively a terminal expression.
class Options < Group::Base
attr_accessor :option_changes
def initialize_copy(orig)
self.option_changes = orig.option_changes.dup
super
end
def quantify(*args)
if token == :options_switch
raise Regexp::Parser::Error, 'Can not quantify an option switch'
else
super
end
end
end
class Capture < Group::Base
attr_accessor :number, :number_at_level
alias identifier number
end
class Named < Group::Capture
attr_reader :name
alias identifier name
def initialize(token, options = {})
@name = token.text[3..-2]
super
end
def initialize_copy(orig)
@name = orig.name.dup
super
end
end
class Comment < Group::Base
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
|