Fortran: implement free & fixed formats
ClosedPublic

Authored by nibags on Jun 10 2019, 8:58 AM.

Details

Summary

FEATURE: 372950

Task T9775

TODO: ask for MIT license.

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Jun 10 2019, 8:58 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJun 10 2019, 8:58 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Jun 10 2019, 8:58 AM
nibags edited the summary of this revision. (Show Details)Jun 10 2019, 9:00 AM

Nice that you take care to integrate that.

Is there any progress with the licensing?
Otherwise I assume LGPL would be good enough, if a change isn't possible.

nononux added a subscriber: nononux.Jul 2 2019, 8:18 PM

Hi, thanks for the patch. I suggest additionnal changes to improve the syntax highlighting for Fortran fixed format.

I write fixed format fortran at least once a week using Kate. I can confirm these modifications will be usefull at least for me ;)
I tested the proposed changes on this file www.unige.ch/~hairer/prog/nonstiff/dop853.f (+ add some characters to test the comments highlighting after the 72th column).

Unfortunately I don't see how to write the changes without regular expressions, but I've only low knowledge on syntax highlighting files.

data/syntax/fortran-fixed.xml
375

I propose to add this (why below)

<IncludeRules context="find_continue" />
408–409

I propose to add theses lines:

<DetectChar attribute="Comment" context="comment" char="!"/>
<RegExpr attribute="Comment" context="comment" String=".*" column="72" />

1st line : The "!" can be used even in fixed format. It can be used at any place in the line to comment the end of the line
2nd line : The characters after the 72th column are ignored by the compiler. So it's easier for the user if they are marked as a comment.

ref : my everyday use of Fortran + https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html

424

I propose to add this (with the line above) :

<!-- This context highlights the continuation character -->
      <context attribute="Normal Text" lineEndContext="#stay" name="find_continue">
        <RegExpr attribute="Continuation character" context="#stay" String="^     [^0-9\s]"/>
      </context>

If the 5 firsts characters are blank and the 6th is not blank and not a number, this indicate a continuation character (usually "&" or "*").
It will be easier for the user to place the continuation character at the right column if it is coloured.

569

To complete the above modification:

<itemData name="Continuation character" defStyleNum="dsBuiltIn" bold="1" italic="0"/>

Hi,

I would propose that we first merge this as is and then start to improve.
For your wanted additions, could you then add matching parts to the test highlighting file that show the improvements (or are there already parts inside that will change)?

Ok, I'll retry after the merge and propose a change to the test file too.

nibags added a comment.Jul 3 2019, 3:30 AM

Is there any progress with the licensing?
Otherwise I assume LGPL would be good enough, if a change isn't possible.

Sorry, I forgot to ask the authors (Franchin Matteo & Janus Weil) about the license change to MIT. Now I send an email to them asking. When I have an answer, I can make a new commit by updating the license.

We can merge this with the current license (LGPL) so that @nononux can implement its improvements. Then I change the license to MIT when I get a response from the original authors.

Ok, please merge

cullmann accepted this revision.Jul 3 2019, 10:37 AM
This revision is now accepted and ready to land.Jul 3 2019, 10:37 AM
This revision was automatically updated to reflect the committed changes.
nibags added a comment.Jul 3 2019, 9:33 PM

Franchin Matteo & Janus Weil responded and agree to the MIT license.

dhaumann added inline comments.Jul 4 2019, 5:11 AM
data/syntax/fortran-free.xml
3

Is it correct that include keywords was added with 5.53?

nibags added inline comments.Jul 4 2019, 5:30 AM
data/syntax/fortran-free.xml
3

Include keywords was added in KF5.52, but the implementation had a bug that was fixed in KF5.53. So far, the files that use this (SCSS and TypeScript) require 5.53

Include-keywords (5.52):
https://phabricator.kde.org/D14632
https://phabricator.kde.org/R216:f2c29ec618da08ebe9d17ff739e8b12bf3c33fff
Fix (5.53):
https://phabricator.kde.org/D17085

dhaumann added inline comments.Jul 4 2019, 10:10 AM
data/syntax/fortran-free.xml
3

Ok thanks. We still need to document this in https://docs.kde.org/stable5/en/applications/katepart/highlight.html
Any takers? :-)

nibags added a comment.Jul 6 2019, 7:27 AM

The files are re-licensed to MIT at: 9c5875af2713