module Raabro::ModuleMethods

def rep(name, input, parser, min, max=0)

def rep(name, input, parser, min, max=0)
  min = 0 if min == nil || min < 0
  max = nil if max.nil? || max < 1
  r = ::Raabro::Tree.new(name, :rep, input)
  start = input.offset
  count = 0
  loop do
    c = _parse(parser, input)
    r.children << c
    break if c.result != 1
    count += 1
    break if c.length < 1
    break if max && count == max
  end
  if count >= min && (max == nil || count <= max)
    r.result = 1
    r.length = input.offset - start
  else
    input.offset = start
  end
  r.prune! if input.options[:prune]
  r
end