[f2py-dev] Comments in f2py (again)

7 views
Skip to first unread message

Omar Awile

unread,
Apr 16, 2010, 1:58:45 PM4/16/10
to f2py...@googlegroups.com
Hi Pearu,

I saw you did some changes in r26 regarding the comments. since this
revision multiline comments are represented in the parse tree as n
single line comments (n being the number of lines in the multiline
comment in the source). Is this change intended? If so, what is the
rational? Wouldn't it be nicer to have blocks of comments in one item
in the parse tree?

best,

omar
--
Omar Awile
Institute of Theoretical Computer Science
ETH Zurich, Universitaetstr. 6, CAB G39.3
CH-8092 Zurich, Switzerland
Tel: +41 44 632 92 74
GPG: http://www.inf.ethz.ch/personal/oawile/gpg/

--
You received this message because you are subscribed to the Google Groups "F2PY Developers" group.
To post to this group, send email to f2py...@googlegroups.com.
To unsubscribe from this group, send email to f2py-dev+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/f2py-dev?hl=en.

Omar Awile

unread,
Apr 16, 2010, 2:25:54 PM4/16/10
to F2PY Developers
I checked... readfortran.py line 625 is the reason there are no
multiline comments anymore, but looking at the Comment class I guess
you decided to have store comments line by line in the parse tree.
Only thing I wonder.. what are lines 627-644 still doing in this
function? That is actually dead code...
So.. having the multiline comments (maybe activating the feature by an
optional switch) would be useful.

-omar

Pearu Peterson

unread,
Apr 16, 2010, 3:18:25 PM4/16/10
to f2py...@googlegroups.com
Hi,

There are no multiline comments any more (CommentBlock is removed),
just comment lines. It is easy to collect the comment lines while
iterating over the parser or reader items. The rationale behind
removing multiline comments was that this preserves more
information of the structure of the original code, see also issue 8.

Indeed, 627-644 is a dead code, I just kept it there in case we
change our minds..

I am 0 on whether to keep comment lines separate or collect them
to a block. Comments do not matter when parsing fortran codes for
actual fortran statements. On the other hand, in fortran code
rewriting applications the organization of comments matter.
Currently fparser only partially keeps the comment location information
(line numbers but not column numbers), fixing this means a careful
revision of the readfortran.py code.

As TakaoKotani notes, reproducing the structure of the original code
would be very useful. For example, that would provide a robust way to
test fparser correctness. On the other hand, fparser correctness
can also be tested by compiling the original code and fparser
generated code --- if in both cases a fortran compiler produces
the same object codes then fparser is doing the right thing.

Pearu

Omar Awile

unread,
Apr 16, 2010, 4:02:26 PM4/16/10
to f2py...@googlegroups.com
Hey,

On Fri, Apr 16, 2010 at 21:18, Pearu Peterson <pearu.p...@gmail.com> wrote:
> Hi,
>
> There are no multiline comments any more (CommentBlock is removed),
> just comment lines. It is easy to collect the comment lines while
> iterating over the parser or reader items. The rationale behind
> removing multiline comments was that this preserves more
> information of the structure of the original code, see also issue 8.

Ok, I kind of suspected that... and yes, collecting them is easy.

> Indeed, 627-644 is a dead code, I just kept it there in case we
> change our minds..

agreed

> I am 0 on whether to keep comment lines separate or collect them
> to a block. Comments do not matter when parsing fortran codes for
> actual fortran statements. On the other hand, in fortran code
> rewriting applications the organization of comments matter.
> Currently fparser only partially keeps the comment location information
> (line numbers but not column numbers), fixing this means a careful
> revision of the readfortran.py code.

for me it mainly matters whether the comments relative position to the
code is preserved as I am writing right now the documentation
generator and need to know what the comment is referring to.. as it
seems the parse tree is preserving this.

Let's see how this goes :)

Have a nice weekend,

omar
Reply all
Reply to author
Forward
0 new messages