diff options
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 - - |