diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2006-06-22 10:25:57 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2006-06-22 10:25:57 +0000 |
commit | d5a5da520b1eddd10a7dde79b0e7df281ee1abaa (patch) | |
tree | f19a3ce2d0e327bc02771dee39a4b0ccea7aeccf /numpy/f2py/lib/readfortran.py | |
parent | 1fe0237f46025a44779ad98974b9a587b6aa6ac8 (diff) | |
download | numpy-d5a5da520b1eddd10a7dde79b0e7df281ee1abaa.tar.gz |
Cont. impl. Fortran parser.
Diffstat (limited to 'numpy/f2py/lib/readfortran.py')
-rw-r--r-- | numpy/f2py/lib/readfortran.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/numpy/f2py/lib/readfortran.py b/numpy/f2py/lib/readfortran.py index 03a64534a..1d6335865 100644 --- a/numpy/f2py/lib/readfortran.py +++ b/numpy/f2py/lib/readfortran.py @@ -51,6 +51,21 @@ class Line: self.label = label self.reader = reader self.strline = None + def copy(self, line = None, apply_map = False): + if line is None: + line = self.line + if apply_map and hasattr(self,'strlinemap'): + str_map = self.strlinemap + keys = str_map.keys() + flag = True + while flag: + flag = False + for k in keys: + if k in line: + flag = True + line = line.replace(k, str_map[k]) + assert k not in line, `k,line` + return Line(line, self.span, self.label, self.reader) def __repr__(self): return self.__class__.__name__+'(%r,%s,%r)' \ % (self.line, self.span, self.label) @@ -139,6 +154,8 @@ class FortranReaderBase: self.fifo_item = [] self.source_lines = [] + self.name = '%s mode=%s' % (source, mode) + def close_source(self): # called when self.source.next() raises StopIteration. pass @@ -208,6 +225,15 @@ class FortranReaderBase: break # else ignore empty lines and comments if not isinstance(item, Comment): + if isinstance(item, Line) and ';' in item.get_line(): + items = [] + for line in item.get_line().split(';'): + line = line.strip() + items.append(item.copy(line, apply_map=True)) + items.reverse() + for newitem in items: + self.fifo_item.insert(0, newitem) + return fifo_item_pop(0) return item # collect subsequent comments to one comment instance comments = [] |