class Regexp::Expression::Sequence

A sequence of expressions. Differs from a Subexpressions by how it handles quantifiers, as it applies them to its last element instead of itself as a whole subexpression.

Used as the base class for the Alternation alternatives, Conditional branches, and CharacterSet::Intersection intersected sequences.

Public Class Methods

add_to(exp, params = {}, active_opts = {}) click to toggle source
# File lib/regexp_parser/expression/sequence.rb, line 10
def add_to(exp, params = {}, active_opts = {})
  sequence = construct(
    level:             exp.level,
    set_level:         exp.set_level,
    conditional_level: params[:conditional_level] || exp.conditional_level,
  )
  sequence.nesting_level = exp.nesting_level + 1
  sequence.options = active_opts
  exp.expressions << sequence
  sequence
end

Public Instance Methods

quantify(*args) click to toggle source
# File lib/regexp_parser/expression/sequence.rb, line 28
def quantify(*args)
  target = expressions.reverse.find { |exp| !exp.is_a?(FreeSpace) }
  target or raise Regexp::Parser::Error,
    "No valid target found for '#{text}' quantifier"

  target.quantify(*args)
end
starts_at() click to toggle source
# File lib/regexp_parser/expression/sequence.rb, line 23
def starts_at
  expressions.first.starts_at
end
Also aliased as: ts
ts()
Alias for: starts_at