diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2006-10-01 11:49:23 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2006-10-01 11:49:23 +0000 |
commit | c3c53e6805beb164581f041a69c9f51c2740d344 (patch) | |
tree | 70d942460a7624996b6a7ee0dd5e25c014b9772f /numpy/f2py | |
parent | 6c52e6fc05f89f13871b79074ea8891c11092d35 (diff) | |
download | numpy-c3c53e6805beb164581f041a69c9f51c2740d344.tar.gz |
F2PY G3: Moved Fortran parser related code to subpackage parser.
Diffstat (limited to 'numpy/f2py')
-rw-r--r-- | numpy/f2py/lib/analyzefortran.py | 138 | ||||
-rw-r--r-- | numpy/f2py/lib/generate_pyobj_tofrom_funcs.py | 2 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/__init__.py | 14 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/api.py | 53 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/base_classes.py (renamed from numpy/f2py/lib/base_classes.py) | 15 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/block_statements.py (renamed from numpy/f2py/lib/block_statements.py) | 24 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/doc.txt (renamed from numpy/f2py/lib/doc.txt) | 57 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/parsefortran.py (renamed from numpy/f2py/lib/parsefortran.py) | 0 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/readfortran.py (renamed from numpy/f2py/lib/readfortran.py) | 7 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/sourceinfo.py (renamed from numpy/f2py/lib/sourceinfo.py) | 18 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/splitline.py (renamed from numpy/f2py/lib/splitline.py) | 13 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/statements.py (renamed from numpy/f2py/lib/statements.py) | 26 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/test_parser.py (renamed from numpy/f2py/lib/test_parser.py) | 33 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/typedecl_statements.py (renamed from numpy/f2py/lib/typedecl_statements.py) | 12 | ||||
-rw-r--r-- | numpy/f2py/lib/parser/utils.py (renamed from numpy/f2py/lib/utils.py) | 17 | ||||
-rw-r--r-- | numpy/f2py/lib/python_wrapper.py | 14 |
16 files changed, 268 insertions, 175 deletions
diff --git a/numpy/f2py/lib/analyzefortran.py b/numpy/f2py/lib/analyzefortran.py deleted file mode 100644 index bf6fc5ee0..000000000 --- a/numpy/f2py/lib/analyzefortran.py +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env python -""" -Defines FortranAnalyzer. - -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: June 2006 -""" - -from numpy.distutils.misc_util import yellow_text, red_text - -class FortranAnalyzer: - - def __init__(self, block): - """ - block is a BeginSource instance with relevant attributes: - name - reader name - content - a list of statements - - Statements are either block statements or simple statements. - - Block statements have the following relevant attributes: - name - block name - blocktype - statement name (equal to lowered statement class name) - content - a list of statements - - Block statements may have additional attributes: - BeginSource: top - Module: - PythonModule: - Program: - BlockData: - Interface: isabstract, generic_spec - Subroutine: prefix, args, suffix - Function: prefix, typedecl, args, suffix - Select: expr - Where: expr - Forall: specs - IfThen: expr - If: expr - Do: endlabel, loopcontrol - Associate: associations - Type: specs, params - Enum: - - Simple statements have various attributes: - Assignment: variable, expr - PointerAssignment: variable, expr - Assign: items - Call: designator, items - Goto: label - ComputedGoto: items, expr - AssignedGoto: varname, items - Continue: label - Return: expr - Stop: code - Print: format, items - Read0: specs, items - Read1: format, items - Write: specs, items - Flush: specs - Wait: specs - Contains: - Allocate: spec, items - Deallocate: items - ModuleProcedure: items - Public | Private: items - Close: specs - Cycle: name - Rewind | Backspace | Endfile: specs - Open: specs - Format: specs - Save: items - Data: stmts - Nullify: items - Use: nature, name, isonly, items - Exit: name - Parameter: items - Equivalence: items - Dimension: items - Target: items - Pointer: items - Protected | Volatile | Value | Intrinsic | External | Optional: items - ArithmeticIf: expr, labels - Inquire: specs, items - Sequence: - Common: items - Intent: specs, items - Entry: name, items, result, binds - Import: items - Forall: specs, content - SpecificBinding: iname, attrs, name, bname - GenericBinding: aspec, spec, items - FinalBinding: items - Allocatable: items - Asynchronous: items - Bind: specs, items - Else: name - ElseIf: name, expr - Case: name, items - Else: name - ElseIf: name, expr - Case: name, items - Where: name, expr - ElseWhere: name, expr - Enumerator: items - FortranName: value - Threadsafe: - Depend: depends, items - Check: expr, value - CallStatement: expr - CallProtoArgument: specs - Pause: value - """ - self.block = block - print block.item - def analyze(self): - - pass - -def simple_main(): - import sys - from parsefortran import FortranParser - from readfortran import FortranFileReader - for filename in sys.argv[1:]: - reader = FortranFileReader(filename) - print yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode)) - parser = FortranParser(reader) - block = parser.parse() - analyzer = FortranAnalyzer(block) - r = analyzer.analyze() - print r - -if __name__ == "__main__": - simple_main() diff --git a/numpy/f2py/lib/generate_pyobj_tofrom_funcs.py b/numpy/f2py/lib/generate_pyobj_tofrom_funcs.py index 7f1c7aa47..b17d4a71e 100644 --- a/numpy/f2py/lib/generate_pyobj_tofrom_funcs.py +++ b/numpy/f2py/lib/generate_pyobj_tofrom_funcs.py @@ -6,7 +6,7 @@ functions. """ __all__ = ['pyobj_to_npy_scalar','pyobj_to_f2py_string','pyobj_from_npy_scalar'] -from utils import CHAR_BIT +from parser.api import CHAR_BIT def pyobj_from_npy_int(ctype): ctype_bits = int(ctype[7:]) diff --git a/numpy/f2py/lib/parser/__init__.py b/numpy/f2py/lib/parser/__init__.py new file mode 100644 index 000000000..9d707c01f --- /dev/null +++ b/numpy/f2py/lib/parser/__init__.py @@ -0,0 +1,14 @@ +""" +Tools for parsing Fortran 60/77/90/2003 codes into Statement tree. + +Use api module for importing public symbols. + +----- +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 +----- +""" diff --git a/numpy/f2py/lib/parser/api.py b/numpy/f2py/lib/parser/api.py new file mode 100644 index 000000000..efcfcbf28 --- /dev/null +++ b/numpy/f2py/lib/parser/api.py @@ -0,0 +1,53 @@ +""" +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 all Statement classes: +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. + """ + import os + from readfortran import FortranFileReader, FortranStringReader + from parsefortran import FortranParser + if os.path.isfile(input): + reader = FortranFileReader(input, + include_dirs = include_dirs) + if isfree is None: reader.isfree + if isstrict is None: 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)) + parser = FortranParser(reader) + parser.parse() + parser.analyze() + return parser.block + + diff --git a/numpy/f2py/lib/base_classes.py b/numpy/f2py/lib/parser/base_classes.py index 203cafd63..81e38ace1 100644 --- a/numpy/f2py/lib/base_classes.py +++ b/numpy/f2py/lib/parser/base_classes.py @@ -1,5 +1,16 @@ - -__all__ = ['Statement','BeginStatement','EndStatement'] +""" +----- +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: May 2006 +----- +""" + +__all__ = ['Statement','BeginStatement','EndStatement', 'Variable', + 'AttributeHolder','ProgramBlock'] import re import sys diff --git a/numpy/f2py/lib/block_statements.py b/numpy/f2py/lib/parser/block_statements.py index f1d4d40f6..1f2d33dca 100644 --- a/numpy/f2py/lib/block_statements.py +++ b/numpy/f2py/lib/parser/block_statements.py @@ -1,14 +1,27 @@ """ +Fortran block statements. +----- +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: May 2006 +----- """ +__all__ = ['BeginSource','Module','PythonModule','Program','BlockData','Interface', + 'Subroutine','Function','Select','EndWhere','WhereConstruct','ForallConstruct', + 'IfThen','If','Do','Associate','TypeDecl','Enum'] + import re import sys from base_classes import BeginStatement, EndStatement, Statement,\ - AttributeHolder, ProgramBlock + AttributeHolder, ProgramBlock, Variable from readfortran import Line -from utils import filter_stmts, parse_bind, parse_result, AnalyzeError +from utils import filter_stmts, parse_bind, parse_result, AnalyzeError, is_name class HasImplicitStmt: @@ -1024,7 +1037,7 @@ class Type(BeginStatement, HasVariables, HasAttributes): def get_c_type(self): return 'f2py_type_%s_%s' % (self.name, self.get_bit_size()) - + def get_c_name(self): return 'f2py_type_%s' % (self.name) @@ -1065,6 +1078,11 @@ class Enum(BeginStatement): ################################################### +import statements +import typedecl_statements +__all__.extend(statements.__all__) +__all__.extend(typedecl_statements.__all__) + from statements import * from typedecl_statements import * diff --git a/numpy/f2py/lib/doc.txt b/numpy/f2py/lib/parser/doc.txt index 159943224..464bd7243 100644 --- a/numpy/f2py/lib/doc.txt +++ b/numpy/f2py/lib/parser/doc.txt @@ -2,10 +2,61 @@ Created: September 2006 Author: Pearu Peterson <pearu.peterson@gmail.com> -Structure -========= +Fortran parser package structure +================================ -numpy.f2py.lib package contains the following files: +numpy.f2py.lib.parser package contains the following files: + +api.py +------ + +Public API for Fortran parser. + +It exposes Statement classes, CHAR_BIT constant, and parse function. + +Function parse(<input>, ..) parses, analyzes and returns Statement +tree of Fortran input. For example, + +:: + >>> from api import parse + >>> code = """ + ... c comment + ... subroutine foo(a) + ... integer a + ... print*,"a=",a + ... end + ... """ + >>> tree = parse(code,isfree=False) + >>> print tree + !BEGINSOURCE <cStringIO.StringI object at 0xb75ac410> mode=fix90 + SUBROUTINE foo(a) + INTEGER a + PRINT *, "a=", a + END SUBROUTINE foo + >>> + >>> tree + BeginSource + blocktype='beginsource' + name='<cStringIO.StringI object at 0xb75ac410> mode=fix90' + a=AttributeHolder: + external_subprogram=<dict with keys ['foo']> + content: + Subroutine + args=['a'] + item=Line('subroutine foo(a)',(3, 3),'') + a=AttributeHolder: + variables=<dict with keys ['a']> + content: + Integer + selector=('', '') + entity_decls=['a'] + item=Line('integer a',(4, 4),'') + Print + item=Line('print*,"a=",a',(5, 5),'') + EndSubroutine + blocktype='subroutine' + name='foo' + item=Line('end',(6, 6),'') readfortran.py -------------- diff --git a/numpy/f2py/lib/parsefortran.py b/numpy/f2py/lib/parser/parsefortran.py index ac3df3068..ac3df3068 100644 --- a/numpy/f2py/lib/parsefortran.py +++ b/numpy/f2py/lib/parser/parsefortran.py diff --git a/numpy/f2py/lib/readfortran.py b/numpy/f2py/lib/parser/readfortran.py index b23a7368f..11dd31fda 100644 --- a/numpy/f2py/lib/readfortran.py +++ b/numpy/f2py/lib/parser/readfortran.py @@ -4,12 +4,14 @@ Defines FortranReader classes for reading Fortran codes from files and strings. FortranReader handles comments and line continuations of both fix and free format Fortran codes. +----- 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: May 2006 +----- """ __all__ = ['FortranFileReader', @@ -710,10 +712,13 @@ class FortranFileReader(FortranReaderBase): class FortranStringReader(FortranReaderBase): - def __init__(self, string, isfree, isstrict): + def __init__(self, string, isfree, isstrict, include_dirs = None): self.id = 'string-'+str(id(string)) source = StringIO(string) FortranReaderBase.__init__(self, source, isfree, isstrict) + if include_dirs is not None: + self.include_dirs = include_dirs[:] + return # Testing: diff --git a/numpy/f2py/lib/sourceinfo.py b/numpy/f2py/lib/parser/sourceinfo.py index 65b90ca21..2f5aab603 100644 --- a/numpy/f2py/lib/sourceinfo.py +++ b/numpy/f2py/lib/parser/sourceinfo.py @@ -1,9 +1,19 @@ """ +Provides get_source_info(<filename>) function to determine the format +(free|fixed|strict|pyf) of a Fortran file. + +----- +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: May 2006 +----- """ __all__ = ['get_source_info'] + import re import os import sys @@ -17,10 +27,10 @@ _free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]',re.I).match def get_source_info(filename): """ Determine if fortran file is - - in fix format and contains Fortran 77 code -> False, True - - in fix format and contains Fortran 90 code -> False, False - - in free format and contains Fortran 90 code -> True, False - - in free format and contains signatures (.pyf) -> True, True + - in fix format and contains Fortran 77 code -> return False, True + - in fix format and contains Fortran 90 code -> return False, False + - in free format and contains Fortran 90 code -> return True, False + - in free format and contains signatures (.pyf) -> return True, True """ base,ext = os.path.splitext(filename) if ext=='.pyf': diff --git a/numpy/f2py/lib/splitline.py b/numpy/f2py/lib/parser/splitline.py index 1bbd77b6e..cceeadd90 100644 --- a/numpy/f2py/lib/splitline.py +++ b/numpy/f2py/lib/parser/splitline.py @@ -2,15 +2,14 @@ """ Defines LineSplitter and helper functions. -Copyright 2006 Pearu Peterson all rights reserved, -Pearu Peterson <pearu@cens.ioc.ee> +----- Permission to use, modify, and distribute this software is given under the -terms of the LGPL. See http://www.fsf.org +terms of the NumPy License. See http://scipy.org. NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. -$Revision:$ -$Date: 2000/07/31 07:04:03 $ -Pearu Peterson +Author: Pearu Peterson <pearu@cens.ioc.ee> +Created: May 2006 +----- """ __all__ = ['String','string_replace_map','splitquote','splitparen'] @@ -410,6 +409,8 @@ def test(): l = string_replace_map('a()') print l + print 'ok' + if __name__ == '__main__': test() diff --git a/numpy/f2py/lib/statements.py b/numpy/f2py/lib/parser/statements.py index 2ca399bb1..5c982ea8b 100644 --- a/numpy/f2py/lib/statements.py +++ b/numpy/f2py/lib/parser/statements.py @@ -1,9 +1,33 @@ +""" +Fortran single line statements. + +----- +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: May 2006 +----- +""" + +__all__ = ['GeneralAssignment', + 'Assignment','PointerAssignment','Assign','Call','Goto','ComputedGoto','AssignedGoto', + 'Continue','Return','Stop','Print','Read','Read0','Read1','Write','Flush','Wait', + 'Contains','Allocate','Deallocate','ModuleProcedure','Access','Public','Private', + 'Close','Cycle','Backspace','Endfile','Rewind','Open','Format','Save', + 'Data','Nullify','Use','Exit','Parameter','Equivalence','Dimension','Target', + 'Pointer','Protected','Volatile','Value','ArithmeticIf','Intrinsic', + 'Inquire','Sequence','External','Namelist','Common','Optional','Intent', + 'Entry','Import','ForallStmt','SpecificBinding','GenericBinding', + 'FinalBinding','Allocatable','Asynchronous','Bind','Else','ElseIf', + 'Case','WhereStmt','ElseWhere','Enumerator','FortranName','Threadsafe', + 'Depend','Check','CallStatement','CallProtoArgument','Pause'] import re import sys from base_classes import Statement, Variable -#from expression import Expression # Auxiliary tools diff --git a/numpy/f2py/lib/test_parser.py b/numpy/f2py/lib/parser/test_parser.py index f69957a76..3921e93a3 100644 --- a/numpy/f2py/lib/test_parser.py +++ b/numpy/f2py/lib/parser/test_parser.py @@ -1,3 +1,15 @@ +""" +Test parsing single Fortran lines. + +----- +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: May 2006 +----- +""" from numpy.testing import * from block_statements import * @@ -430,19 +442,19 @@ class test_Statements(NumpyTestCase): def check_integer(self): assert_equal(parse(Integer,'integer'),'INTEGER') - assert_equal(parse(Integer,'integer*4'),'INTEGER(KIND=4)') - assert_equal(parse(Integer,'integer*4 a'),'INTEGER(KIND=4) a') - assert_equal(parse(Integer,'integer*4, a'),'INTEGER(KIND=4) a') - assert_equal(parse(Integer,'integer*4 a ,b'),'INTEGER(KIND=4) a, b') - assert_equal(parse(Integer,'integer*4 :: a ,b'),'INTEGER(KIND=4) a, b') - assert_equal(parse(Integer,'integer*4 a(1,2)'),'INTEGER(KIND=4) a(1,2)') - assert_equal(parse(Integer,'integer*4 :: a(1,2),b'),'INTEGER(KIND=4) a(1,2), b') + assert_equal(parse(Integer,'integer*4'),'INTEGER*4') + assert_equal(parse(Integer,'integer*4 a'),'INTEGER*4 a') + assert_equal(parse(Integer,'integer*4, a'),'INTEGER*4 a') + assert_equal(parse(Integer,'integer*4 a ,b'),'INTEGER*4 a, b') + assert_equal(parse(Integer,'integer*4 :: a ,b'),'INTEGER*4 a, b') + assert_equal(parse(Integer,'integer*4 a(1,2)'),'INTEGER*4 a(1,2)') + assert_equal(parse(Integer,'integer*4 :: a(1,2),b'),'INTEGER*4 a(1,2), b') assert_equal(parse(Integer,'integer*4 external :: a'), - 'INTEGER(KIND=4), external :: a') + 'INTEGER*4, external :: a') assert_equal(parse(Integer,'integer*4, external :: a'), - 'INTEGER(KIND=4), external :: a') + 'INTEGER*4, external :: a') assert_equal(parse(Integer,'integer*4 external , intent(in) :: a'), - 'INTEGER(KIND=4), external, intent(in) :: a') + 'INTEGER*4, external, intent(in) :: a') assert_equal(parse(Integer,'integer(kind=4)'),'INTEGER(KIND=4)') assert_equal(parse(Integer,'integer ( kind = 4)'),'INTEGER(KIND=4)') assert_equal(parse(Integer,'integer(kind=2+2)'),'INTEGER(KIND=2+2)') @@ -479,5 +491,6 @@ class test_Statements(NumpyTestCase): 'IMPLICIT INTEGER ( i-m, p, q-r )') assert_equal(parse(Implicit,'implicit integer (i-m), real (z)'), 'IMPLICIT INTEGER ( i-m ), REAL ( z )') + if __name__ == "__main__": NumpyTest().run() diff --git a/numpy/f2py/lib/typedecl_statements.py b/numpy/f2py/lib/parser/typedecl_statements.py index 7778de28a..2e5eea2bc 100644 --- a/numpy/f2py/lib/typedecl_statements.py +++ b/numpy/f2py/lib/parser/typedecl_statements.py @@ -1,3 +1,15 @@ +""" +Fortran type declaration statements. + +----- +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: May 2006 +----- +""" __all__ = ['Integer', 'Real', 'DoublePrecision', 'Complex', 'DoubleComplex', 'Character', 'Logical', 'Byte', 'TypeStmt','Class', diff --git a/numpy/f2py/lib/utils.py b/numpy/f2py/lib/parser/utils.py index bdd838596..fbb5219f6 100644 --- a/numpy/f2py/lib/utils.py +++ b/numpy/f2py/lib/parser/utils.py @@ -1,3 +1,20 @@ +""" +Various utility functions. + +----- +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: May 2006 +----- +""" + +__all__ = ['split_comma', 'specs_split_comma', + 'ParseError','AnalyzeError', + 'get_module_file','parse_bind','parse_result','is_name', + 'CHAR_BIT','str2stmt'] import re import os, glob diff --git a/numpy/f2py/lib/python_wrapper.py b/numpy/f2py/lib/python_wrapper.py index 351dd7c02..35f3147fc 100644 --- a/numpy/f2py/lib/python_wrapper.py +++ b/numpy/f2py/lib/python_wrapper.py @@ -5,9 +5,11 @@ import re import os import sys -from block_statements import * +from parser.api import * + +#from block_statements import * #from typedecl_statements import intrinsic_type_spec, Character -from utils import CHAR_BIT +#from utils import CHAR_BIT from wrapper_base import * @@ -596,9 +598,9 @@ initialize_%(typename)s_interface(initialize_%(typename)s_interface_c);\ if __name__ == '__main__': - from utils import str2stmt, get_char_bit - - stmt = str2stmt(""" + #from utils import str2stmt, get_char_bit + + stmt = parse(""" module rat integer :: i type info @@ -641,7 +643,7 @@ if __name__ == '__main__': """ wm = PythonWrapperModule('foo') - wm.add(str2stmt(foo_code)) + wm.add(parse(foo_code)) #wm.add_fortran_code(foo_code) #wm.add_subroutine(str2stmt(foo_code)) #print wm.c_code() |