class DEBUGGER__::Config

def self.parse_config_value name, valstr

def self.parse_config_value name, valstr
  return valstr unless valstr.kind_of? String
  case CONFIG_SET[name][2]
  when :bool
    case valstr
    when '1', 'true', 'TRUE', 'T'
      true
    else
      false
    end
  when :int
    valstr.to_i
  when :loglevel
    if DEBUGGER__::LOG_LEVELS[s = valstr.to_sym]
      s
    else
      raise "Unknown loglevel: #{valstr}"
    end
  when :forkmode
    case sym = valstr.to_sym
    when :parent, :child, :both, nil
      sym
    else
      raise "unknown fork mode: #{sym}"
    end
  when :path # array of String
    valstr.split(/:/).map{|e|
      if /\A\/(.+)\/\z/ =~ e
        Regexp.compile $1
      else
        e
      end
    }
  when :path_map
    valstr.split(',').map{|e| e.split(':')}
  else
    valstr
  end
end