def build_reduce_code(self, result, select, reduce):
        """
        Builds a reduce operation on the selected target range.
        """

        select = select.replace('/', '.')
        select = select.replace(' ', '')
        if reduce == 'add':
            reduce_op = '+'
            acc_start = 0
        else:
            reduce_op = '*'
            acc_start = 1

        #bits = select.split('[*]')
        bits = re.split('\[.*\]', select)
        seps = re.findall('\[.*\]', select)

        code = ['self.{0} = {1}'.format(result, acc_start)]
        code += ['self.{0}_shadow = {1}'.format(result, acc_start)]

        code += ['try:']

        if len(bits) == 1:
            target = select
            code += ['    self.{0} = self.{1}'.format(result, target)]
            code += ['    self.{0}_shadow = self.{1}'.format(result, target)]
        elif len(bits) == 2:
            sep = seps[0][1:-1]

            if sep == '*':
                array = bits[0]
                ref = bits[1]

                code += ['    acc = {0}'.format(acc_start)]
                code += ['    for o in self.{0}:'.format(array)]
                code += ['        acc = acc {0} o{1}'.format(reduce_op, ref)]
                code += ['    self.{0} = acc'.format(result)]
                code += ['    self.{0}_shadow = acc'.format(result)]
            else:
                bits2 = sep.split('=')
                if len(bits2) > 1:
                    array = bits[0]
                    ref = bits[1]

                    code += ['    acc = {0}'.format(acc_start)]
                    code += ['    for o in self.{0}:'.format(array)]
                    code += ['        if o.{0} == {1}:'.format(bits2[0], bits2[1])]
                    code += ['            acc = acc {0} o{1}'.format(reduce_op, ref)]
                    code += ['    self.{0} = acc'.format(result)]
                    code += ['    self.{0}_shadow = acc'.format(result)]
                else:
                    raise SimbuildError("Invalid reduce target - '{0}'".format(select))
        else:
            raise SimbuildError("Invalid reduce target - '{0}'".format(select))

        code += ['except:']
        code += ['    pass']

        return code
Builds a reduce operation on the selected target range.