Ejemplo n.º 1
0
    def analyze(self):
        BeginStatement.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:
            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 parent_provides.has_key(self.name):
        #            self.warning('type declaration name conflict with %s, overriding.' % (self.name))
        #        parent_provides[self.name] = self

        return
Ejemplo n.º 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)
Ejemplo n.º 3
0
 def process_item(self):
     item = self.item
     line = item.get_line()[2:-4].strip()
     assert line[0] == '(' and line[-1] == ')', ` line `
     self.expr = item.apply_map(line[1:-1].strip())
     self.construct_name = item.name
     return BeginStatement.process_item(self)
Ejemplo n.º 4
0
 def process_item(self):
     if self.item is not None:
         name = self.item.get_line().replace(' ','')\
                [len(self.blocktype):].strip()
         if name:
             self.name = name
     return BeginStatement.process_item(self)
Ejemplo n.º 5
0
 def process_item(self):
     if self.item is not None:
         name = self.item.get_line().replace(' ','')\
                [len(self.blocktype):].strip()
         if name:
             self.name = name
     return BeginStatement.process_item(self)
Ejemplo n.º 6
0
 def process_item(self):
     line = self.item.get_line()[4:].lstrip()
     if line.startswith('('):
         self.isvalid = False
         return
     specs = []
     i = line.find('::')
     if i != -1:
         for s in line[:i].split(','):
             s = s.strip()
             if s: specs.append(s)
         line = line[i + 2:].lstrip()
     self.specs = specs
     i = line.find('(')
     if i != -1:
         self.name = line[:i].rstrip()
         assert line[-1] == ')', ` line `
         self.params = split_comma(line[i + 1:-1].lstrip())
     else:
         self.name = line
         self.params = []
     if not is_name(self.name):
         self.isvalid = False
         return
     return BeginStatement.process_item(self)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
 def process_item(self):
     line = self.item.get_line()[4:].lstrip()
     if line.startswith('('):
         self.isvalid = False
         return
     specs = []
     i = line.find('::')
     if i!=-1:
         for s in line[:i].split(','):
             s = s.strip()
             if s: specs.append(s)
         line = line[i+2:].lstrip()
     self.specs = specs
     i = line.find('(')
     if i!=-1:
         self.name = line[:i].rstrip()
         assert line[-1]==')',`line`
         self.params = split_comma(line[i+1:-1].lstrip())
     else:
         self.name = line
         self.params = []
     if not is_name(self.name):
         self.isvalid = False
         return
     return BeginStatement.process_item(self)
Ejemplo n.º 9
0
 def process_item(self):
     item = self.item
     line = item.get_line()[2:-4].strip()
     assert line[0]=='(' and line[-1]==')',`line`
     self.expr = line[1:-1].strip()
     self.name = item.label
     return BeginStatement.process_item(self)
Ejemplo n.º 10
0
 def process_item(self):
     item = self.item
     line = item.get_line()[2:-4].strip()
     assert line[0]=='(' and line[-1]==')',`line`
     self.expr = line[1:-1].strip()
     self.construct_name = item.name
     return BeginStatement.process_item(self)
Ejemplo n.º 11
0
 def process_item(self):
     item = self.item
     line = item.get_line()
     m = self.item_re(line)
     self.endlabel = m.group('label').strip()
     self.name = item.label
     self.loopcontrol = m.group('loopcontrol').strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 12
0
 def process_item(self):
     line = self.item.get_line()
     self.isabstract = line.startswith('abstract')
     if self.isabstract:
         self.generic_spec = ''
     else:
         self.generic_spec = line[len(self.blocktype):].strip()
     self.name = self.generic_spec # XXX
     return BeginStatement.process_item(self)
Ejemplo n.º 13
0
 def process_item(self):
     line = self.item.get_line()
     self.isabstract = line.startswith('abstract')
     if self.isabstract:
         self.generic_spec = ''
     else:
         self.generic_spec = line[len(self.blocktype):].strip()
     self.name = self.generic_spec # XXX
     return BeginStatement.process_item(self)
Ejemplo n.º 14
0
 def process_subitem(self, item):
     r = False
     if self.endlabel:
         label = item.label
         if label == self.endlabel:
             r = True
             if isinstance(self.parent, Do) and label==self.parent.endlabel:
                 # the same item label may be used for different block ends
                 self.put_item(item)
     return BeginStatement.process_subitem(self, item) or r
