Beispiel #1
0
 def process_item(self):
     clsname = self.__class__.__name__.lower()
     item = self.item
     line = item.get_line()
     m = self.match(line)
     i = line.lower().find(clsname)
     assert i != -1, ` clsname, line `
     self.prefix = line[:i].rstrip()
     self.name = line[i:m.end()].lstrip()[len(clsname):].strip()
     line = line[m.end():].lstrip()
     args = []
     if line.startswith('('):
         i = line.find(')')
         assert i != -1, ` line `
         line2 = item.apply_map(line[:i + 1])
         for a in line2[1:-1].split(','):
             a = a.strip()
             if not a: continue
             args.append(a)
         line = line[i + 1:].lstrip()
     suffix = item.apply_map(line)
     self.bind, suffix = parse_bind(suffix, item)
     self.result = None
     if isinstance(self, Function):
         self.result, suffix = parse_result(suffix, item)
         if suffix:
             assert self.bind is None, ` self.bind `
             self.bind, suffix = parse_result(suffix, item)
         if self.result is None:
             self.result = self.name
     assert not suffix, ` suffix `
     self.args = args
     self.typedecl = None
     return BeginStatement.process_item(self)
Beispiel #2
0
 def process_item(self):
     clsname = self.__class__.__name__.lower()
     item = self.item
     line = item.get_line()
     m = self.match(line)
     i = line.lower().find(clsname)
     assert i!=-1,`clsname, line`
     self.prefix = line[:i].rstrip()
     self.name = line[i:m.end()].lstrip()[len(clsname):].strip()
     line = line[m.end():].lstrip()
     args = []
     if line.startswith('('):
         i = line.find(')')
         assert i!=-1,`line`
         line2 = item.apply_map(line[:i+1])
         for a in line2[1:-1].split(','):
             a=a.strip()
             if not a: continue
             args.append(a)
         line = line[i+1:].lstrip()
     suffix = item.apply_map(line)
     self.bind, suffix = parse_bind(suffix, item)
     self.result = None
     if isinstance(self, Function):
         self.result, suffix = parse_result(suffix, item)
         if suffix:
             assert self.bind is None,`self.bind`
             self.bind, suffix = parse_result(suffix, item)
         if self.result is None:
             self.result = self.name
     assert not suffix,`suffix`
     self.args = args
     self.typedecl = None
     return BeginStatement.process_item(self)
Beispiel #3
0
    def analyze(self):
        for spec in self.specs:
            i = spec.find('(')
            if i != -1:
                assert spec.endswith(')'), ` spec `
                s = spec[:i].rstrip().upper()
                n = spec[i + 1:-1].strip()
                if s == 'EXTENDS':
                    self.a.extends = n
                    continue
                elif s == 'BIND':
                    args, rest = parse_bind(spec)
                    assert not rest, ` rest `
                    spec = 'BIND(%s)' % (', '.join(args))
                else:
                    spec = '%s(%s)' % (s, n)
            else:
                spec = spec.upper()
            self.update_attributes(spec)

        component_names = self.a.component_names
        content = self.content[:]
        while content:
            stmt = content.pop(0)
            if isinstance(stmt, self.end_stmt_cls):
                break
            stmt.analyze()

        if content:
            logging.info('Not analyzed content: %s' % content)
            # self.show_message('Not analyzed content: %s' % content)

        parameters = self.a.parameters
        components = self.a.components
        component_names = self.a.component_names
        for name in self.a.variable_names:
            var = self.a.variables[name]
            if name in self.params:
                parameters[name] = var
            else:
                component_names.append(name)
                components[name] = var

        self.parent.a.type_decls[self.name] = self

        parent_provides = self.parent.get_provides()
        if parent_provides is not None:
            if self.is_public():
                if self.name in parent_provides:
                    self.warning(
                        'type declaration name conflict with %s, overriding.' %
                        (self.name))
                parent_provides[self.name] = self

        return
Beispiel #4
0
    def analyze(self):
        for spec in self.specs:
            i = spec.find('(')
            if i!=-1:
                assert spec.endswith(')'),`spec`
                s = spec[:i].rstrip().upper()
                n = spec[i+1:-1].strip()
                if s=='EXTENDS':
                    self.a.extends = n
                    continue
                elif s=='BIND':
                    args,rest = parse_bind(spec)
                    assert not rest,`rest`
                    spec = 'BIND(%s)' % (', '.join(args))
                else:
                    spec = '%s(%s)' % (s,n)
            else:
                spec = spec.upper()
            self.update_attributes(spec)

        component_names = self.a.component_names
        content = self.content[:]
        while content:
            stmt = content.pop(0)
            if isinstance(stmt, self.end_stmt_cls):
                break
            stmt.analyze()

        if content:
            logging.info('Not analyzed content: %s' % content)
            # self.show_message('Not analyzed content: %s' % content)

        parameters = self.a.parameters
        components = self.a.components
        component_names = self.a.component_names
        for name in self.a.variable_names:
            var = self.a.variables[name]
            if name in self.params:
                parameters[name] = var
            else:
                component_names.append(name)
                components[name] = var

        self.parent.a.type_decls[self.name] = self

        parent_provides = self.parent.get_provides()
        if parent_provides is not None:
            if self.is_public():
                if self.name in parent_provides:
                    self.warning('type declaration name conflict with %s, overriding.' % (self.name))
                parent_provides[self.name] = self

        return