diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2006-09-16 05:56:18 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2006-09-16 05:56:18 +0000 |
commit | 617b46e97017ca4614d04090db5c7d999d1be422 (patch) | |
tree | 31fe8bd3b9a28b01d233eceae83735631789ee9b /numpy/f2py/lib/utils.py | |
parent | 8b6db6e885dec95dda7bbe2001d95bdee63e6cf1 (diff) | |
download | numpy-617b46e97017ca4614d04090db5c7d999d1be422.tar.gz |
4G f2py: first working example.
Diffstat (limited to 'numpy/f2py/lib/utils.py')
-rw-r--r-- | numpy/f2py/lib/utils.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/f2py/lib/utils.py b/numpy/f2py/lib/utils.py index 7a194c9c7..bdd838596 100644 --- a/numpy/f2py/lib/utils.py +++ b/numpy/f2py/lib/utils.py @@ -74,6 +74,8 @@ def parse_result(line, item = None): return name, line[i+1:].lstrip() def filter_stmts(content, classes): + """ Pop and return classes instances from content. + """ stmts = [] indices = [] for i in range(len(content)): @@ -123,3 +125,30 @@ def get_module_file(name, directory, _cache={}): return fn f.close() return + +def str2stmt(string, isfree=True, isstrict=False): + """ Convert Fortran code to Statement tree. + """ + from readfortran import Line, FortranStringReader + from parsefortran import FortranParser + reader = FortranStringReader(string, isfree, isstrict) + parser = FortranParser(reader) + parser.parse() + parser.analyze() + block = parser.block + while len(block.content)==1: + block = block.content[0] + return block + +def get_char_bit(): + import numpy + one = numpy.ubyte(1) + two = numpy.ubyte(2) + n = numpy.ubyte(2) + i = 1 + while n>=two: + n <<= one + i += 1 + return i + +CHAR_BIT = get_char_bit() |