Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Fortran) FORTRAN 77 style comments #2677

Closed
interkosmos opened this issue Sep 8, 2020 · 9 comments · Fixed by #2689
Closed

(Fortran) FORTRAN 77 style comments #2677

interkosmos opened this issue Sep 8, 2020 · 9 comments · Fixed by #2689
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@interkosmos
Copy link
Contributor

Describe the issue
Two comment styles are supported, old C (FORTRAN 77) and new !. Syntax starting with C/c in column 1 are treated as comments. The ^C comment indicator should be better replaced with ^C (appended whitespace) as a workaround.

Which language seems to have the issue?
Fortran.

Are you using highlight or highlightAuto?
highlight

Sample Code to Reproduce

module test
    implicit none
    public :: foo
contains ! <-- is treated as comment because of `c` in first column
    function foo()
        integer :: foo
        foo = 1
    end function foo
end module test

Expected behavior
Syntax starting with character c should not be treated as comments.

Additional context
The comments in fortran.js are defined as:

  const COMMENT = {
    variants: [
      hljs.COMMENT('!', '$', {relevance: 0}),
      // allow Fortran 77 style comments
      hljs.COMMENT('^C', '$', {relevance: 0})
    ]
  };

Perhaps, it is sufficient to replace ^C with ^C or ^C\s.

@interkosmos interkosmos added bug help welcome Could use help from community language labels Sep 8, 2020
@joshgoebel
Copy link
Member

joshgoebel commented Sep 9, 2020

Longer discussion: #2310

The space variant doesn't work because evidently C==== is a style some use (or at least it was pointed out its more than valid) ... and one could imagine other variants... perhaps \b would be better... but would anyone use CCCCCCC?

This is hard because really these should likely be two separate languages, not one.

Are you perhaps someone with a deep understanding or Fortran and the various commenting styles someone uses within the scope of the actual rules?

@interkosmos
Copy link
Contributor Author

I agree, it’s a tricky question. Perhaps, it is better to split between FORTRAN 77 and modern Fortran, and remove the C comment indicator entirely. I’ll try to work on fortran77.js language configuration file in near future.

@joshgoebel
Copy link
Member

@interkosmos Would you want to make a PR where we extend this to C\s and see how it goes? I'm not opposed to trying it.

I’ll try to work on fortran77.js language configuration file in near future.

Would it be that different from Fortran 90? Are these really two entirely different langauges?

@joshgoebel joshgoebel added the good first issue Should be easier for first time contributors label Sep 11, 2020
@interkosmos
Copy link
Contributor Author

interkosmos commented Sep 11, 2020

Would you want to make a PR where we extend this to C\s and see how it goes? I'm not opposed to trying it.

Yeah, why not.

Would it be that different from Fortran 90? Are these really two entirely different langauges?

FORTRAN 77 is written in fixed-source format, with the first six columns of a row being reserved for comments, format descriptors, line break indications, and so on. Fortran 90 changed to free-source format, without such restrictions.

@joshgoebel
Copy link
Member

joshgoebel commented Sep 11, 2020

FORTRAN 77 is written in fixed-source format, with the first six columns of a row being reserved for comments, format descriptors, line break indications, and so on. Fortran 90 changed to free-source format, without such restrictions.

Sounds about like my understanding... but for highlighting purposes how are they any different other than the ambiguity with comments? It seems right now we perfectly highlight both - with this comment exception, no?

@interkosmos
Copy link
Contributor Author

Yes, I don’t see any edge case at the moment. So, if ^C\s checks out you would rather keep a single language file?

@nathanweeks
Copy link

FWIW, in free source form (Fortran >= 90),call SOME_SUBROUTINE is also currently treated as a comment when the call statement begins in the first column.

@joshgoebel
Copy link
Member

Pretty sure this also resolves that no?

@nathanweeks
Copy link

Yes, it seems like it should. Looking forward to seeing it merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants