#!/usr/bin/env python """ 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 Created: May 2006 """ __all__ = ['FortranFileReader', 'FortranStringReader', 'FortranReaderError', 'Line', 'SyntaxErrorLine', 'Comment', 'MultiLine','SyntaxErrorMultiLine', ] import re import sys import tempfile from cStringIO import StringIO from numpy.distutils.misc_util import yellow_text, red_text, blue_text from sourceinfo import get_source_info from splitline import LineSplitter, String, string_replace_map _spacedigits=' 0123456789' _cf2py_re = re.compile(r'(?P\s*)!f2py(?P.*)',re.I) _is_fix_cont = lambda line: line and len(line)>5 and line[5]!=' ' and line[:5]==5*' ' _is_f90_cont = lambda line: line and '&' in line and line.rstrip()[-1]=='&' _f90label_re = re.compile(r'\s*(?P