class Regexp::Expression::Base

def ascii_classes?

def ascii_classes?
  options[:a] == true
end

def case_insensitive?

def case_insensitive?
  options[:i] == true
end

def default_classes?

def default_classes?
  options[:d] == true
end

def free_spacing?

def free_spacing?
  options[:x] == true
end

def greedy?

def greedy?
  quantified? and quantifier.greedy?
end

def initialize(token, options = {})

def initialize(token, options = {})
  init_from_token_and_options(token, options)
end

def match(string, offset = 0)

def match(string, offset = 0)
  Regexp.new(to_s).match(string, offset)
end

def match?(string)

def match?(string)
  !!match(string)
end

def multiline?

def multiline?
  options[:m] == true
end

def possessive?

def possessive?
  quantified? and quantifier.possessive?
end

def quantify(*args)

def quantify(*args)
  self.quantifier = Quantifier.new(*args)
end

def quantity

Deprecated. Prefer `#repetitions` which has a more uniform interface.
def quantity
  return [nil,nil] unless quantified?
  [quantifier.min, quantifier.max]
end

def reluctant?

def reluctant?
  quantified? and quantifier.reluctant?
end

def repetitions

def repetitions
  @repetitions ||=
    if quantified?
      min = quantifier.min
      max = quantifier.max < 0 ? Float::INFINITY : quantifier.max
      range = min..max
      # fix Range#minmax on old Rubies - https://bugs.ruby-lang.org/issues/15807
      if RUBY_VERSION.to_f < 2.7
        range.define_singleton_method(:minmax) { [min, max] }
      end
      range
    else
      1..1
    end
end

def strfregexp(format = '%a', indent_offset = 0, index = nil)


%a All info, same as '%m %t'
%m Most info, same as '%b %q'
%b Basic info, same as '%o %i'

%T Full text of the expression (includes quantifier, if any)
%~t Full text if the expression is terminal, otherwise %i
%t Base text of the expression (excludes quantifier, if any)

%Z Quantifier max
%z Quantifier min

%Q Quantifier text
%q Quantifier info, as {m[,M]}

%c Class name
%i ID, same as '%y:%k'
%k Token of expression.
%y Type of expression.

%o Coded offset and length, same as '@%s+%S'

%S Length of expression.
%e End offset within the whole expression.
%s Start offset within the whole expression.

the sprintf_tree method only.
%x Index of the expression at its depth. Available when using

%> Indentation at expression's level.

expression, returns zero or higher for all others.
%l Level (depth) of the expression. Returns 'root' for the root
def strfregexp(format = '%a', indent_offset = 0, index = nil)
  have_index    = index ? true : false
  part = {}
  print_level = nesting_level > 0 ? nesting_level - 1 : nil
  # Order is important! Fields that use other fields in their
  # definition must appear before the fields they use.
  part_keys = %w[a m b o i l x s e S y k c q Q z Z t ~t T >]
  part.keys.each {|k| part[k] = "<?#{k}?>"}
  part['>'] = print_level ? ('  ' * (print_level + indent_offset)) : ''
  part['l'] = print_level ? "#{'%d' % print_level}" : 'root'
  part['x'] = "#{'%d' % index}" if have_index
  part['s'] = starts_at
  part['S'] = full_length
  part['e'] = starts_at + full_length
  part['o'] = coded_offset
  part['k'] = token
  part['y'] = type
  part['i'] = '%y:%k'
  part['c'] = self.class.name
  if quantified?
    if quantifier.max == -1
      part['q'] = "{#{quantifier.min}, or-more}"
    else
      part['q'] = "{#{quantifier.min}, #{quantifier.max}}"
    end
    part['Q'] = quantifier.text
    part['z'] = quantifier.min
    part['Z'] = quantifier.max
  else
    part['q'] = '{1}'
    part['Q'] = ''
    part['z'] = '1'
    part['Z'] = '1'
  end
  part['t'] = to_s(:base)
  part['~t'] = terminal? ? to_s : "#{type}:#{token}"
  part['T'] = to_s(:full)
  part['b'] = '%o %i'
  part['m'] = '%b %q'
  part['a'] = '%m %t'
  out = format.dup
  part_keys.each do |k|
    out.gsub!(/%#{k}/, part[k].to_s)
  end
  out
end

def to_h

def to_h
  {
    type:              type,
    token:             token,
    text:              to_s(:base),
    starts_at:         ts,
    length:            full_length,
    level:             level,
    set_level:         set_level,
    conditional_level: conditional_level,
    options:           options,
    quantifier:        quantified? ? quantifier.to_h : nil,
  }
end

def to_re(format = :full)

def to_re(format = :full)
  if set_level > 0
    warn "Calling #to_re on character set members is deprecated - "\
         "their behavior might not be equivalent outside of the set."
  end
  ::Regexp.new(to_s(format))
end

def unicode_classes?

def unicode_classes?
  options[:u] == true
end

def unquantified_clone

def unquantified_clone
  clone.tap { |exp| exp.quantifier = nil }
end