class Racc::States

def generate_states(state)

def generate_states(state)
  puts "dstate: #{state}" if @d_state
  table = {}
  state.closure.each do |ptr|
    if sym = ptr.dereference
      addsym table, sym, ptr.next
    end
  end
  table.each do |sym, core|
    puts "dstate: sym=#{sym} ncore=#{core}" if @d_state
    dest = core_to_state(core.to_a)
    state.goto_table[sym] = dest
    id = sym.nonterminal?() ? @gotos.size : nil
    g = Goto.new(id, sym, state, dest)
    @gotos.push g if sym.nonterminal?
    state.gotos[sym] = g
    puts "dstate: #{state.ident} --#{sym}--> #{dest.ident}" if @d_state
    # check infinite recursion
    if state.ident == dest.ident and state.closure.size == 1
      raise CompileError,
          sprintf("Infinite recursion: state %d, with rule %d",
                  state.ident, state.ptrs[0].rule.ident)
    end
  end
end