camfort / fortran-src

Fortran parsing and static analysis infrastructure
https://hackage.haskell.org/package/fortran-src
Other
44 stars 20 forks source link

Loosen legacy restriction for inline comments #257

Closed RaoulHC closed 1 year ago

RaoulHC commented 1 year ago

These are explicitly in the Fortran 77 standard.

Issue raised in #256.

raehik commented 1 year ago

Cheers, nice catch.

To confirm, there are two things we're doing here:

fortran-src is generally pretty stubborn about syntax and standards, but I agree with you that we should be lenient here, especially with comments (no semantic value). LGTM!


Unrelated, the comment for

  -- Skip the newline before a comment
  | _isWhiteInsensitive && isNewlineCommentsFollowedByContinuation ai
  = skip NewlineComment ai

threw me. It's actually detecting the former case, and skips that (comment) line.

RaoulHC commented 1 year ago

Hmmm actually maybe we just want the first change in that case, indeed it looks like using ! for comments isn't in the standard at all! Maybe that change should be removed and we can make the legacy parser the default for .f files as I suggested in #256? I think it could be useful to have a strict 77 standard parser, but the majority of users probably actually want the legacy parser.

raehik commented 1 year ago

I'm fairly ambivalent on the ! change. I'm definitely for your .f default parser change suggestion -- opened an issue at #259 .

Ah, I now note that this change loosens further than Fortran77 -- the FORTRAN 66 parser also receives these changes. We should be able to use Ord FortranVersion to check for "FORTRAN 77 or newer" to catch all the F77s. (It'd be so much nicer if our lexers were composable...! aleeeeex!!)

RaoulHC commented 1 year ago

Cool, have updated so it's just the one change that loosens the comment line before continuation line restriction.