# File lib/multimethod/signature.rb, line 108
    def scan_string(str, need_names = true)

      str.sub!(/\A\s+/, '')

      if @mod && md = /\Adef\s+(self\.)?([^\s\(]+)/.match(str)
        str = md.post_match
        @class_method = ! ! md[1]
        @name = md[2]
      elsif @mod && md = /\A(self\.)?([^\s\(]+)/.match(str)
        str = md.post_match
        @class_method = ! ! md[1]
        @name = md[2]
      elsif md = /\A(\w+(::\w+)*)#([^\s\(]+)/.match(str)
        str = md.post_match
        @mod = md[1] unless @mod
        @name = md[3]
      elsif md = /\A(\w+(::\w+)*)\.([^\s\(]+)/.match(str)
        str = md.post_match
        @mod = md[1] unless @mod
        @class_method = true
        @name = md[3]
      elsif md = /\A((\w+(::\w+)*)\s+)?def\s+(self\.)?([^\s\(]+)/.match(str)
        str = md.post_match
        @mod = md[2] unless @mod
        @class_method = ! ! md[4]
        @name = md[5]
      else
        raise NameError, "Syntax error in multimethod signature at #{str.inspect}"
      end

      # Resolve mod name.
      # FIXME!

      # Add self parameter.
      add_self

      # Parse parameter list.
      if md = /\A\(/.match(str)
        str = md.post_match

        str = scan_parameters_string(str, need_names)

        $stderr.puts "  str=#{str.inspect}" if @verbose

        if md = /\A\)/.match(str)
          str = md.post_match
        else
          raise NameError, "Syntax error in multimethod parameters expected ')' at #{str.inspect}"
        end
      end
      
      str
    end