opengrok icon indicating copy to clipboard operation
opengrok copied to clipboard

Add support for $ in fortran identifiers and clickable .i include files.

Open navinp0304 opened this issue 1 year ago • 7 comments

How do i make #include 'file.i' as clickable i.e it is showing as text not a link ? For me #include "file.h" works as a clickable link. I tried adding it in suffix but it doesn't work. The format is #include 'file.i' not "file.i".

diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java
index 3bc256d38d9..14a8fcf3ca1 100644
--- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java
+++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java
@@ -49,7 +49,9 @@ public class FortranAnalyzerFactory extends FileAnalyzerFactory {
         "F95",
         "F03",
         "F08",
-        "F15"};
+        "F15",
+        "F77",
+        "I"};

Ctags has added support for fortran identifiers with $ https://github.com/universal-ctags/ctags/issues/4033

Please add support for opengrok as well. This works well for me.

diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh b/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh
index 86994f85da2..7e9577f4588 100644
--- a/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh
+++ b/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh
@@ -22,7 +22,7 @@
  * Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
  */

-Identifier = [a-zA-Z_] [a-zA-Z0-9_]*
+Identifier = [a-zA-Z_] [a-zA-Z0-9_$]*
 Label = [0-9]+

 Number = ([0-9]+\.[0-9]+|[0-9][0-9]* | [0][xX] [0-9a-fA-F]+ )([uUdDlL]+)?

navinp0304 avatar Jul 27 '24 10:07 navinp0304

Care to submit a PR ?

vladak avatar Aug 01 '24 11:08 vladak

@vladak Yes but why aren't the include files clickable (without href) even after adding suffixes. I'll have that and then submit PR.

navinp0304 avatar Aug 01 '24 15:08 navinp0304

@vladak Yes but why aren't the include files clickable (without href) even after adding suffixes. I'll have that and then submit PR.

Hi @vladak , can you please help with this ?

navinp0304 avatar Aug 10 '24 08:08 navinp0304

For the include directive I think this needs to be processed by the Fortran analyzer. I believe https://github.com/oracle/opengrok/blob/master/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex needs to obtain similar rule as e.g. in https://github.com/oracle/opengrok/blob/0e0e613f0e7824b129796f77d024a0455d659ed9/opengrok-indexer/src/main/jflex/analysis/c/CSymbolTokenizer.lex#L54 , just with the single quotes surrounding the file path element.

Is the file include a feature of (modern) Fortran actually ? Just asking, I have never worked with Fortran before.

vladak avatar Aug 14 '24 14:08 vladak

The Fortran lexing rules already contain file/path matching: https://github.com/oracle/opengrok/blob/0e0e613f0e7824b129796f77d024a0455d659ed9/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex#L166-L184 and there is also https://github.com/oracle/opengrok/blob/0e0e613f0e7824b129796f77d024a0455d659ed9/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex#L89-L96 so perhaps these need to be augmented and/or receive rule similar to the one used for C: https://github.com/oracle/opengrok/blob/0e0e613f0e7824b129796f77d024a0455d659ed9/opengrok-indexer/src/main/jflex/analysis/c/CXref.lex#L98-L113 (which should match the rule added to FortranSymbolTokenizer.lex)

Further, there is also https://github.com/oracle/opengrok/blob/0e0e613f0e7824b129796f77d024a0455d659ed9/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex#L62 which probably needs to be reconciled with the new state of include files in Fortran.

vladak avatar Aug 14 '24 15:08 vladak

For the include directive I think this needs to be processed by the Fortran analyzer. I believe https://github.com/oracle/opengrok/blob/master/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex needs to obtain similar rule as e.g. in

https://github.com/oracle/opengrok/blob/0e0e613f0e7824b129796f77d024a0455d659ed9/opengrok-indexer/src/main/jflex/analysis/c/CSymbolTokenizer.lex#L54

, just with the single quotes surrounding the file path element. Is the file include a feature of (modern) Fortran actually ? Just asking, I have never worked with Fortran before.

No it was there since Fortran 77 include 'file' or include "file" . Below is the link https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vna1/index.html

navinp0304 avatar Aug 17 '24 05:08 navinp0304

Care to submit a PR ?

Submitted

navinp0304 avatar Aug 21 '24 07:08 navinp0304