class Racc::States

def resolve_sr(state, s)

def resolve_sr(state, s)
  s.each do |stok|
    goto = state.goto_table[stok]
    act = state.action[stok]
    unless act
      # no conflict
      state.action[stok] = @actions.shift(goto)
    else
      unless act.kind_of?(Reduce)
        puts 'DEBUG -------------------------------'
        p stok
        p act
        state.action.each do |k,v|
          print k.inspect, ' ', v.inspect, "\n"
        end
        raise "racc: fatal: #{act.class} in action table"
      end
      # conflict on stok
      rtok = act.rule.precedence
      case do_resolve_sr(stok, rtok)
      when :Reduce
        # action is already set
      when :Shift
        # overwrite
        act.decref
        state.action[stok] = @actions.shift(goto)
      when :Error
        act.decref
        state.action[stok] = @actions.error
      when :CantResolve
        # shift as default
        act.decref
        state.action[stok] = @actions.shift(goto)
        state.sr_conflict stok, act.rule
      end
    end
  end
end