summaryrefslogtreecommitdiff
path: root/numpy/f2py/lib/readfortran.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2006-06-22 10:25:57 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2006-06-22 10:25:57 +0000
commitd5a5da520b1eddd10a7dde79b0e7df281ee1abaa (patch)
treef19a3ce2d0e327bc02771dee39a4b0ccea7aeccf /numpy/f2py/lib/readfortran.py
parent1fe0237f46025a44779ad98974b9a587b6aa6ac8 (diff)
downloadnumpy-d5a5da520b1eddd10a7dde79b0e7df281ee1abaa.tar.gz
Cont. impl. Fortran parser.
Diffstat (limited to 'numpy/f2py/lib/readfortran.py')
-rw-r--r--numpy/f2py/lib/readfortran.py26
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 = []