예제 #1
0
    def __init__(self,
                 id,
                 composing,
                 source_types,
                 target_types_and_names,
                 requirements=[]):
        assert (not isinstance(source_types, str))
        assert (not isinstance(target_types_and_names, str))
        self.id_ = id
        self.composing_ = composing
        self.source_types_ = source_types
        self.target_types_and_names_ = target_types_and_names
        self.requirements_ = requirements

        self.target_types_ = []
        self.name_prefix_ = []
        self.name_postfix_ = []

        for e in target_types_and_names:
            # Create three parallel lists: one with the list of target types,
            # and two other with prefixes and postfixes to be added to target
            # name. We use parallel lists for prefix and postfix (as opposed
            # to mapping), because given target type might occur several times,
            # for example "H H(%_symbols)".
            m = _re_separate_types_prefix_and_postfix.match(e)

            if not m:
                raise BaseException(
                    "Invalid type and name '%s' in declaration of type '%s'" %
                    (e, id))

            target_type = m.group(1)
            if not target_type: target_type = ''
            prefix = m.group(3)
            if not prefix: prefix = ''
            postfix = m.group(4)
            if not postfix: postfix = ''

            self.target_types_.append(target_type)
            self.name_prefix_.append(prefix)
            self.name_postfix_.append(postfix)

        for x in self.source_types_:
            type.validate(x)

        for x in self.target_types_:
            type.validate(x)
예제 #2
0
    def __init__ (self, id, composing, source_types, target_types_and_names, requirements = []):
        assert(not isinstance(source_types, str))
        assert(not isinstance(target_types_and_names, str))
        self.id_ = id
        self.composing_ = composing
        self.source_types_ = source_types
        self.target_types_and_names_ = target_types_and_names
        self.requirements_ = requirements
        
        self.target_types_ = []
        self.name_prefix_ = []
        self.name_postfix_ = []
        
        for e in target_types_and_names:
            # Create three parallel lists: one with the list of target types,
            # and two other with prefixes and postfixes to be added to target 
            # name. We use parallel lists for prefix and postfix (as opposed
            # to mapping), because given target type might occur several times,
            # for example "H H(%_symbols)".
            m = _re_separate_types_prefix_and_postfix.match (e)
            
            if not m:
                raise BaseException ("Invalid type and name '%s' in declaration of type '%s'" % (e, id))
            
            target_type = m.group (1)
            if not target_type: target_type = ''
            prefix = m.group (3)
            if not prefix: prefix = ''
            postfix = m.group (4)
            if not postfix: postfix = ''
            
            self.target_types_.append (target_type)
            self.name_prefix_.append (prefix)
            self.name_postfix_.append (postfix)

        for x in self.source_types_:
            type.validate (x)

        for x in self.target_types_:
            type.validate (x)