Fortran-FOSS-Programmers / ford

Automatically generates FORtran Documentation from comments within the code.
https://forddocs.readthedocs.io
GNU General Public License v3.0
405 stars 131 forks source link

Can not start a new line in Fortran with "&" #582

Open SharpRT opened 10 months ago

SharpRT commented 10 months ago

Hi,

I am getting the following error: Warning: Error parsing src/main.f90. Can not start a new line in Fortran with "&": & world &

As far as I know, this is standard Fortran syntax for line continuation of strings. https://stackoverflow.com/questions/16776270/line-continuation-of-strings-in-fortran

Is this something that can be fixed?

Thanks!

ZedThree commented 10 months ago

Oh dear, this definitely should work!

This looks like it should only happen if we think the previous line didn't end with an &. Do you have a full example I can check?

It does look like we don't actually have any tests for this, which is a mistake!

SharpRT commented 10 months ago

It seems to be my comment that is throwing things. Would be nice if this worked.

write(11, ' &
    &( &
        ! row    col    day    year   sysTime   sysRate   cpuTime
        & I0, A, I0, A, I0, A, I0, A, I0, A, I0, A, f13.6, A &
    &)' &
) 
ZedThree commented 10 months ago

Thanks! Ah, that is quite painful: there's a comment in the middle of the string literal. Valid Fortran, but quite difficult to parse.

This might take me a little bit of time to get to, so one workaround would be to move the comment out of the string. You could put a & at the end of the comment instead

SharpRT commented 10 months ago

Yes, that works as a fairly pain-free workaround. Thanks!