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

Add inline exclamation mark comments to fortran.tmbundle #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

friedc
Copy link

@friedc friedc commented Nov 30, 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. For GitHub, the correct highlight can be checked with Lightshow. Currently the highlight is incorrect4, which is fixed by this PR5.

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=

@friedc
Copy link
Author

friedc commented Dec 17, 2021

@infininight

@octycs
Copy link

octycs commented May 11, 2022

+1 from me. This would fix the issues if there's an apostrophe in an inline comment (e.g. here: https://github.com/nwchemgit/nwchem/blob/3ebfe1a6739e0d71a527731f7b198dbaa94adc60/src/property/raman.F#L362)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants