class RuboCop::AST::NodePattern::Compiler::SequenceSubcompiler

def compile_captured_repetition(child_code, child_captures)

def compile_captured_repetition(child_code, child_captures)
  captured_range = "#{compiler.captures - child_captures}...#{compiler.captures}"
  captured = "captures[#{captured_range}]"
  compiler.with_temp_variables do |accumulate|
    code = "#{child_code} && #{accumulate}.push(#{captured})"
    <<~RUBY
      (#{accumulate} = Array.new) &&
      #{compile_loop(code)} &&
      (#{captured} = if #{accumulate}.empty?
        (#{captured_range}).map{[]} # Transpose hack won't work for empty case
      else
        #{accumulate}.transpose
      end) \\
    RUBY
  end
end