From 4d11fdfa180f9e1412b18278c95b17d2040ea67f Mon Sep 17 00:00:00 2001 From: Pearu Peterson Date: Mon, 30 Oct 2006 19:21:25 +0000 Subject: F2PY: Cont. unifying Fortran stmt and expr parsers. --- numpy/f2py/lib/parser/api.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'numpy/f2py/lib/parser/api.py') 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 - - -- cgit v1.2.1