class PatternMatch::PatternQuantifier

Attributes

min_k[R]

Public Class Methods

new(min_k, is_greedy) click to toggle source
Calls superclass method PatternMatch::Pattern::new
# File lib/pattern-match/core.rb, line 157
def initialize(min_k, is_greedy)
  super()
  @min_k = min_k
  @is_greedy = is_greedy
end

Public Instance Methods

greedy?() click to toggle source
# File lib/pattern-match/core.rb, line 185
def greedy?
  @is_greedy
end
inspect() click to toggle source
# File lib/pattern-match/core.rb, line 189
def inspect
  "#<#{self.class.name}: min_k=#{@min_k}, is_greedy=#{@is_greedy}>"
end
match(vals) click to toggle source
# File lib/pattern-match/core.rb, line 177
def match(vals)
  if @next
    @next.match(vals)
  else
    vals.empty?
  end
end
quantifier?() click to toggle source
# File lib/pattern-match/core.rb, line 173
def quantifier?
  true
end
validate() click to toggle source
Calls superclass method PatternMatch::Pattern#validate
# File lib/pattern-match/core.rb, line 163
def validate
  super
  raise MalformedPatternError unless @prev and ! @prev.quantifier?
  raise MalformedPatternError unless @parent.kind_of?(HasOrderedSubPatterns)
  seqs = ancestors.grep(PatternSequence).reverse
  if seqs.any? {|i| i.next and i.next.quantifier? and not i.vars.empty? }
    raise NotImplementedError
  end
end