diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2006-10-30 19:21:25 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2006-10-30 19:21:25 +0000 |
commit | 4d11fdfa180f9e1412b18278c95b17d2040ea67f (patch) | |
tree | 344aa6b2f311dfcc2560faf4a71f9a0e77f95869 /numpy/f2py/lib/parser/splitline.py | |
parent | 693762bb8378a9977ccc1367e5e03d352f90f7cb (diff) | |
download | numpy-4d11fdfa180f9e1412b18278c95b17d2040ea67f.tar.gz |
F2PY: Cont. unifying Fortran stmt and expr parsers.
Diffstat (limited to 'numpy/f2py/lib/parser/splitline.py')
-rw-r--r-- | numpy/f2py/lib/parser/splitline.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/f2py/lib/parser/splitline.py b/numpy/f2py/lib/parser/splitline.py index cceeadd90..b933602d4 100644 --- a/numpy/f2py/lib/parser/splitline.py +++ b/numpy/f2py/lib/parser/splitline.py @@ -30,6 +30,17 @@ def split2(line, lower=False): _f2py_str_findall = re.compile(r"_F2PY_STRING_CONSTANT_\d+_").findall _is_name = re.compile(r'\w*\Z',re.I).match _is_simple_str = re.compile(r'\w*\Z',re.I).match +_f2py_findall = re.compile(r'(_F2PY_STRING_CONSTANT_\d+_|F2PY_EXPR_TUPLE_\d+)').findall + +class string_replace_dict(dict): + """ + Dictionary object that is callable for applying map returned + by string_replace_map() function. + """ + def __call__(self, line): + for k in _f2py_findall(line): + line = line.replace(k, self[k]) + return line def string_replace_map(line, lower=False, _cache={'index':0,'pindex':0}): @@ -39,7 +50,7 @@ def string_replace_map(line, lower=False, Returns a new line and the replacement map. """ items = [] - string_map = {} + string_map = string_replace_dict() rev_string_map = {} for item in splitquote(line, lower=lower)[0]: if isinstance(item, String) and not _is_simple_str(item[1:-1]): |