Commit 2dec1060 authored by albert-github's avatar albert-github
Browse files

Bug 625601 - FORTRAN: recognition free versus fixed formatted code

The recognition of the type (free or fixed) of Fortran code is not reliable possible. A well known possibility as used with compilers as well is to specify the type of code by means of the extension.
With EXTENSION_MAPPING it is possible to select the type of Fortran code, when not explicitly set doxygen tries to guess the type of Fortran code.
parent 8eeaae0b
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -460,11 +460,18 @@ settings where overruled.
When using doxygen for Fortran code you should
set \ref cfg_optimize_for_fortran "OPTIMIZE_FOR_FORTRAN" to \c YES.

The parser tries to guess wheter the source code is fixed format Fortran or
free format Fortran code. This is not always correct, in the later case 
one should use \ref cfg_extension_mapping "EXTENSION_MAPPING" to correct this.
By setteing `EXTENSION_MAPPING =  f=FortranFixed f90=FortranFree` files with
extension \c f90 are interpreted as fixed format Fortran code and files with
extension \c f are interpreted as free format Fortran code.

For Fortran "!>" or "!<" starts a comment and "!!" or "!>" can be used to 
continue an one line comment into a multi-line comment.

Here is an example of a documented Fortran subroutine:
\verbatim
\code{.f}
  !> Build the restriction matrix for the aggregation 
  !! method.
  !! @param aggr information about the aggregates
@@ -474,18 +481,20 @@ Here is an example of a documented Fortran subroutine:
    Type(SpMtx), intent(in) :: A !< our fine level matrix
    Type(Aggrs), intent(in) :: aggr
    Type(SpMtx), intent(out) :: Restrict !< Our restriction matrix
\endverbatim
    !...
  end subroutine
\endcode

As an alternative you can also use comments in fixed format code:

\verbatim
\code{.f}
C> Function comment
C> another line of comment
      function A(i)
C> input parameter
        integer i
      end function A
\endverbatim
\endcode

\subsection tclblocks Comment blocks in Tcl

+4 −1
Original line number Diff line number Diff line
@@ -588,7 +588,10 @@ Go to the <a href="commands.html">next</a> section or return to the
 Doxygen has a built-in mapping, but you can override or extend it using this tag.
 The format is <code>ext=language</code>, where \c ext is a file extension, and language is one of
 the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
 Objective-C, Python, Fortran, VHDL. 
 Objective-C, Python, Fortran (fixed format Fortran: FortranFixed,
 free formatted Fortran: FortranFree, unknown formatted Fortran: Fortran. In
 the later case the parser tries to guess whether the code is fixed or free
 formatted code, this is the default for Fortran type files), VHDL. 

 For instance to make doxygen treat
 <code>.inc</code> files as Fortran files (default is PHP), and <code>.f</code> files as C (default is Fortran),
+9 −7
Original line number Diff line number Diff line
@@ -9880,6 +9880,8 @@ void initDoxygen()
  Doxygen::parserManager->registerParser("c",            new CLanguageScanner, TRUE);
  Doxygen::parserManager->registerParser("python",       new PythonLanguageScanner);
  Doxygen::parserManager->registerParser("fortran",      new FortranLanguageScanner);
  Doxygen::parserManager->registerParser("fortranfree",  new FortranLanguageScannerFree);
  Doxygen::parserManager->registerParser("fortranfixed", new FortranLanguageScannerFixed);
  Doxygen::parserManager->registerParser("vhdl",         new VHDLLanguageScanner);
  Doxygen::parserManager->registerParser("dbusxml",      new DBusXMLScanner);
  Doxygen::parserManager->registerParser("tcl",          new TclLanguageScanner);
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ void parseFortranCode(CodeOutputInterface &,const char *,const QCString &,
            bool ,const char *,FileDef *fd,
            int startLine,int endLine,bool inlineFragment,
            MemberDef *memberDef,bool showLineNumbers,Definition *searchCtx,
            bool collectRefs);
            bool collectRefs, FortranKind codeType);
void resetFortranCodeParserState();
void codeFreeScanner();

+5 −3
Original line number Diff line number Diff line
@@ -154,11 +154,13 @@ static int bracketCount = 0;

// simplified way to know if this is fixed form
// duplicate in fortranscanner.l
static bool recognizeFixedForm(const char* contents)
static bool recognizeFixedForm(const char* contents, FortranKind codeType)
{
  int column=0;
  bool skipLine=FALSE;

  if (codeType == FORTRAN_FIXED) return TRUE;
  if (codeType == FORTRAN_FREE) return FALSE;
  for (int i=0;;i++) 
  {
    column++;
@@ -1108,7 +1110,7 @@ void parseFortranCode(CodeOutputInterface &od,const char *className,const QCStri
                  bool exBlock, const char *exName,FileDef *fd,
		  int startLine,int endLine,bool inlineFragment,
		  MemberDef *memberDef,bool,Definition *searchCtx,
                  bool collectXRefs)
                  bool collectXRefs, FortranKind codeType)
{
  //printf("***parseCode() exBlock=%d exName=%s fd=%p\n",exBlock,exName,fd);

@@ -1122,7 +1124,7 @@ void parseFortranCode(CodeOutputInterface &od,const char *className,const QCStri
  g_code = &od;
  g_inputString   = s;
  g_inputPosition = 0;
  g_isFixedForm = recognizeFixedForm((const char*)s);
  g_isFixedForm = recognizeFixedForm((const char*)s,codeType);
  g_currentFontClass = 0;
  g_needsTermination = FALSE;
  g_searchCtx = searchCtx;
Loading