class Racc::StateTransitionTableGenerator

def set_table(entries, dummy, tbl, chk, ptr)

def set_table(entries, dummy, tbl, chk, ptr)
  upper = 0
  map = '-' * 10240
  # sort long to short
  entries.sort_by!.with_index {|a,i| [-a[0].size, i] }
  entries.each do |arr, chkval, expr, min, ptri|
    if upper + arr.size > map.size
      map << '-' * (arr.size + 1024)
    end
    idx = map.index(expr)
    ptr[ptri] = idx - min
    arr.each_with_index do |item, i|
      if item
        i += idx
        tbl[i] = item
        chk[i] = chkval
        map[i] = ?o
      end
    end
    upper = idx + arr.size
  end
end