pearu / f2py

Automatically exported from code.google.com/p/f2py
Other
54 stars 37 forks source link

recursively called parser does not preserve state of ignore_comments #27

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Pearu,

When the analyse() function of the Use statement is called it will try to find 
the file of the module and call the parser to parse and analyse this module. 
However, i noticed that the ignore_comments parameter to the constructor of 
FortranParser is not set. So if the user is parsing with ignore_comments=False, 
then this is not carried through to the parser instances called within the 
cascade of analyse() calls.

Here's my proposed fix:

diff -r ec5eb01a4e3e fparser/statements.py
--- a/fparser/statements.py Fri Sep 03 20:20:51 2010 +0300
+++ b/fparser/statements.py Mon Sep 06 22:36:52 2010 +0200
@@ -913,7 +913,7 @@
                 from parsefortran import FortranParser
                 self.info('looking module information from %r' % (fn))
                 reader = FortranFileReader(fn, include_dirs=self.reader.include_dirs, source_only=self.reader.source_only)
-                parser = FortranParser(reader)
+                parser = 
FortranParser(reader,ignore_comments=self.top.parent.ignore_comments)
                 parser.parse()
                 parser.block.a.module.update(modules)
                 parser.analyze()

best,

omar

Original issue reported on code.google.com by omar.aw...@gmail.com on 6 Sep 2010 at 8:42