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/api.py | |
parent | 693762bb8378a9977ccc1367e5e03d352f90f7cb (diff) | |
download | numpy-4d11fdfa180f9e1412b18278c95b17d2040ea67f.tar.gz |
F2PY: Cont. unifying Fortran stmt and expr parsers.
Diffstat (limited to 'numpy/f2py/lib/parser/api.py')
-rw-r--r-- | numpy/f2py/lib/parser/api.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/numpy/f2py/lib/parser/api.py b/numpy/f2py/lib/parser/api.py index 4b3ea88fa..bc99f94d7 100644 --- a/numpy/f2py/lib/parser/api.py +++ b/numpy/f2py/lib/parser/api.py @@ -18,17 +18,7 @@ from block_statements import * # CHAR_BIT is used to convert object bit sizes to byte sizes from utils import CHAR_BIT -def parse(input, isfree=None, isstrict=None, include_dirs = None): - """ Parse input and return Statement tree. - - input --- string or filename. - isfree, isstrict --- specify input Fortran format. - Defaults are True, False, respectively, or - determined from input. - include_dirs --- list of include directories. - Default contains current working directory - and the directory of file name. - """ +def get_reader(input, isfree=None, isstrict=None, include_dirs = None): import os import re from readfortran import FortranFileReader, FortranStringReader @@ -61,9 +51,21 @@ def parse(input, isfree=None, isstrict=None, include_dirs = None): include_dirs = include_dirs) else: raise TypeError,'Expected string or filename input but got %s' % (type(input)) + return reader + +def parse(input, isfree=None, isstrict=None, include_dirs = None): + """ Parse input and return Statement tree. + + input --- string or filename. + isfree, isstrict --- specify input Fortran format. + Defaults are True, False, respectively, or + determined from input. + include_dirs --- list of include directories. + Default contains current working directory + and the directory of file name. + """ + reader = get_reader(input, isfree, isstrict, include_dirs) parser = FortranParser(reader) parser.parse() parser.analyze() return parser.block - - |