From ec1662fb0182a87ebf39ec476109becfc7a8cdb1 Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Fri, 30 Jun 2006 13:36:13 +0000 Subject: Writting parser unittests, fixed bugs. --- numpy/f2py/lib/readfortran.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'numpy/f2py/lib/readfortran.py') diff --git a/numpy/f2py/lib/readfortran.py b/numpy/f2py/lib/readfortran.py index b275d220f..add45e71c 100644 --- a/numpy/f2py/lib/readfortran.py +++ b/numpy/f2py/lib/readfortran.py @@ -51,7 +51,7 @@ class Line: """ Holds a Fortran source line. """ - f2py_strmap_findall = re.compile(r'( _F2PY_STRING_CONSTANT_\d+_ |\(F2PY_EXPR_TUPLE_\d+\))').findall + f2py_strmap_findall = re.compile(r'(_F2PY_STRING_CONSTANT_\d+_|F2PY_EXPR_TUPLE_\d+)').findall def __init__(self, line, linenospan, label, reader): self.line = line.strip() @@ -61,8 +61,12 @@ class Line: self.strline = None self.is_f2py_directive = linenospan[0] in reader.f2py_comment_lines + def has_map(self): + return not not (hasattr(self,'strlinemap') and self.strlinemap) + def apply_map(self, line): - if not hasattr(self,'strlinemap'): return line + if not hasattr(self,'strlinemap') or not self.strlinemap: + return line findall = self.f2py_strmap_findall str_map = self.strlinemap keys = findall(line) -- cgit v1.2.1