pearu / f2py

Automatically exported from code.google.com/p/f2py
Other
55 stars 39 forks source link

FortranFileReader reader.span looks strange in a case. #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.expande attatched file.
2.Put takao_test_read.py just above the f2py directoy.
3.Then type "takao_test_read.py Issue7.F"

What is the expected output? What do you see instead?
This is what I got in the above procedure.
=======================================
Not implemented: Defined_Binary_Op
Not implemented: Defined_Binary_Op
Defined_Operator not defined used by Generic_Spec
['Issue7.F']
@@@@@ Issue7.F @@@@@ start -----
(1, 1) Line subroutine bndfp()
(2, 8) Line use m_struc_def
(3, 3) C-
(9, 9) Line end
@@@@@ Issue7.F @@@@@ end -------
=======================================
The first things in each line are reader.span.
You can see that (3, 3) is after (2, 8).
This seems to occur when C followed by '- 'is a comment line.

What version of the product are you using? On what operating system?
r17

Please provide any additional information below.

Original issue reported on code.google.com by TakaoKot...@gmail.com on 9 Mar 2010 at 2:34

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r19.

Original comment by pearu.peterson on 9 Mar 2010 at 9:14

GoogleCodeExporter commented 9 years ago
Thanks for the bug report. I have fixed this issue in svn.

By the way, the recommended way to iterate reader instance is
{{{
    reader = FortranFileReader(ffile)
    for item in reader:
        # process item
}}}
Note that FortranFileReader is iterator (it defines __iter__ and next methods).

Original comment by pearu.peterson on 9 Mar 2010 at 9:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thank you so much for your fixing. 
I am now leaning fparser, and also python itself.
fparser is very interesting for me
(a while ago, I looked into parser in gfortran or something, 
 but it was too complicated).

A minor problem: a result obtained from the code below is
  item=Comment('C-\nC a\nC b\nC 1',(3, 9))
So, I can not reproduce the original code from this item
since C\n or just \n are missing.
I don't know wether you need to fix it now or not
(probably I don't need this now).

-------------------------------
      subroutine bndfp()
      use m_struc_def
C-
C a 
C b

C
C 1
      read(6,*) abc 
      end
-------------------------------

Original comment by TakaoKot...@gmail.com on 10 Mar 2010 at 2:43

GoogleCodeExporter commented 9 years ago
The above behavior comes from fparser design: ignore empty
lines and empty comments. And so indeed, the original code
is not reproduced exactly.

Do you actually need that the original code would be reproduced
exactly?

Original comment by pearu.peterson on 10 Mar 2010 at 9:28

GoogleCodeExporter commented 9 years ago
No. Probably not.

From your code and document, I gradually understand fparser,
and your idea on it. I now have impression that 
I can manage to treat it (at least as a user), though I need to learn it more.

Original comment by TakaoKot...@gmail.com on 10 Mar 2010 at 6:07

GoogleCodeExporter commented 9 years ago
I have just commited a patch that will not ignore empty comments.
Empty lines are still ignored.

Original comment by pearu.peterson on 15 Mar 2010 at 7:46