# File lib/Getopt/Declare.rb, line 612
    def code(*t)
      owner = t[0]
      mod   = t[1]


      code = "\n"
      flag = @flag
      clump = owner.clump
      i = 0
      nocasei = ((Getopt::Declare::nocase || @nocase) ? 'i' : '')

      code << "          catch(:paramout) do\n"
      code += !@repeatable? "            while !_FOUND_['" + self.foundid + "']" :
                            "            while 1"
      if (flag && (clump==1 && flag !~ /\A[^a-z0-9]+[a-z0-9]\Z/i ||
                   (clump<3 && @args.size > 0 )))
        code << " && !_lastprefix"
      end

      code << '
              begin
                catch(:param) do
                  _pos = _nextpos if _args
                  _PUNCT_ = {}
              '

      if flag != ''
        # This boundary is to handle -- option, so that if user uses

        # --foo and --foo is not a flag, it does not become

        # --  and unused: 'foo', but an error saying flag '--foo' not defined.

        boundary = ''
        boundary = '(\s+|\Z)' if flag =~ /^(--|-|\+|\+\+)$/

        code << '
                  _args && _pos = gindex( _args, /\G[\s|\0]*' + 
          Regexp::quote(flag) + boundary + '/' + nocasei + ", _pos) or throw(:paramout) 
                  unless @_errormsg
                    @_errormsg = %q|incorrect specification of '" + flag + "' parameter|
                  end
"
      elsif ( ScalarArg::stdtype(@args[0].type)||'') !~ /\%F/
        code << "\n                  throw(:paramout) if @_errormsg\n"
      end


      code << "\n                  _PARAM_ = '" + self.name + "'\n"


      trailer = []
      i = @args.size-1
      while i > 0
        trailer[i-1] = @args[i].trailer
        trailer[i-1] = trailer[i] unless trailer[i-1]
        i -= 1
      end # while i


      if @args
        code << "\n"+'                 _args && _pos = gindex( _args, /\G'

        @args.each_with_index { |arg, i|
          code << arg.ows(arg.matcher(trailer[i]))
        }

        code << '/x' + nocasei + ", _pos ) or throw(:paramout)\n"
      end # if @args


      @args.each_with_index { |arg, i|
        code << arg.code(i,mod)        #, $flag ????

      }

      if flag
        mutexlist = owner.mutex[flag] ? 
        (  owner.mutex[flag].map {|i| "'#{i}'"} ).join(',') : ''

        code << "
                  if _invalid.has_key?('#{flag}')
                    @_errormsg = %q|parameter '#{flag}' not allowed with parameter '| + _invalid['#{flag}'] + %q|'|
                    throw(:paramout)
                  else
                    for i in [#{mutexlist}]
                        _invalid[i] = '#{flag}'
                    end
                  end  #if/then

"
      end



      for action in @actions
        #action.sub!( /(\s*\{)/, '\1 module '+mod )  # @TODO

        code << "\n                  " + action + "\n"
      end

      if flag && @items==0
        code << "\n                  @cache['#{flag}'] = '#{flag}'\n"
        if @ditto
          code << "\n                  @cache['#{@ditto.flag}'] = '#{flag}'\n"
        end
      end

      if @items > 1
        code << "                  @cache['#{self.name}'] = {} unless @cache['#{self.name}'].kind_of?(Hash)\n"
        if @ditto
          code << "\n                  @cache['#{@ditto.name}'] = {} unless @cache['#{@ditto.name}'].kind_of?(Hash)\n"
        end
      end

      for subarg in @args
        code << subarg.cachecode(self.name,@items)
        if ditto
        code << subarg.cachecode(@ditto.name,@items)
        end
      end

      if flag =~ /\A([^a-z0-9]+)/i
        code << '                  _lastprefix = "'+ Regexp::quote("#$1") + '"' + "\n"
      else
        code << "                  _lastprefix = nil\n"
      end

      code << "
                  _FOUND_['"+ self.foundid + "'] = 1
                  throw :arg if _pos > 0
                  _nextpos = _args.size
                  throw :alldone
                end  # catch(:param)
              end  # begin
            end # while
          end # catch(:paramout)
"

      code
    end