fortran-lang / vscode-fortran-support

Fortran language support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=fortran-lang.linter-gfortran
MIT License
221 stars 30 forks source link

bug(syntax): F77 code highlighting cannot resolve a bare statement with line continuation #1130

Open ilayn opened 3 months ago

ilayn commented 3 months ago

Is there an existing issue for this?

Description

If the file https://github.com/scipy/scipy/blob/maintenance/1.14.x/scipy/optimize/lbfgsb_src/lbfgsb.f is opened in VS Code, the syntax highlighting comes quite nice all the way down to the line 967 and then gets confused on a naked format directive and cannot recover until the end of the file. On my system, it looks like the screenshot pasted below.

However, if I transfer a single character from 968 to 967 so format has at least something in the same line, it manages to recover. This leads me to believe that there is a greedy search for an argument after format line but cannot resolve the line continuation context.

Screenshots

image

image

Code Example

!   Code above snippped
      dsave(14) = stp
      dsave(15) = gdold
      dsave(16) = dtd

 1001 format (//,'ITERATION ',i5)
 1002 format
     +  (/,'At iterate',i5,4x,'f= ',1p,d12.5,4x,'|proj g|= ',1p,d12.5)
 1003 format (2(1x,i4),5x,'-',5x,'-',3x,'-',5x,'-',5x,'-',8x,'-',3x,
     +        1p,2(1x,d10.3))
 1004 format ('  ys=',1p,e10.3,'  -gs=',1p,e10.3,' BFGS update SKIPPED')
 1005 format (/,
     +' Singular triangular system detected;',/,
     +'   refresh the lbfgs memory and restart the iteration.')
 1006 format (/,
     +' Nonpositive definiteness in Cholesky factorization in formk;',/,
     +'   refresh the lbfgs memory and restart the iteration.')
 1007 format (/,
     +' Nonpositive definiteness in Cholesky factorization in formt;',/,
     +'   refresh the lbfgs memory and restart the iteration.')
 1008 format (/,
     +' Bad direction in the line search;',/,
     +'   refresh the lbfgs memory and restart the iteration.')

      return
!   Code below snippped

Fortran Version (Free/Fixed Form)

Fixed Form e.g. F77

Version of Modern Fortran

v3.4.2024061901 (pre-release)

Version of Visual Studio Code

v1.92.0

Platform and Architecture

Windows 10

Additional Information

No response