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..f3ec4b32a53 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,8 @@ public class FortranAnalyzerFactory extends FileAnalyzerFactory { "F95", "F03", "F08", - "F15"}; + "F15", + "F77"}; public FortranAnalyzerFactory() { super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, NAME, true); 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 . */ -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]+)? diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex index c0763088939..8be50e0afeb 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex @@ -52,11 +52,13 @@ import org.opengrok.indexer.analysis.JFlexSymbolMatcher; return yystate(); } } +{WhspChar}* "include" {WhspChar}* (\'[^\'\n\r]+\'| \"[^\"\n\r]+\") {} {Number} {} \" { yybegin(STRING); } \' { yybegin(QSTRING); } \! { yybegin(SCOMMENT); } + "C" { yybegin(SCOMMENT); } } { diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex index 685bfb5bc1d..037eafd4973 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex @@ -59,7 +59,7 @@ import org.opengrok.indexer.web.HtmlConsts; } %} -File = [a-zA-Z]{FNameChar}* ".inc" +File = [a-zA-Z]{FNameChar}* "." ("i"|"inc") %state STRING SCOMMENT QSTRING LCOMMENT @@ -86,13 +86,14 @@ File = [a-zA-Z]{FNameChar}* ".inc" onFilteredSymbolMatched(yytext(), yychar, Consts.kwd, false); } +"'" ({File}|{FPath}) "'" | "<" ({File}|{FPath}) ">" { chkLOC(); - onNonSymbolMatched("<", yychar); - String file = yytext(); - file = file.substring(1, file.length() - 1); + String cmatch = yytext(); + onNonSymbolMatched(cmatch.substring(0, 1), yychar); + String file = cmatch.substring(1, cmatch.length() - 1); onFilelikeMatched(file, yychar + 1); - onNonSymbolMatched(">", yychar + 1 + file.length()); + onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, 1), yychar + 1 + file.length()); } /*{Hier} diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java index dd7983a3e4a..e43a5f0140c 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java @@ -40,7 +40,7 @@ void sampleTest() throws IOException { writeAndCompare(new FortranAnalyzerFactory(), "analysis/fortran/sample.f", "analysis/fortran/sample_xref.html", - readTagsFromResource("analysis/fortran/sampletags"), 28); + readTagsFromResource("analysis/fortran/sampletags"), 32); } @Test diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/sample.f b/opengrok-indexer/src/test/resources/analysis/fortran/sample.f index 7fd7257c30d..014f3e70443 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/sample.f +++ b/opengrok-indexer/src/test/resources/analysis/fortran/sample.f @@ -227,4 +227,16 @@ SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) * End of DGESV * END + +* A Fortran 77 subroutine that ends in $ +* ===================================================================== + SUBROUTINE SUBF77$() +* + INTEGER VARF77$ + VARF77$ = 0 +* +* ===================================================================== +* + CALL SUBF77$ + CALL 'http://example.com' diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html b/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html index bde8dc1e5b0..1adb6dc847b 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html +++ b/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html @@ -4,7 +4,7 @@ sampleFile - OpenGrok cross reference for /sampleFile 1* Copyright (c) 2013 Samuel Halliday +function get_sym_list(){return [];} /* ]]> */1* Copyright (c) 2013 Samuel Halliday 2* Copyright (c) 1992-2011 The University of Tennessee and The University 3* of Tennessee Research Foundation. All rights 4* reserved. @@ -176,7 +176,7 @@ 170*> \ingroup doubleGEsolve 171* 172* ===================================================================== -173 SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) +173 SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) 174* 175* -- LAPACK driver routine (version 3.4.0) -- 176* -- LAPACK is a software package provided by Univ. of Tennessee, -- @@ -184,11 +184,11 @@ 178* November 2011 179* 180* .. Scalar Arguments .. -181 INTEGER INFO, LDA, LDB, N, NRHS +181 INTEGER INFO, LDA, LDB, N, NRHS 182* .. 183* .. Array Arguments .. -184 INTEGER IPIV( * ) -185 DOUBLE PRECISION A( LDA, * ), B( LDB, * ) +184 INTEGER IPIV( * ) +185 DOUBLE PRECISION A( LDA, * ), B( LDB, * ) 186* .. 187* 188* ===================================================================== @@ -203,36 +203,48 @@ 197* 198* Test the input parameters. 199* -200 INFO = 0 + 0xFFFF - 0XFF - 0xFF00 -201 IF( N.LT.0 ) THEN -202 INFO = -1 -203 ELSE IF( NRHS.LT.0 ) THEN -204 INFO = -2 -205 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN -206 INFO = -4 -207 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN -208 INFO = -7 +200 INFO = 0 + 0xFFFF - 0XFF - 0xFF00 +201 IF( N.LT.0 ) THEN +202 INFO = -1 +203 ELSE IF( NRHS.LT.0 ) THEN +204 INFO = -2 +205 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN +206 INFO = -4 +207 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN +208 INFO = -7 209 END IF -210 IF( INFO.NE.0 ) THEN -211 CALL XERBLA( 'DGESV ', -INFO ) +210 IF( INFO.NE.0 ) THEN +211 CALL XERBLA( 'DGESV ', -INFO ) 212 RETURN 213 END IF 214* 215* Compute the LU factorization of A. 216* -217 CALL DGETRF( N, N, A, LDA, IPIV, INFO ) -218 IF( INFO.EQ.0 ) THEN +217 CALL DGETRF( N, N, A, LDA, IPIV, INFO ) +218 IF( INFO.EQ.0 ) THEN 219* 220* Solve the system A*X = B, overwriting B with X. 221* -222 CALL DGETRS( 'No transpose', N, NRHS, A, LDA, IPIV, B, LDB, -223 $ INFO ) +222 CALL DGETRS( 'No transpose', N, NRHS, A, LDA, IPIV, B, LDB, +223 $ INFO ) 224 END IF 225 RETURN 226* 227* End of DGESV 228* 229 END -230 CALL 'http://example.com' -231 +230 +231* A Fortran 77 subroutine that ends in $ +232* ===================================================================== +233 SUBROUTINE SUBF77$() +234* +235 INTEGER VARF77$ +236 VARF77$ = 0 +237* +238* ===================================================================== +239* +240 CALL SUBF77$ +241 +242 CALL 'http://example.com' +243 diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt b/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt index a41cfb276bb..5e80e84474b 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt +++ b/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt @@ -52,3 +52,7 @@ IPIV B LDB INFO +SUBF77$ +VARF77$ +VARF77$ +SUBF77$ diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/sampletags b/opengrok-indexer/src/test/resources/analysis/fortran/sampletags index 4c3bfc07496..ce971b069f4 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/sampletags +++ b/opengrok-indexer/src/test/resources/analysis/fortran/sampletags @@ -1,16 +1,52 @@ +!_TAG_EXTRA_DESCRIPTION anonymous /Include tags for non-named objects like lambda/ +!_TAG_EXTRA_DESCRIPTION fileScope /Include tags of file scope/ +!_TAG_EXTRA_DESCRIPTION pseudo /Include pseudo tags/ +!_TAG_EXTRA_DESCRIPTION subparser /Include tags generated by subparsers/ +!_TAG_FIELD_DESCRIPTION epoch /the last modified time of the input file (only for F\/file kind tag)/ +!_TAG_FIELD_DESCRIPTION file /File-restricted scoping/ +!_TAG_FIELD_DESCRIPTION input /input file/ +!_TAG_FIELD_DESCRIPTION name /tag name/ +!_TAG_FIELD_DESCRIPTION pattern /pattern/ +!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/ !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_KIND_DESCRIPTION!Fortran E,enum /enumerations/ +!_TAG_KIND_DESCRIPTION!Fortran L,local /local, common block, and namelist variables/ +!_TAG_KIND_DESCRIPTION!Fortran M,method /type bound procedures/ +!_TAG_KIND_DESCRIPTION!Fortran N,enumerator /enumeration values/ +!_TAG_KIND_DESCRIPTION!Fortran S,submodule /submodules/ +!_TAG_KIND_DESCRIPTION!Fortran b,blockData /block data/ +!_TAG_KIND_DESCRIPTION!Fortran c,common /common blocks/ +!_TAG_KIND_DESCRIPTION!Fortran e,entry /entry points/ +!_TAG_KIND_DESCRIPTION!Fortran f,function /functions/ +!_TAG_KIND_DESCRIPTION!Fortran i,interface /interface contents, generic names, and operators/ +!_TAG_KIND_DESCRIPTION!Fortran k,component /type and structure components/ +!_TAG_KIND_DESCRIPTION!Fortran l,label /labels/ +!_TAG_KIND_DESCRIPTION!Fortran m,module /modules/ +!_TAG_KIND_DESCRIPTION!Fortran n,namelist /namelists/ +!_TAG_KIND_DESCRIPTION!Fortran p,program /programs/ +!_TAG_KIND_DESCRIPTION!Fortran s,subroutine /subroutines/ +!_TAG_KIND_DESCRIPTION!Fortran t,type /derived types and structures/ +!_TAG_KIND_DESCRIPTION!Fortran v,variable /program (global) and module variables/ +!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/ +!_TAG_OUTPUT_FILESEP slash /slash or backslash/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ +!_TAG_OUTPUT_VERSION 0.0 /current.age/ +!_TAG_PARSER_VERSION!Fortran 1.1 /current.age/ +!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/ +!_TAG_PROC_CWD /home/navin.parakkal/OpenGrok/opengrok-indexer/src/test/resources/analysis/fortran/ // !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ -!_TAG_PROGRAM_VERSION 0.0.0 /b13cb551/ -!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ -DGESV grok.f /^ SUBROUTINE DGESV(/;" subroutine line:173 signature:(N, NRHS, A, LDA, IPIV, B, LDB, INFO) -INFO grok.f /^ INTEGER INFO,/;" local line:181 subroutine:DGESV -LDA grok.f /^ INTEGER INFO, LDA,/;" local line:181 subroutine:DGESV -LDB grok.f /^ INTEGER INFO, LDA, LDB,/;" local line:181 subroutine:DGESV -N grok.f /^ INT/;" local line:181 subroutine:DGESV -NRHS grok.f /^ INTEGER INFO, LDA, LDB, N, NRHS$/;" local line:181 subroutine:DGESV -IPIV grok.f /^ INTEGER IPIV(/;" local line:184 subroutine:DGESV -A grok.f /^ DOUBLE PRECISION A(/;" local line:185 subroutine:DGESV -B grok.f /^ DOUBL/;" local line:185 subroutine:DGESV +!_TAG_PROGRAM_VERSION 6.1.0 /p6.1.20240714.0/ +A sample.f /^ DOUBLE PRECISION A( LDA,/;" L subroutine:DGESV file: +B sample.f /^ DOUBLE PRECISION A( LDA, * ), B( LDB,/;" L subroutine:DGESV file: +DGESV sample.f /^ SUBROUTINE DGESV(/;" s +INFO sample.f /^ INTEGER INFO,/;" L subroutine:DGESV file: +IPIV sample.f /^ INTEGER IPIV(/;" L subroutine:DGESV file: +LDA sample.f /^ INTEGER INFO, LDA,/;" L subroutine:DGESV file: +LDB sample.f /^ INTEGER INFO, LDA, LDB,/;" L subroutine:DGESV file: +N sample.f /^ INTEGER INFO, LDA, LDB, N, NR/;" L subroutine:DGESV file: +NRHS sample.f /^ INTEGER INFO, LDA, LDB, N, NRHS$/;" L subroutine:DGESV file: +SUBF77$ sample.f /^ SUBROUTINE SUBF77$(/;" s +VARF77$ sample.f /^ INTEGER VARF77\$$/;" L subroutine:SUBF77$ file: