Orb/Doxygen/src/commentscan.l
changeset 4 468f4c8d3d5b
parent 3 d8fccb2cd802
equal deleted inserted replaced
3:d8fccb2cd802 4:468f4c8d3d5b
     1 /*****************************************************************************
     1 /*****************************************************************************
     2  *
     2  *
     3  * Copyright (C) 1997-2008 by Dimitri van Heesch.
     3  * Copyright (C) 1997-2010 by Dimitri van Heesch.
     4  *
     4  *
     5  * Permission to use, copy, modify, and distribute this software and its
     5  * Permission to use, copy, modify, and distribute this software and its
     6  * documentation under the terms of the GNU General Public License is hereby 
     6  * documentation under the terms of the GNU General Public License is hereby 
     7  * granted. No representations are made about the suitability of this software 
     7  * granted. No representations are made about the suitability of this software 
     8  * for any purpose. It is provided "as is" without express or implied warranty.
     8  * for any purpose. It is provided "as is" without express or implied warranty.
   393 static bool             xrefAppendFlag;
   393 static bool             xrefAppendFlag;
   394 static bool             inGroupParamFound;
   394 static bool             inGroupParamFound;
   395 static int              braceCount;
   395 static int              braceCount;
   396 static bool             insidePre;
   396 static bool             insidePre;
   397 static bool             parseMore;
   397 static bool             parseMore;
       
   398 static int              g_condCount;
       
   399 static int              g_sectionLevel;
   398 
   400 
   399 static int              g_commentCount;
   401 static int              g_commentCount;
   400 
   402 
   401 //-----------------------------------------------------------------------------
   403 //-----------------------------------------------------------------------------
   402 
   404 
   690       if (oldContext!=inContext)
   692       if (oldContext!=inContext)
   691       {
   693       {
   692         stripTrailingWhiteSpace(current->doc);
   694         stripTrailingWhiteSpace(current->doc);
   693         if (current->docFile.isEmpty())
   695         if (current->docFile.isEmpty())
   694         {
   696         {
   695 		  //printf("Setting docFile to %s\n", yyFileName.data());
       
   696           current->docFile = yyFileName;
   697           current->docFile = yyFileName;
   697           current->docLine = yyLineNr;
   698           current->docLine = yyLineNr;
   698         }
   699         }
   699       }
   700       }
   700       pOutputString = &current->doc;
   701       pOutputString = &current->doc;
  1028   					  addOutput(yytext[2]);
  1029   					  addOutput(yytext[2]);
  1029   					}
  1030   					}
  1030 <Comment>".,"				{ // . with comma such as "e.g.," 
  1031 <Comment>".,"				{ // . with comma such as "e.g.," 
  1031   					  addOutput(yytext);
  1032   					  addOutput(yytext);
  1032   					}
  1033   					}
       
  1034 <Comment>"...\\"[ \t]			{ // ellipsis with escaped space.
       
  1035   					  addOutput("... ");
       
  1036   					}
       
  1037 <Comment>".."[\.]?/[^ \t\n] 		{ // internal ellipsis 
       
  1038   					  addOutput(yytext);
       
  1039   					}
  1033 <Comment>(\n|\\_linebr)({B}*(\n|\\_linebr))+	{ // at least one blank line (or blank line command)
  1040 <Comment>(\n|\\_linebr)({B}*(\n|\\_linebr))+	{ // at least one blank line (or blank line command)
  1034   					  if (inContext!=OutputBrief)
  1041 					  if (inContext==OutputXRef)
       
  1042 					  {
       
  1043 					    // see bug 613024, we need to put the newlines after ending the XRef section.
       
  1044 					    setOutput(OutputDoc);
       
  1045   					    addOutput("\n\n");
       
  1046 					  }
       
  1047 					  else if (inContext!=OutputBrief)
  1035 					  {
  1048 					  {
  1036   					    addOutput("\n\n");
  1049   					    addOutput("\n\n");
  1037 					    setOutput(OutputDoc);
  1050 					    setOutput(OutputDoc);
  1038 					  }
  1051 					  }
  1039 					  else 
  1052 					  else // inContext==OutputBrief
  1040 					  { // only go to the detailed description if we have
  1053 					  { // only go to the detailed description if we have
  1041 					    // found some brief description and not just whitespace
  1054 					    // found some brief description and not just whitespace
  1042 					    endBrief(FALSE);
  1055 					    endBrief(FALSE);
  1043 					  }
  1056 					  }
  1044   					  lineCount();
  1057   					  lineCount();
  1690 
  1703 
  1691 <SkipInternal>{DOCNL}			{ // skip line
  1704 <SkipInternal>{DOCNL}			{ // skip line
  1692   					  if (*yytext=='\n') yyLineNr++;
  1705   					  if (*yytext=='\n') yyLineNr++;
  1693 					  addOutput('\n');
  1706 					  addOutput('\n');
  1694   					}
  1707   					}
       
  1708 <SkipInternal>[@\\]"if"/[ \t]		{
       
  1709                                           g_condCount++;
       
  1710   					}
       
  1711 <SkipInternal>[@\\]"ifnot"/[ \t]	{
       
  1712                                           g_condCount++;
       
  1713   					}
       
  1714 <SkipInternal>[@\\]/"endif"		{
       
  1715                                           g_condCount--;
       
  1716 					  if (g_condCount<0) // handle conditional section around of \internal, see bug607743  
       
  1717 					  {
       
  1718 					    unput('\\');
       
  1719 					    BEGIN(Comment);
       
  1720 					  }
       
  1721   					}
       
  1722 <SkipInternal>[@\\]/"section"[ \t]	{
       
  1723   					  if (g_sectionLevel>0)
       
  1724 					  {
       
  1725 					    unput('\\');
       
  1726 					    BEGIN(Comment);
       
  1727 					  }
       
  1728   					}
       
  1729 <SkipInternal>[@\\]/"subsection"[ \t]	{
       
  1730   					  if (g_sectionLevel>1)
       
  1731 					  {
       
  1732 					    unput('\\');
       
  1733 					    BEGIN(Comment);
       
  1734 					  }
       
  1735   					}
       
  1736 <SkipInternal>[@\\]/"subsubsection"[ \t]	{
       
  1737   					  if (g_sectionLevel>2)
       
  1738 					  {
       
  1739 					    unput('\\');
       
  1740 					    BEGIN(Comment);
       
  1741 					  }
       
  1742   					}
       
  1743 <SkipInternal>[@\\]/"paragraph"[ \t]	{
       
  1744   					  if (g_sectionLevel>3)
       
  1745 					  {
       
  1746 					    unput('\\');
       
  1747 					    BEGIN(Comment);
       
  1748 					  }
       
  1749   					}
  1695 <SkipInternal>[^ \\@\n]+		{ // skip non-special characters
  1750 <SkipInternal>[^ \\@\n]+		{ // skip non-special characters
  1696   					}
  1751   					}
  1697 <SkipInternal>.				{ // any other character
  1752 <SkipInternal>.				{ // any other character
  1698   					}
  1753   					}
  1699 
  1754 
  2133 static bool handleSection(const QCString &s)
  2188 static bool handleSection(const QCString &s)
  2134 {
  2189 {
  2135   setOutput(OutputDoc);
  2190   setOutput(OutputDoc);
  2136   addOutput("@"+s+" ");
  2191   addOutput("@"+s+" ");
  2137   BEGIN(SectionLabel);
  2192   BEGIN(SectionLabel);
       
  2193   if      (s=="section")       g_sectionLevel=1;
       
  2194   else if (s=="subsection")    g_sectionLevel=2;
       
  2195   else if (s=="subsubsection") g_sectionLevel=3;
       
  2196   else if (s=="paragraph")     g_sectionLevel=4;
  2138   return FALSE;
  2197   return FALSE;
  2139 }
  2198 }
  2140 
  2199 
  2141 static bool handleSubpage(const QCString &s)
  2200 static bool handleSubpage(const QCString &s)
  2142 {
  2201 {
  2282     // is not treated as "documentation"
  2341     // is not treated as "documentation"
  2283     if (current->doc.stripWhiteSpace().isEmpty())
  2342     if (current->doc.stripWhiteSpace().isEmpty())
  2284     { 
  2343     { 
  2285       current->doc.resize(0);
  2344       current->doc.resize(0);
  2286     }
  2345     }
       
  2346     g_condCount=0;
  2287     BEGIN( SkipInternal );
  2347     BEGIN( SkipInternal );
  2288   }
  2348   }
  2289   else
  2349   else
  2290   {
  2350   {
  2291     addOutput("\\internal "); 
  2351     addOutput("\\internal "); 
  2386 		       /* out */    bool &newEntryNeeded
  2446 		       /* out */    bool &newEntryNeeded
  2387 		      )
  2447 		      )
  2388 {
  2448 {
  2389   //printf("parseCommentBlock() isBrief=%d isAutoBriefOn=%d lineNr=%d\n",
  2449   //printf("parseCommentBlock() isBrief=%d isAutoBriefOn=%d lineNr=%d\n",
  2390   //    isBrief,isAutoBriefOn,lineNr);
  2450   //    isBrief,isAutoBriefOn,lineNr);
  2391   //printf("parseCommentBlock() lineNr=%d file=%s\n", lineNr, fileName.data());
  2451 
  2392   initParser();
  2452   initParser();
  2393   guards.setAutoDelete(TRUE);
  2453   guards.setAutoDelete(TRUE);
  2394   guards.clear();
  2454   guards.clear();
  2395   langParser     = parser;
  2455   langParser     = parser;
  2396   current        = curEntry;
  2456   current        = curEntry;
  2408   parseMore      = FALSE;
  2468   parseMore      = FALSE;
  2409   inBody         = isInbody;
  2469   inBody         = isInbody;
  2410   outputXRef.resize(0);
  2470   outputXRef.resize(0);
  2411   setOutput( isBrief || isAutoBriefOn ? OutputBrief : OutputDoc );
  2471   setOutput( isBrief || isAutoBriefOn ? OutputBrief : OutputDoc );
  2412   briefEndsAtDot = isAutoBriefOn;
  2472   briefEndsAtDot = isAutoBriefOn;
       
  2473   g_condCount    = 0;
       
  2474   g_sectionLevel = 0;
  2413 
  2475 
  2414   if (!current->inbodyDocs.isEmpty() && isInbody) // separate in body fragments
  2476   if (!current->inbodyDocs.isEmpty() && isInbody) // separate in body fragments
  2415   {
  2477   {
  2416     current->inbodyDocs+="\n\n";
  2478     current->inbodyDocs+="\n\n";
  2417   }
  2479   }