Orb/Doxygen/src/fortranscanner.l
changeset 4 468f4c8d3d5b
parent 0 42188c7ea2d9
equal deleted inserted replaced
3:d8fccb2cd802 4:468f4c8d3d5b
   152 static QCString          result; // function result
   152 static QCString          result; // function result
   153 static Argument          *parameter; // element of parameter list
   153 static Argument          *parameter; // element of parameter list
   154 static QCString          argType;  // fortran type of an argument of a parameter list
   154 static QCString          argType;  // fortran type of an argument of a parameter list
   155 static QCString          argName;  // last identifier name in variable list
   155 static QCString          argName;  // last identifier name in variable list
   156 static QCString          initializer;  // initial value of a variable
   156 static QCString          initializer;  // initial value of a variable
   157 static int               initializerScope;  // number if nested array scopes in initializer
   157 static int               initializerArrayScope;  // number if nested array scopes in initializer
       
   158 static int               initializerScope;  // number if nested function calls in initializer
   158 static QCString          useModuleName;  // name of module in the use statement
   159 static QCString          useModuleName;  // name of module in the use statement
   159 static Protection        defaultProtection;
   160 static Protection        defaultProtection;
   160 
   161 
   161 static char              stringStartSymbol; // single or double quote
   162 static char              stringStartSymbol; // single or double quote
   162 
   163 
   308                                             }
   309                                             }
   309 
   310 
   310                                         }
   311                                         }
   311 
   312 
   312 
   313 
   313  /*------ ignore strings */ 
   314  /*------ ignore strings that are not initialization strings */ 
   314 <*>"\\\\"                               { /* ignore \\  */}
   315 <*>"\\\\"				{ if (yy_top_state() == Initialization
   315 <*>"\\\""|\\\'                          { /* ignore \" and \'  */}
   316 					      || yy_top_state() == ArrayInitializer)
   316 
   317 					    initializer+=yytext;
       
   318 					}
       
   319 <*>"\\\""|\\\'                          { if (yy_top_state() == Initialization
       
   320 					      || yy_top_state() == ArrayInitializer)
       
   321 					    initializer+=yytext;
       
   322 					}
   317 <String>\"|\'                           { // string ends with next quote without previous backspace
   323 <String>\"|\'                           { // string ends with next quote without previous backspace
   318                                           if (yytext[0]!=stringStartSymbol) REJECT; // single vs double quote
   324                                           if (yytext[0]!=stringStartSymbol) REJECT; // single vs double quote
   319                                           // fprintf(stderr,"string end: %s\n",debugStr.data());
   325 					  if (yy_top_state() == Initialization
       
   326 					      || yy_top_state() == ArrayInitializer)
       
   327 					    initializer+=yytext;
   320                                           yy_pop_state();
   328                                           yy_pop_state();
   321                                         }           
   329                                         }           
   322 
   330 <String>.                               { if (yy_top_state() == Initialization
   323 <String>.                               { debugStr+=yytext; } // ignore String contents (especially '!') 
   331 					      || yy_top_state() == ArrayInitializer)
   324 
   332 					    initializer+=yytext;
       
   333 					} 
   325 <*>\"|\'                                { /* string starts */
   334 <*>\"|\'                                { /* string starts */
   326 					  if (YY_START == StrIgnore) REJECT; // ignore in simple comments
   335 					  if (YY_START == StrIgnore) REJECT; // ignore in simple comments
   327                                           // fprintf(stderr,"string start: %c %d\n",yytext[0],yyLineNr);
       
   328                                           yy_push_state(YY_START);
   336                                           yy_push_state(YY_START);
       
   337                                           if (yy_top_state() == Initialization
       
   338 					      || yy_top_state() == ArrayInitializer)
       
   339 					    initializer+=yytext;
   329                                           stringStartSymbol=yytext[0]; // single or double quote
   340                                           stringStartSymbol=yytext[0]; // single or double quote
   330                                           BEGIN(String); debugStr="!^!";
   341                                           BEGIN(String);
   331                                         }
   342                                         }
   332 
   343 
   333  /*------ ignore simple comment (not documentation comments) */
   344  /*------ ignore simple comment (not documentation comments) */
   334 
   345 
   335 <*>"!"/[^<>\n]                         {  if (YY_START == String) REJECT; // "!" is ignored in strings
   346 <*>"!"/[^<>\n]                         {  if (YY_START == String) REJECT; // "!" is ignored in strings
   627 					  modifiers[current_root][name] |= attr;
   638 					  modifiers[current_root][name] |= attr;
   628 					}
   639 					}
   629 <Variable>{COMMA}	                {}
   640 <Variable>{COMMA}	                {}
   630 <Variable>{BS}"="                       { yy_push_state(YY_START);
   641 <Variable>{BS}"="                       { yy_push_state(YY_START);
   631                                           initializer="";
   642                                           initializer="";
   632                                           initializerScope = 0;
   643                                           initializerScope = initializerArrayScope = 0;
   633 					  BEGIN(Initialization);
   644 					  BEGIN(Initialization);
   634                                         }
   645                                         }
   635 <Variable>"\n"	                        { currentModifiers = SymbolModifiers();
   646 <Variable>"\n"	                        { currentModifiers = SymbolModifiers();
   636                                           yy_pop_state(); // end variable deklaration list
   647                                           yy_pop_state(); // end variable deklaration list
   637                                           yyLineNr++; yyLineNr+=lineCountPrepass; lineCountPrepass=0;
   648                                           yyLineNr++; yyLineNr+=lineCountPrepass; lineCountPrepass=0;
   638                                           docBlock.resize(0);
   649                                           docBlock.resize(0);
   639                                         }
   650                                         }
   640 
   651 
   641 <Initialization,ArrayInitializer>"(/"   { initializer+=yytext;
   652 <Initialization,ArrayInitializer>"(/"   { initializer+=yytext;
   642                                            initializerScope++;
   653                                            initializerArrayScope++;
   643                                            BEGIN(ArrayInitializer); // initializer may contain comma
   654                                            BEGIN(ArrayInitializer); // initializer may contain comma
   644                                         }
   655                                         }
   645 <ArrayInitializer>"/)"                   { initializer+=yytext;
   656 <ArrayInitializer>"/)"                   { initializer+=yytext;
   646                                            initializerScope--;
   657                                            initializerArrayScope--;
   647                                            if(initializerScope<=0)
   658                                            if(initializerArrayScope<=0)
   648                                            {
   659                                            {
   649                                               initializerScope = 0; // just in case
   660                                               initializerArrayScope = 0; // just in case
   650                                               BEGIN(Initialization);
   661                                               BEGIN(Initialization);
   651                                            }
   662                                            }
   652                                         }
   663                                         }
   653 <ArrayInitializer>.                     { initializer+=yytext; }
   664 <ArrayInitializer>.                     { initializer+=yytext; }
   654 <Initialization>{COMMA}                 { yy_pop_state(); // end initialization
   665 <Initialization>"("			{ initializerScope++;
   655                                           if (v_type == V_VARIABLE) last_entry->initializer= initializer;
   666 					  initializer+=yytext;
   656                                         }
   667 					}
   657 <Initialization>"\n"|"!"                { //| 
   668 <Initialization>")"			{ initializerScope--;
       
   669 					  initializer+=yytext;
       
   670 					}
       
   671 <Initialization>{COMMA}                 { if (initializerScope == 0)
       
   672 					  {
       
   673 					    yy_pop_state(); // end initialization
       
   674                                             if (v_type == V_VARIABLE) last_entry->initializer= initializer;
       
   675 					  }
       
   676 					  else
       
   677 					    initializer+=", ";
       
   678 					}
       
   679 <Initialization>"\n"|"!"                { //|
   658                                           yy_pop_state(); // end initialization
   680                                           yy_pop_state(); // end initialization
   659                                           if (v_type == V_VARIABLE) last_entry->initializer= initializer;
   681                                           if (v_type == V_VARIABLE) last_entry->initializer= initializer;
   660  					  unput(*yytext);
   682  					  unput(*yytext);
   661                                         }
   683                                         }
   662 <Initialization>.                       { initializer+=yytext; }
   684 <Initialization>.                       { initializer+=yytext; }
  1661   if (inputFile.open(IO_ReadOnly))
  1683   if (inputFile.open(IO_ReadOnly))
  1662   {
  1684   {
  1663     isFixedForm = recognizeFixedForm(fileBuf);
  1685     isFixedForm = recognizeFixedForm(fileBuf);
  1664 
  1686 
  1665     if (isFixedForm) {
  1687     if (isFixedForm) {
  1666       printf("Prepassing fixed form of %s\n", yyFileName.data());
  1688       printf("Prepassing fixed form of %s\n", fileName);
  1667       //printf("---strlen=%d\n", strlen(fileBuf));
  1689       //printf("---strlen=%d\n", strlen(fileBuf));
  1668       //clock_t start=clock();
  1690       //clock_t start=clock();
  1669 
  1691 
  1670       inputString = prepassFixedForm(fileBuf);
  1692       inputString = prepassFixedForm(fileBuf);
  1671 
  1693 
  1727                    const char * exampleName,
  1749                    const char * exampleName,
  1728                    FileDef * fileDef,
  1750                    FileDef * fileDef,
  1729                    int startLine,
  1751                    int startLine,
  1730                    int endLine,
  1752                    int endLine,
  1731                    bool inlineFragment,
  1753                    bool inlineFragment,
  1732 		   MemberDef *memberDef
  1754 		   MemberDef *memberDef,
       
  1755                    bool showLineNumbers
  1733                   )
  1756                   )
  1734 {
  1757 {
  1735   ::parseFortranCode(codeOutIntf,scopeName,input,isExampleBlock,exampleName,
  1758   ::parseFortranCode(codeOutIntf,scopeName,input,isExampleBlock,exampleName,
  1736                      fileDef,startLine,endLine,inlineFragment,memberDef);
  1759                      fileDef,startLine,endLine,inlineFragment,memberDef,
       
  1760                      showLineNumbers);
  1737 }
  1761 }
  1738 
  1762 
  1739 bool FortranLanguageScanner::needsPreprocessing(const QCString &extension)
  1763 bool FortranLanguageScanner::needsPreprocessing(const QCString &extension)
  1740 {
  1764 {
  1741   (void)extension;
  1765   (void)extension;