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

Grammar for fixed form fortran doesn't support exclamation mark comments #5697

Closed
friedc opened this issue Dec 20, 2021 · 1 comment
Closed

Comments

@friedc
Copy link
Contributor

friedc commented Dec 20, 2021

Many compilers support inline exclamation mark comments with fixed source form12. Here an example for such comments is given1

C Column Numbers:
C        1         2         3         4         5         6         7
C23456789012345678901234567890123456789012345678901234567890123456789012

!IBM* SOURCEFORM (FIXED)
      CHARACTER CHARSTR ; LOGICAL X          ! 2 statements on 1 line
      DO 10 I=1,10
        PRINT *,'this is the index',I  ! with an inline comment
10    CONTINUE
C
       CHARSTR="THIS IS A CONTINUED
     X CHARACTER STRING"
       ! There will be 38 blanks in the string between "CONTINUED"
       ! and "CHARACTER". You cannot have an inline comment on
       ! the initial line because it would be interpreted as part
       ! of CHARSTR (character context).
  100 PRINT *, IERROR
! The following debug lines are compiled as source lines if
! you use -qdlines
D     IF (I.EQ.IDEBUG.AND.
D    +    J.EQ.IDEBUG)     WRITE(6,*) IERROR
D     IF (I.EQ.
D    +  IDEBUG )
D    +  WRITE(6,*) INFO
       END

And here is another example2

c      Start expression analyzer 
       CHARACTER S, STACK*80 
       COMMON /PRMS/ N, S, STACK 
       ... 
*      Crack the expression:
       IF ( S .GE. '0' .AND. S .LE. '9' ) THEN ! EoL comment 
              CALL PUSH        ! Save on stack. EoL comment 
d             PRINT *, S       ! Debug comment & EoL comment 
       ELSE 
              CALL TOLOWER ! To lowercase EoL comment 
       END IF 
D      PRINT *, N!       Debug comment & EoL comment 
       ... 
C      Finished 
!       expression analyzer

Finally another publicly available example3 also uses this feature. All these examples are currently not correctly highlighted. Currently the highlight is incorrect4, which is fixed a PR5 which I sent to the upstream repository fortran.tmbundle6. However, I have not heard back from the authors of the upstream grammar and probably never will.

Footnotes

  1. https://www.ibm.com/docs/en/xcafbg/9.0.0?topic=SS3KZ4_9.0.0/com.ibm.xlf111.bg.doc/xlflr/lines_source_formats.htm 2

  2. https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html 2

  3. https://github.com/johannesgerer/jburkardt-f77/blob/master/triangulation/triangulation_prb.f#L3253-L3268

  4. https://github-lightshow.herokuapp.com/?utf8=%E2%9C%93&scope=from-url&grammar_format=auto&grammar_url=https%3A%2F%2Fgithub.com%2Ftextmate%2Ffortran.tmbundle%2Fblob%2Fmaster%2FSyntaxes%2FFortran%2520-%2520Punchcard.tmLanguage&grammar_text=&code_source=from-url&code_url=https%3A%2F%2Fgithub.com%2Fjohannesgerer%2Fjburkardt-f77%2Fblob%2Fmaster%2Ftriangulation%2Ftriangulation_prb.f%23L3253-L3268&code=

  5. https://github-lightshow.herokuapp.com/?utf8=%E2%9C%93&scope=from-url&grammar_format=auto&grammar_url=https%3A%2F%2Fgithub.com%2Ffriedc%2Ffortran.tmbundle%2Fblob%2Fmaster%2FSyntaxes%2FFortran%2520-%2520Punchcard.tmLanguage&grammar_text=&code_source=from-url&code_url=https%3A%2F%2Fgithub.com%2Fjohannesgerer%2Fjburkardt-f77%2Fblob%2Fmaster%2Ftriangulation%2Ftriangulation_prb.f%23L3253-L3268&code=

  6. https://github.com/textmate/fortran.tmbundle/pull/27

@friedc friedc added the Bug label Dec 20, 2021
@lildude
Copy link
Member

lildude commented Dec 21, 2021

Unfortunately there's little we can do about it short of replacing the grammar with a better maintained one that has the support you desire.

If you know of a better grammar, please open a PR to switch to replace the old with the new. The CONTRIBUTING.md has details in what you need to do.

Removing bug tag as this is not a Linguist bug.

@lildude lildude closed this as completed Apr 5, 2022
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants