1 /******************************************************************************
3 * Parser for syntax hightlighting and references for Fortran90 F subset
5 * Copyright (C) by Anke Visser
6 * based on the work of Dimitri van Heesch.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
20 @todo - continutation lines not always recognized
21 - merging of use-statements with same module name and different only-names
22 - rename part of use-statement
23 - links to interface functions
24 - references to variables
37 #include <qstringlist.h>
41 #include "outputlist.h"
43 #include "membername.h"
44 #include "searchindex.h"
46 #include "memberlist.h"
49 #include "classlist.h"
51 #include "namespacedef.h"
54 // Toggle for some debugging info
55 //#define DBG_CTX(x) fprintf x
56 #define DBG_CTX(x) do { } while(0)
58 #define YY_NEVER_INTERACTIVE 1
59 #define YY_NO_TOP_STATE 1
63 * For fixed formatted code position 6 is of importance (continuation character).
64 * The following variables and macros keep track of the column number
65 * YY_USER_ACTION is always called for each scan action
66 * YY_FTN_REST is used to handle end of lines and reset the column counter
67 * YY_FTN_REJECT resets the column counters when a pattern is rejected and thus rescanned.
72 #define YY_USER_ACTION {yy_old_start = yy_my_start; yy_my_start = yy_end; yy_end += yyleng;}
73 #define YY_FTN_RESET {yy_old_start = 0; yy_my_start = 0; yy_end = 1;}
74 #define YY_FTN_REJECT {yy_end = yy_my_start; yy_my_start = yy_old_start; REJECT;}
76 //--------------------------------------------------------------------------------
79 data of an use-statement
84 QCString module; // just for debug
85 QStringList onlyNames; /* entries of the ONLY-part */
89 module name -> list of ONLY/remote entries
90 (module name = name of the module, which can be accessed via use-directive)
92 class UseSDict : public SDict<UseEntry>
95 UseSDict() : SDict<UseEntry>(17) {}
99 Contains names of used modules and names of local variables.
104 QStringList useNames; //!< contains names of used modules
105 QDict<void> localVars; //!< contains names of local variables
107 Scope() : localVars(7, FALSE /*caseSensitive*/) {}
110 /*===================================================================*/
115 static QCString docBlock; //!< contents of all lines of a documentation block
116 static QCString currentModule=0; //!< name of the current enclosing module
117 static UseSDict *useMembers= new UseSDict; //!< info about used modules
118 static UseEntry *useEntry = 0; //!< current use statement info
119 static QList<Scope> scopeStack;
120 // static QStringList *currentUseNames= new QStringList; //! contains names of used modules of current program unit
121 static QCString str=""; //!> contents of fortran string
123 static CodeOutputInterface * g_code;
125 // TODO: is this still needed? if so, make it work
126 static QCString g_parmType;
127 static QCString g_parmName;
129 static const char * g_inputString; //!< the code fragment as text
130 static int g_inputPosition; //!< read offset during parsing
131 static int g_inputLines; //!< number of line in the code fragment
132 static int g_yyLineNr; //!< current line number
133 static bool g_needsTermination;
134 static Definition *g_searchCtx;
135 static bool g_collectXRefs;
136 static bool g_isFixedForm;
138 static bool g_insideBody; //!< inside subprog/program body? => create links
139 static const char * g_currentFontClass;
141 static bool g_exampleBlock;
142 static QCString g_exampleName;
143 static QCString g_exampleFile;
145 static FileDef * g_sourceFileDef;
146 static Definition * g_currentDefinition;
147 static MemberDef * g_currentMemberDef;
148 static bool g_includeCodeFragment;
150 static char stringStartSymbol; // single or double quote
151 // count in variable declaration to filter out
152 // declared from referenced names
153 static int bracketCount = 0;
155 // simplified way to know if this is fixed form
156 // duplicate in fortranscanner.l
157 static bool recognizeFixedForm(const char* contents, FortranFormat format)
162 if (format == FortranFormat_Fixed) return TRUE;
163 if (format == FortranFormat_Free) return FALSE;
181 if(column==1) return TRUE;
185 if(column>1 && column<7) return FALSE;
190 if(column==7) return TRUE;
197 static void endFontClass()
199 if (g_currentFontClass)
201 g_code->endFontClass();
202 g_currentFontClass=0;
206 static void startFontClass(const char *s)
209 g_code->startFontClass(s);
210 g_currentFontClass=s;
213 static void setCurrentDoc(const QCString &anchor)
215 if (Doxygen::searchIndex)
219 Doxygen::searchIndex->setCurrentDoc(g_searchCtx,g_searchCtx->anchor(),FALSE);
223 Doxygen::searchIndex->setCurrentDoc(g_sourceFileDef,anchor,TRUE);
228 static void addToSearchIndex(const char *text)
230 if (Doxygen::searchIndex)
232 Doxygen::searchIndex->addWord(text,FALSE);
236 /*! start a new line of code, inserting a line number if g_sourceFileDef
237 * is TRUE. If a definition starts at the current line, then the line
238 * number is linked to the documentation of that definition.
240 static void startCodeLine()
244 //QCString lineNumber,lineAnchor;
245 //lineNumber.sprintf("%05d",g_yyLineNr);
246 //lineAnchor.sprintf("l%05d",g_yyLineNr);
248 Definition *d = g_sourceFileDef->getSourceDefinition(g_yyLineNr);
249 //printf("startCodeLine %d d=%s\n", g_yyLineNr,d ? d->name().data() : "<null>");
250 if (!g_includeCodeFragment && d)
252 g_currentDefinition = d;
253 g_currentMemberDef = g_sourceFileDef->getSourceMember(g_yyLineNr);
254 g_insideBody = FALSE;
255 g_parmType.resize(0);
256 g_parmName.resize(0);
258 lineAnchor.sprintf("l%05d",g_yyLineNr);
259 if (g_currentMemberDef)
261 g_code->writeLineNumber(g_currentMemberDef->getReference(),
262 g_currentMemberDef->getOutputFileBase(),
263 g_currentMemberDef->anchor(),g_yyLineNr);
264 setCurrentDoc(lineAnchor);
266 else if (d->isLinkableInProject())
268 g_code->writeLineNumber(d->getReference(),
269 d->getOutputFileBase(),
271 setCurrentDoc(lineAnchor);
276 g_code->writeLineNumber(0,0,0,g_yyLineNr);
279 g_code->startCodeLine(g_sourceFileDef);
280 if (g_currentFontClass)
282 g_code->startFontClass(g_currentFontClass);
287 static void endFontClass();
288 static void endCodeLine()
291 g_code->endCodeLine();
294 /*! write a code fragment `text' that may span multiple lines, inserting
295 * line numbers for each line.
297 static void codifyLines(char *text)
299 //printf("codifyLines(%d,\"%s\")\n",g_yyLineNr,text);
303 const char * tmp_currentFontClass = g_currentFontClass;
307 while ((c=*p++) && c!='\n') { }
314 if (g_yyLineNr<g_inputLines)
318 if (tmp_currentFontClass)
320 startFontClass(tmp_currentFontClass);
331 static void codifyLines(QCString str)
333 char *tmp= (char *) malloc(str.length()+1);
339 /*! writes a link to a fragment \a text that may span multiple lines, inserting
340 * line numbers for each line. If \a text contains newlines, the link will be
341 * split into multiple links with the same destination, one for each line.
343 static void writeMultiLineCodeLink(CodeOutputInterface &ol,
344 Definition *d,const char *text)
346 static bool sourceTooltips = Config_getBool("SOURCE_TOOLTIPS");
347 TooltipManager::instance()->addTooltip(d);
348 QCString ref = d->getReference();
349 QCString file = d->getOutputFileBase();
350 QCString anchor = d->anchor();
352 if (!sourceTooltips) // fall back to simple "title" tooltips
354 tooltip = d->briefDescriptionAsTooltip();
357 char *p=(char *)text;
362 while ((c=*p++) && c!='\n') { }
367 //printf("writeCodeLink(%s,%s,%s,%s)\n",ref,file,anchor,sp);
368 ol.writeCodeLink(ref,file,anchor,sp,tooltip);
370 if (g_yyLineNr<g_inputLines)
377 //printf("writeCodeLink(%s,%s,%s,%s)\n",ref,file,anchor,sp);
378 ol.writeCodeLink(ref,file,anchor,sp,tooltip);
385 //-------------------------------------------------------------------------------
387 searches for definition of a type
388 @param tname the name of the type
389 @param moduleName name of enclosing module or null, if global entry
390 @param cd the entry, if found or null
391 @param useDict dictionary of data of USE-statement
392 @returns true, if type is found
394 static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName,
395 ClassDef *&cd, UseSDict *usedict=0)
397 if (tname.isEmpty()) return FALSE; /* empty name => nothing to link */
399 //cout << "=== search for type: " << tname << endl;
402 if ((cd=Doxygen::classSDict->find(tname)))
404 //cout << "=== type found in global module" << endl;
407 else if (moduleName && (cd= Doxygen::classSDict->find(moduleName+"::"+tname)))
409 //cout << "=== type found in local module" << endl;
415 for (UseSDict::Iterator di(*usedict); (use=di.current()); ++di)
417 if ((cd= Doxygen::classSDict->find(use->module+"::"+tname)))
419 //cout << "=== type found in used module" << endl;
429 searches for definition of function memberName
430 @param memberName the name of the function/variable
431 @param moduleName name of enclosing module or null, if global entry
432 @param md the entry, if found or null
433 @param usedict array of data of USE-statement
434 @returns true, if found
436 static bool getFortranDefs(const QCString &memberName, const QCString &moduleName,
437 MemberDef *&md, UseSDict *usedict=0)
439 if (memberName.isEmpty()) return FALSE; /* empty name => nothing to link */
441 // look in local variables
442 QListIterator<Scope> it(scopeStack);
444 for (it.toLast();(scope=it.current());--it)
446 if (scope->localVars.find(memberName))
450 // search for function
451 MemberName *mn = Doxygen::functionNameSDict->find(memberName);
454 mn = Doxygen::memberNameSDict->find(memberName);
457 if (mn) // name is known
459 MemberListIterator mli(*mn);
460 for (mli.toFirst();(md=mli.current());++mli) // all found functions with given name
462 FileDef *fd=md->getFileDef();
463 GroupDef *gd=md->getGroupDef();
465 //cout << "found link with same name: " << fd->fileName() << " " << memberName;
466 //if (md->getNamespaceDef() != 0) cout << " in namespace " << md->getNamespaceDef()->name();cout << endl;
468 if ((gd && gd->isLinkable()) || (fd && fd->isLinkable()))
470 NamespaceDef *nspace= md->getNamespaceDef();
473 { // found function in global scope
476 else if (moduleName == nspace->name())
477 { // found in local scope
481 { // else search in used modules
482 QCString moduleName= nspace->name();
483 UseEntry *ue= usedict->find(moduleName);
486 // check if only-list exists and if current entry exists is this list
487 QStringList &only= ue->onlyNames;
490 //cout << " found in module " << moduleName << " entry " << memberName << endl;
491 return TRUE; // whole module used
495 for ( QStringList::Iterator it = only.begin(); it != only.end(); ++it)
497 //cout << " search in only: " << moduleName << ":: " << memberName << "==" << (*it)<< endl;
498 if (memberName == (*it).utf8())
500 return TRUE; // found in ONLY-part of use list
513 gets the link to a generic procedure which depends not on the name, but on the parameter list
516 static bool getGenericProcedureLink(const ClassDef *cd,
517 const char *memberText,
518 CodeOutputInterface &ol)
526 static bool getLink(UseSDict *usedict, // dictonary with used modules
527 const char *memberText, // exact member text
528 CodeOutputInterface &ol,
532 QCString memberName= removeRedundantWhiteSpace(memberText);
534 if (getFortranDefs(memberName, currentModule, md, usedict) && md->isLinkable())
536 //if (md->isVariable()) return FALSE; // variables aren't handled yet
538 Definition *d = md->getOuterScope()==Doxygen::globalScope ?
539 md->getBodyDef() : md->getOuterScope();
540 if (md->getGroupDef()) d = md->getGroupDef();
541 if (d && d->isLinkable())
543 if (g_currentDefinition && g_currentMemberDef &&
544 md!=g_currentMemberDef && g_insideBody && g_collectXRefs)
546 addDocCrossReference(g_currentMemberDef,md);
548 writeMultiLineCodeLink(ol,md,text ? text : memberText);
549 addToSearchIndex(text ? text : memberText);
557 static void generateLink(CodeOutputInterface &ol, char *lname)
560 QCString tmp = lname;
561 tmp = removeRedundantWhiteSpace(tmp.lower());
563 // check if lowercase lname is a linkable type or interface
564 if ( (getFortranTypeDefs(tmp, currentModule, cd, useMembers)) && cd->isLinkable() )
566 if ( (cd->compoundType() == ClassDef::Class) && // was Entry::INTERFACE_SEC) &&
567 (getGenericProcedureLink(cd, tmp, ol)) )
569 //cout << "=== generic procedure resolved" << endl;
572 { // write type or interface link
573 writeMultiLineCodeLink(ol,cd,tmp);
574 addToSearchIndex(tmp.data());
577 // check for function/variable
578 else if (getLink(useMembers, tmp, ol, tmp))
580 //cout << "=== found link for lowercase " << lname << endl;
584 // nothing found, just write out the word
585 //startFontClass("charliteral"); //test
587 //endFontClass(); //test
588 addToSearchIndex(tmp.data());
592 /*! counts the number of lines in the input */
593 static int countLines()
595 const char *p=g_inputString;
601 if (c=='\n') count++;
603 if (p>g_inputString && *(p-1)!='\n')
604 { // last line does not end with a \n, so we add an extra
605 // line and explicitly terminate the line after parsing.
607 g_needsTermination=TRUE;
612 //----------------------------------------------------------------------------
614 static void startScope()
616 DBG_CTX((stderr, "===> startScope %s",yytext));
617 Scope *scope = new Scope;
618 scopeStack.append(scope);
622 static void endScope()
624 DBG_CTX((stderr,"===> endScope %s",yytext));
625 if (scopeStack.isEmpty())
627 DBG_CTX((stderr,"WARNING: fortrancode.l: stack empty!\n"));
631 Scope *scope = scopeStack.getLast();
632 scopeStack.removeLast();
633 for ( QStringList::Iterator it = scope->useNames.begin(); it != scope->useNames.end(); ++it)
635 useMembers->remove((*it).utf8());
640 static void addUse(const QCString &moduleName)
642 if (!scopeStack.isEmpty())
643 scopeStack.getLast()->useNames.append(moduleName);
646 static void addLocalVar(const QCString &varName)
648 if (!scopeStack.isEmpty())
649 scopeStack.getLast()->localVars.insert(varName, (void*)1);
652 //----------------------------------------------------------------------------
654 /* -----------------------------------------------------------------*/
656 #define YY_INPUT(buf,result,max_size) result=yyread(buf,max_size);
658 static int yyread(char *buf,int max_size)
661 while( c < max_size && g_inputString[g_inputPosition] )
663 *buf = g_inputString[g_inputPosition++] ;
672 ID [a-z_A-Z]+{IDSYM}*
673 SUBPROG (subroutine|function)
678 ARGS_L0 ("("[^)]*")")
679 ARGS_L1a [^()]*"("[^)]*")"[^)]*
680 ARGS_L1 ("("{ARGS_L1a}*")")
681 ARGS_L2 "("({ARGS_L0}|[^()]|{ARGS_L1a}|{ARGS_L1})*")"
682 ARGS {BS}({ARGS_L0}|{ARGS_L1}|{ARGS_L2})
684 NUM_TYPE (complex|integer|logical|real)
685 LOG_OPER (\.and\.|\.eq\.|\.eqv\.|\.ge\.|\.gt\.|\.le\.|\.lt\.|\.ne\.|\.neqv\.|\.or\.|\.not\.)
687 CHAR (CHARACTER{ARGS}?|CHARACTER{BS}"*"({BS}[0-9]+|{ARGS}))
688 TYPE_SPEC (({NUM_TYPE}({BS}"*"{BS}[0-9]+)?)|({NUM_TYPE}{KIND})|DOUBLE{BS}COMPLEX|DOUBLE{BS}PRECISION|{CHAR})
690 INTENT_SPEC intent{BS}"("{BS}(in|out|in{BS}out){BS}")"
691 ATTR_SPEC (IMPLICIT|ALLOCATABLE|DIMENSION{ARGS}|EXTERNAL|{INTENT_SPEC}|INTRINSIC|OPTIONAL|PARAMETER|POINTER|PROTECTED|PRIVATE|PUBLIC|SAVE|TARGET|RECURSIVE|PURE|IMPURE|ELEMENTAL)
692 ACCESS_SPEC (PROTECTED|PRIVATE|PUBLIC)
693 /* Assume that attribute statements are almost the same as attributes. */
694 ATTR_STMT {ATTR_SPEC}|DIMENSION
695 FLOW (DO|SELECT|CASE|SELECTCASE|WHERE|IF|THEN|ELSE|WHILE|FORALL|ELSEWHERE|ELSEIF|RETURN|CONTINUE|EXIT)
696 COMMANDS (FORMAT|CONTAINS|MODULE{BS_}PROCEDURE|WRITE|READ|ALLOCATE|ALLOCATED|ASSOCIATED|DEALLOCATE|SIZE|INQUIRE|OPEN|CLOSE|DATA|COMMON)
698 PREFIX (RECURSIVE{BS_}|IMPURE{BS_}|PURE{BS_}|ELEMENTAL{BS_}){0,3}(RECURSIVE|IMPURE|PURE|ELEMENTAL)?
724 /*==================================================================*/
726 /*-------- ignore ------------------------------------------------------------*/
728 <Start>{IGNORE}/{BS}"("? { // do not search keywords, intrinsics... TODO: complete list
731 /*-------- inner construct ---------------------------------------------------*/
733 <Start>{COMMANDS}/[,( \t\n].* { // highlight
734 /* font class is defined e.g. in doxygen.css */
735 startFontClass("keyword");
739 <Start>{FLOW}/[,( \t\n].* {
742 if ((yy_my_start == 1) && ((yytext[0] == 'c') || (yytext[0] == 'C'))) YY_FTN_REJECT;
744 /* font class is defined e.g. in doxygen.css */
745 startFontClass("keywordflow");
749 <Start>"end"({BS}{FLOW})?/[ \t\n] { // list is a bit long as not all have possible end
750 startFontClass("keywordflow");
755 <Start>"implicit"{BS}"none" {
756 startFontClass("keywordtype");
760 /*-------- use statement -------------------------------------------*/
762 startFontClass("keywordtype");
765 yy_push_state(YY_START);
769 QCString tmp = yytext;
772 generateLink(*g_code, yytext);
775 /* append module name to use dict */
776 useEntry = new UseEntry();
777 //useEntry->module = yytext;
778 //useMembers->append(yytext, useEntry);
780 useEntry->module = tmp;
781 useMembers->append(tmp, useEntry);
784 <Use>,{BS}"ONLY" { // TODO: rename
785 startFontClass("keywordtype");
788 yy_push_state(YY_START);
791 <UseOnly>{BS},{BS} { codifyLines(yytext); }
792 <UseOnly>{BS}&{BS}"\n" { codifyLines(yytext); YY_FTN_RESET}
795 generateLink(*g_code, yytext);
797 useEntry->onlyNames.append(yytext);
801 yy_pop_state();YY_FTN_RESET
804 /*-------- fortran module -----------------------------------------*/
805 <Start>("block"{BS}"data"|"program"|"module"|"type"|"interface")/{BS_}|({COMMA}{ACCESS_SPEC})|\n { //
807 startFontClass("keyword");
810 yy_push_state(YY_START);
812 if (!qstricmp(yytext,"module")) currentModule="module";
815 if (currentModule == "module")
817 currentModule=yytext;
818 currentModule = currentModule.lower();
820 generateLink(*g_code,yytext);
823 <ClassName>\n { // interface may be without name
827 <Start>"end"({BS_}"module").* { // just reset currentModule, rest is done in following rule
831 /*-------- subprog definition -------------------------------------*/
832 <Start>({PREFIX}{BS_})?{TYPE_SPEC}{BS_}({PREFIX}{BS_})?{BS}/{SUBPROG}{BS_} { // TYPE_SPEC is for old function style function result
833 startFontClass("keyword");
837 <Start>({PREFIX}{BS_})?{SUBPROG}{BS_} { // Fortran subroutine or function found
838 startFontClass("keyword");
841 yy_push_state(YY_START);
844 <Subprog>{ID} { // subroutine/function name
845 DBG_CTX((stderr, "===> start subprogram %s\n", yytext));
847 generateLink(*g_code,yytext);
849 <Subprog>"(".* { // ignore rest of line
852 <Subprog,Subprogend>"\n" { codifyLines(yytext);
856 <Start>^{BS}"end"{BS}("block"{BS}"data"|{SUBPROG}|"module"|"program"|"type"|"interface"){BS} { // Fortran subroutine or function ends
857 //cout << "===> end function " << yytext << endl;
859 startFontClass("keyword");
862 yy_push_state(YY_START);
865 <Subprogend>{ID}/{BS}(\n|!) {
866 generateLink(*g_code,yytext);
869 <Start>^{BS}"end"{BS}("block"{BS}"data"|{SUBPROG}|"module"|"program"|"type"|"interface"){BS}/(\n|!) { // Fortran subroutine or function ends
870 //cout << "===> end function " << yytext << endl;
872 startFontClass("keyword");
876 /*-------- variable declaration ----------------------------------*/
877 <Start>"type"{BS}"(" {
878 yy_push_state(YY_START);
880 startFontClass("keywordtype");
881 g_code->codify(yytext);
884 <TypeDecl>{ID} { // link type
886 generateLink(*g_code,yytext);
891 startFontClass("keywordtype");
892 g_code->codify(yytext);
895 <Start>{TYPE_SPEC}/[,:( ] {
896 yy_push_state(YY_START);
898 startFontClass("keywordtype");
899 g_code->codify(yytext);
903 startFontClass("keywordtype");
904 g_code->codify(yytext);
907 <Declaration>({TYPE_SPEC}|{ATTR_SPEC})/[,:( ] { //| variable deklaration
908 startFontClass("keywordtype");
909 g_code->codify(yytext);
912 <Declaration>{ID} { // local var
913 if (g_currentMemberDef && !g_currentMemberDef->isFunction())
915 g_code->codify(yytext);
920 generateLink(*g_code, yytext);
923 <Declaration>[(] { // start of array specification
925 g_code->codify(yytext);
928 <Declaration>[)] { // end array specification
930 g_code->codify(yytext);
933 <Declaration>"&" { // continuation line
934 g_code->codify(yytext);
935 yy_push_state(YY_START);
938 <DeclContLine>"\n" { // declaration not yet finished
944 <Declaration>"\n" { // end declaration line
951 /*-------- subprog calls -----------------------------------------*/
955 yy_push_state(YY_START);
958 <SubCall>{ID} { // subroutine call
960 generateLink(*g_code, yytext);
964 <Start>{ID}{BS}/"(" { // function call
966 generateLink(*g_code, yytext);
970 /*-------- comments ---------------------------------------------------*/
971 <Start>\n?{BS}"!>"|"!<" { // start comment line or comment block
972 if (yytext[0] == '\n')
978 // Actually we should see if ! on position 6, can be continuation
979 // but the chance is very unlikely, so no effort to solve it here
980 yy_push_state(YY_START);
984 <Declaration>{BS}"!<" { // start comment line or comment block
985 yy_push_state(YY_START);
990 <DocBlock>.* { // contents of current comment line
993 <DocBlock>"\n"{BS}("!>"|"!<"|"!!") { // comment block (next line is also comment line)
997 // Actually we should see if ! on position 6, can be continuation
998 // but the chance is very unlikely, so no effort to solve it here
1001 <DocBlock>"\n" { // comment block ends at the end of this line
1003 // remove special comment (default config)
1004 if (Config_getBool("STRIP_CODE_COMMENTS"))
1006 g_yyLineNr+=((QCString)docBlock).contains('\n');
1008 if (g_yyLineNr<g_inputLines)
1013 else // do not remove comment
1015 startFontClass("comment");
1016 codifyLines(docBlock);
1023 <*>"!"[^><\n].*|"!"$ { // normal comment
1024 if(YY_START == String) YY_FTN_REJECT; // ignore in strings
1025 if (g_isFixedForm && yy_my_start == 6) YY_FTN_REJECT;
1026 startFontClass("comment");
1027 codifyLines(yytext);
1031 <*>^[Cc*].* { // normal comment
1032 if(! g_isFixedForm) YY_FTN_REJECT;
1034 startFontClass("comment");
1035 codifyLines(yytext);
1039 /*------ preprocessor --------------------------------------------*/
1041 if (g_isFixedForm && yy_my_start == 6) YY_FTN_REJECT;
1042 startFontClass("preprocessor");
1043 codifyLines(yytext);
1047 /*------ variable references? -------------------------------------*/
1049 <Start>"%"{BS}{ID} { // ignore references to elements
1050 g_code->codify(yytext);
1054 generateLink(*g_code, yytext);
1057 /*------ strings --------------------------------------------------*/
1058 <*>"\\\\" { str+=yytext; /* ignore \\ */}
1059 <*>"\\\""|\\\' { str+=yytext; /* ignore \" */}
1061 <String>\n { // string with \n inside
1063 startFontClass("stringliteral");
1069 <String>\"|\' { // string ends with next quote without previous backspace
1070 if(yytext[0]!=stringStartSymbol) YY_FTN_REJECT; // single vs double quote
1072 startFontClass("stringliteral");
1077 <String>. {str+=yytext;}
1079 <*>\"|\' { /* string starts */
1080 /* if(YY_START == StrIgnore) YY_FTN_REJECT; // ignore in simple comments */
1081 if (g_isFixedForm && yy_my_start == 6) YY_FTN_REJECT;
1082 yy_push_state(YY_START);
1083 stringStartSymbol=yytext[0]; // single or double quote
1087 /*-----------------------------------------------------------------------------*/
1090 codifyLines(yytext);
1094 g_code->codify(yytext);
1096 <*>{LOG_OPER} { // Fortran logical comparison keywords
1097 g_code->codify(yytext);
1101 /*@ ----------------------------------------------------------------------------
1104 /*===================================================================*/
1107 void resetFortranCodeParserState() {}
1109 void parseFortranCode(CodeOutputInterface &od,const char *className,const QCString &s,
1110 bool exBlock, const char *exName,FileDef *fd,
1111 int startLine,int endLine,bool inlineFragment,
1112 MemberDef *memberDef,bool,Definition *searchCtx,
1113 bool collectXRefs, FortranFormat format)
1115 //printf("***parseCode() exBlock=%d exName=%s fd=%p\n",exBlock,exName,fd);
1121 if (s.isEmpty()) return;
1122 printlex(yy_flex_debug, TRUE, __FILE__, fd ? fd->fileName().data(): NULL);
1123 TooltipManager::instance()->clearTooltips();
1126 g_inputPosition = 0;
1127 g_isFixedForm = recognizeFixedForm((const char*)s,format);
1128 g_currentFontClass = 0;
1129 g_needsTermination = FALSE;
1130 g_searchCtx = searchCtx;
1131 g_collectXRefs = collectXRefs;
1133 g_inputLines = endLine+1;
1135 g_inputLines = countLines();
1138 g_yyLineNr = startLine;
1142 g_exampleBlock = exBlock;
1143 g_exampleName = exName;
1144 g_sourceFileDef = fd;
1145 if (exBlock && fd==0)
1147 // create a dummy filedef for the example
1148 g_sourceFileDef = new FileDef("",exName);
1150 if (g_sourceFileDef)
1152 setCurrentDoc("l00001");
1154 g_currentDefinition = 0;
1155 g_currentMemberDef = 0;
1156 if (!g_exampleName.isEmpty())
1158 g_exampleFile = convertNameToFile(g_exampleName+"-example");
1160 g_includeCodeFragment = inlineFragment;
1162 g_parmName.resize(0);
1163 g_parmType.resize(0);
1164 fortrancodeYYrestart( fortrancodeYYin );
1167 if (g_needsTermination)
1170 g_code->endCodeLine();
1174 TooltipManager::instance()->writeTooltips(*g_code);
1176 if (exBlock && g_sourceFileDef)
1178 // delete the temporary file definition used for this example
1179 delete g_sourceFileDef;
1182 printlex(yy_flex_debug, FALSE, __FILE__, fd ? fd->fileName().data(): NULL);
1186 #if !defined(YY_FLEX_SUBMINOR_VERSION)
1187 extern "C" { // some bogus code to keep the compiler happy
1188 void fortrancodeYYdummy() { yy_flex_realloc(0,0); }
1190 #elif YY_FLEX_SUBMINOR_VERSION<33
1191 #error "You seem to be using a version of flex newer than 2.5.4 but older than 2.5.33. These versions do NOT work with doxygen! Please use version <=2.5.4 or >=2.5.33 or expect things to be parsed wrongly!"
1193 extern "C" { // some bogus code to keep the compiler happy
1194 void fortrancodeYYdummy() { yy_top_state(); }