summaryrefslogtreecommitdiff
path: root/numpy/f2py/lib/parser/api.py
diff options
context:
space:
mode:
authorRobert Kern <robert.kern@gmail.com>2008-07-03 19:57:24 +0000
committerRobert Kern <robert.kern@gmail.com>2008-07-03 19:57:24 +0000
commit484c100392601f4942ceecbedf32e6df0201d473 (patch)
tree5e5a58b30a39bd1b5481333ae4a4b9c34e466841 /numpy/f2py/lib/parser/api.py
parent0c817a5d51c2c16db9df5c015ff846002d991d74 (diff)
downloadnumpy-484c100392601f4942ceecbedf32e6df0201d473.tar.gz
Removing G3 f2py code. Development has moved to https://launchpad.net/f2py/
Diffstat (limited to 'numpy/f2py/lib/parser/api.py')
-rw-r--r--numpy/f2py/lib/parser/api.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/numpy/f2py/lib/parser/api.py b/numpy/f2py/lib/parser/api.py
deleted file mode 100644
index 476c142e5..000000000
--- a/numpy/f2py/lib/parser/api.py
+++ /dev/null
@@ -1,73 +0,0 @@
-"""
-Public API for Fortran parser.
-
------
-Permission to use, modify, and distribute this software is given under the
-terms of the NumPy License. See http://scipy.org.
-
-NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
-Author: Pearu Peterson <pearu@cens.ioc.ee>
-Created: Oct 2006
------
-"""
-
-import Fortran2003
-# import all Statement classes:
-from base_classes import EndStatement
-from block_statements import *
-
-# CHAR_BIT is used to convert object bit sizes to byte sizes
-from utils import CHAR_BIT
-
-def get_reader(input, isfree=None, isstrict=None, include_dirs = None):
- import os
- import re
- from readfortran import FortranFileReader, FortranStringReader
- from parsefortran import FortranParser
- if os.path.isfile(input):
- name,ext = os.path.splitext(input)
- if ext.lower() in ['.c']:
- # get signatures from C file comments starting with `/*f2py` and ending with `*/`.
- # TODO: improve parser to take line number offset making line numbers in
- # parser messages correct.
- f2py_c_comments = re.compile('/[*]\s*f2py\s.*[*]/',re.I | re.M)
- f = open(filename,'r')
- c_input = ''
- for s1 in f2py_c_comments.findall(f.read()):
- c_input += s1[2:-2].lstrip()[4:] + '\n'
- f.close()
- if isfree is None: isfree = True
- if isstrict is None: isstrict = True
- return parse(c_input, isfree, isstrict, include_dirs)
- reader = FortranFileReader(input,
- include_dirs = include_dirs)
- if isfree is None: isfree = reader.isfree
- if isstrict is None: isstrict = reader.isstrict
- reader.set_mode(isfree, isstrict)
- elif isinstance(input, str):
- if isfree is None: isfree = True
- if isstrict is None: isstrict = False
- reader = FortranStringReader(input,
- isfree, isstrict,
- 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.
- """
- from parsefortran import FortranParser
- reader = get_reader(input, isfree, isstrict, include_dirs)
- parser = FortranParser(reader)
- parser.parse()
- parser.analyze()
- return parser.block