# File lib/multimethod/parameter.rb, line 95
    def scan_string(str, need_names = true)
      # @verbose ||= @@debug

      type = nil
      name = nil
      default = nil

      str.sub!(/\A\s+/, '')
      
      $stderr.puts "  str=#{str.inspect}" if @verbose
      
      if md = /\A(\w+(::\w+)*)\s+(\w+)/s.match(str)
        # $stderr.puts "   pre_match=#{md.pre_match.inspect}"
        # $stderr.puts "   md[0]=#{md[0].inspect}"
        str = md.post_match
        type = md[1]
        name = md[3]
      elsif md = /\A(\*?\w+)/s.match(str)
        # $stderr.puts "   pre_match=#{md.pre_match.inspect}"
        # $stderr.puts "   md[0]=#{md[0].inspect}"
        str = md.post_match
        type = nil
        name = md[1]
      else
        raise NameError, "Syntax error in multimethod parameter: expected type and/or name at #{str.inspect}"
      end
      
      $stderr.puts "  type=#{type.inspect}" if @verbose       
      $stderr.puts "  name=#{name.inspect}" if @verbose       
      
      # Parse parameter default.
      if md = /\A\s*=\s*/.match(str)
        str = md.post_match
        
        in_paren = 0
        default = ''
        until str.empty?
          # $stderr.puts "    default: str=#{str.inspect}"
          # $stderr.puts "    default: params=#{parameter_to_s}"
          
          if md = /\A(\s+)/s.match(str)
            str = md.post_match
            default = default + md[1]
          end
          
          if md = /\A("([^"\\]|\\.)*")/s.match(str)
            str = md.post_match
            default = default + md[1]
          elsif md = /\A('([^'\\]|\\.)*')/s.match(str)
            str = md.post_match
            default = default + md[1]
          elsif md = /\A(\()/.match(str)
            str = md.post_match
            in_paren = in_paren + 1
            default = default + md[1]
          elsif in_paren > 0 && md = /\A(\))/s.match(str)
            str = md.post_match
            in_paren = in_paren - 1
            default = default + md[1]
          elsif md = /\A(\))/s.match(str)
            break
          elsif in_paren == 0 && md = /\A,/s.match(str)
            break
          elsif md = /\A(\w+)/s.match(str)
            str = md.post_match
            default = default + md[1]
          elsif md = /\A(.)/s.match(str)
            str = md.post_match
            default = default + md[1] 
          end

          $stderr.puts "  default=#{default.inspect}" if @verbose       
        end
      end
      
      self.name = name unless @name
      self.type = type unless @type
      default = nil if default && default.empty?
      self.default = default unless @default

      str
    end