Ejemplo n.º 15
0
 def process_subitem(self, item):
     r = False
     if self.endlabel:
         label = item.label
         if label == self.endlabel:
             r = True
             if isinstance(self.parent, Do) and label==self.parent.endlabel:
                 # the same item label may be used for different block ends
                 self.put_item(item)
     return BeginStatement.process_subitem(self, item) or r
Ejemplo n.º 16
0
 def process_item(self):
     item = self.item
     line = item.get_line()
     m = self.item_re(line)
     label = m.group('label').strip() or None
     if label:
         label = int(label)
     self.endlabel = label
     self.construct_name = item.name
     self.loopcontrol = m.group('loopcontrol').strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 17
0
 def process_item(self):
     item = self.item
     line = item.get_line()
     m = self.item_re(line)
     label = m.group('label').strip() or None
     if label:
         label = int(label)
     self.endlabel = label
     self.construct_name = item.name
     self.loopcontrol = m.group('loopcontrol').strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 18
0
 def process_subitem(self, item):
     # MAIN block does not define start/end line conditions,
     # so it should never end until all lines are read.
     # However, sometimes F77 programs lack the PROGRAM statement,
     # and here we fix that:
     if self.reader.isfix77:
         line = item.get_line()
         if line=='end':
             message = item.reader.format_message(\
                     'WARNING',
                     'assuming the end of undefined PROGRAM statement',
                     item.span[0],item.span[1])
             print >> sys.stderr, message
             p = Program(self)
             p.content.extend(self.content)
             p.content.append(EndProgram(p,item))
             self.content[:] = [p]
             return
     return BeginStatement.process_subitem(self, item)
Ejemplo n.º 19
0
 def process_item(self):
     self.expr = self.item.get_line()[5:].lstrip()[1:-1].strip()
     self.construct_name = self.item.name
     return BeginStatement.process_item(self)
Ejemplo n.º 20
0
 def process_item(self):
     self.name = self.item.get_line()[5:].lstrip()[4:].lstrip()
     return BeginStatement.process_item(self)
Ejemplo n.º 21
0
 def process_item(self):
     line = self.item.get_line()[9:].lstrip()
     self.associations = line[1:-1].strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 22
0
 def process_item(self):
     self.name = self.item.get_line().replace(' ','')\
                 [len(self.blocktype):].strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 23
0
 def process_item(self):
     return BeginStatement.process_item(self)
Ejemplo n.º 24
0
 def process_item(self):
     return BeginStatement.process_item(self)
Ejemplo n.º 25
0
 def tofortran(self, isfix=None):
     if isfix:
         tab = 'C'
     else:
         tab = self.get_indent_tab(isfix=isfix) + '!'
     return tab + BeginStatement.tofortran(self, isfix=isfix)
Ejemplo n.º 26
0
 def process_item(self):
     line = self.item.get_line()[9:].lstrip()
     self.associations = line[1:-1].strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 27
0
 def tofortran(self,isfix=None):
     if isfix:
         tab = 'C'
     else:
         tab = self.get_indent_tab(isfix=isfix) + '!'
     return tab + BeginStatement.tofortran(self, isfix=isfix)
Ejemplo n.º 28
0
 def process_item(self):
     self.name = self.item.get_line().replace(' ','')\
                 [len(self.blocktype):].strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 29
0
 def process_item(self):
     self.name = self.item.get_line()[5:].lstrip()[4:].lstrip()
     return BeginStatement.process_item(self)
Ejemplo n.º 30
0
 def process_item(self):
     self.specs = self.item.get_line()[6:].lstrip()[1:-1].strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 31
0
 def process_item(self):
     self.expr = self.item.get_line()[6:].lstrip()[4:].lstrip()[1:-1].strip()
     self.name = self.item.label
     return BeginStatement.process_item(self)
Ejemplo n.º 32
0
 def process_item(self):
     self.specs = self.item.get_line()[6:].lstrip()[1:-1].strip()
     return BeginStatement.process_item(self)
Ejemplo n.º 33
0
 def process_item(self):
     self.expr = self.item.get_line()[5:].lstrip()[1:-1].strip()
     self.construct_name = self.item.name
     return BeginStatement.process_item(self)
Ejemplo n.º 34
0
 def process_item(self):
     self.expr = self.item.apply_map(self.item.get_line()[5:].lstrip()[1:-1].strip()) # OC addition
     #self.expr = self.item.get_line()[5:].lstrip()[1:-1].strip() # OC deletion
     self.construct_name = self.item.name
     return BeginStatement.process_item(self)