class KPeg::Multiple
Attributes
max[R]
min[R]
op[R]
save_values[R]
Public Class Methods
new(op, min, max)
click to toggle source
Calls superclass method
KPeg::Operator::new
# File lib/kpeg/grammar.rb, line 235 def initialize(op, min, max) super() @op = op @min = min @max = max @save_values = nil end
Public Instance Methods
==(obj)
click to toggle source
Calls superclass method
# File lib/kpeg/grammar.rb, line 278 def ==(obj) case obj when Multiple @op == obj.op and @min == obj.min and @max == obj.max else super end end
inspect()
click to toggle source
# File lib/kpeg/grammar.rb, line 287 def inspect inspect_type "multi", "#{@min} #{@max ? @max : "*"} #{@op.inspect}" end
match(x)
click to toggle source
# File lib/kpeg/grammar.rb, line 249 def match(x) n = 0 matches = [] start = x.pos while true if m = @op.match(x) matches << m else break end n += 1 if @max and n > @max x.pos = start return nil end end if n >= @min return MatchComposition.new(self, matches) end x.pos = start return nil end
save_values!()
click to toggle source
# File lib/kpeg/grammar.rb, line 245 def save_values! @save_values = true end