Bug 372950 - [PATCH] Fortran syntax highlighting: distinguish free format and fixed format
Summary: [PATCH] Fortran syntax highlighting: distinguish free format and fixed format
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-26 11:39 UTC by janus
Modified: 2019-07-03 18:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2016-11-26 11:39:55 UTC
Kate currently seems to have only one syntax-highlighting mode for Fortran. However, in the Fortran language there are two different source formats:
* fixed format (from the old Fortran77 standard, extension .f)
* free format (introduced with Fortran90, extension .f90)

The keywords etc are the same, but one thing that differs is commenting: In fixed format every line with a 'c' in the first column is a comment, while in free format comments start with an '!' (in any column).

Both of these mechanisms seem to be supported in Kate 16.04.3 on Ubuntu 16.10 (with Fortran highlighting file v2). The problem is that lines starting with 'c' are also displayed like a comment in f90 files (where only '!' indicates a comment).

Simple example ('test.f90'):


! this is a test program that does absolutely nothing
program test
contains
  subroutine s
  end subroutine
end program


The first line is greyed out, which is correct, but also the third line ('contains') is greyed out, which is wrong. It is displayed normally if a space is inserted before 'contains.'
Comment 1 janus 2016-11-26 23:28:05 UTC
Implemented here:

https://github.com/KDE/syntax-highlighting/pull/3
Comment 2 janus 2016-11-28 07:42:01 UTC
Submitted for review here:

https://git.reviewboard.kde.org/r/129569/
Comment 3 Dominik Haumann 2017-02-18 11:33:14 UTC
Hi Janus, could you have a look at the review request again? I've added some comments and thoughts there. Thanks!
Comment 4 Christoph Cullmann 2019-07-03 18:19:20 UTC
Git commit c579929d8667114ca1d440563d409f7c92cf00e6 by Christoph Cullmann, on behalf of Nibaldo González.
Committed on 03/07/2019 at 18:19.
Pushed by cullmann into branch 'master'.

Fortran: implement free & fixed formats

Summary:

Task T9775

* Implement patch provided at: https://github.com/janusw/syntax-highlighting/commits/Fortran_2003_2008
* The `fortran-fixed.xml` file corresponds to the original file (`fortran.xml`), which is renamed. The `fortran-free.xml` file uses `IncludeRules` and include-keywords to avoid replicated code.
* Some unnecessary `RegExpr` rules are replaced for optimization.

TODO: ask for MIT license.

Reviewers: #framework_syntax_highlighting, dhaumann, cullmann

Reviewed By: #framework_syntax_highlighting, cullmann

Subscribers: nononux, kwrite-devel, kde-frameworks-devel

Tags: #kate, #frameworks

Differential Revision: https://phabricator.kde.org/D21713

A  +28   -0    autotests/folding/highlight.f.fold
M  +9    -13   autotests/folding/highlight.f90.fold
A  +35   -0    autotests/html/highlight.f.html
M  +24   -28   autotests/html/highlight.f90.html
A  +28   -0    autotests/input/highlight.f
M  +8    -12   autotests/input/highlight.f90
A  +28   -0    autotests/reference/highlight.f.ref
M  +23   -27   autotests/reference/highlight.f90.ref
R  +36   -38   data/syntax/fortran-fixed.xml [from: data/syntax/fortran.xml - 087% similarity]
A  +311  -0    data/syntax/fortran-free.xml

https://commits.kde.org/syntax-highlighting/c579929d8667114ca1d440563d409f7c92cf00e6