Sha256: ac87723182062bca4846447f0f0b030bd639a6d8e0db04c43e2f1e1a39a6b618
Contents?: true
Size: 1.1 KB
Versions: 23
Compression:
Stored size: 1.1 KB
Contents
module Regexp::Expression # 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 and Conditional # branches. class Sequence < Regexp::Expression::Subexpression def initialize(level, set_level, conditional_level) super Regexp::Token.new( :expression, :sequence, '', nil, # ts nil, # te level, set_level, conditional_level ) end def text to_s end def starts_at @expressions.first.starts_at end def quantify(token, text, min = nil, max = nil, mode = :greedy) offset = -1 target = expressions[offset] while target and target.is_a?(FreeSpace) target = expressions[offset -= 1] end raise ArgumentError.new("No valid target found for '#{text}' " + "quantifier") unless target target.quantify(token, text, min, max, mode) end end end
Version data entries
23 entries across 23 versions & 1 rubygems