Imported Upstream version 1.9.8
[platform/upstream/doxygen.git] / src / commentcnv.l
index ad9b302..85cec27 100644 (file)
@@ -1,12 +1,10 @@
 /*****************************************************************************
  *
- * 
- *
- * Copyright (C) 1997-2015 by Dimitri van Heesch.
+ * Copyright (C) 1997-2023 by Dimitri van Heesch.
  *
  * Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby 
- * granted. No representations are made about the suitability of this software 
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
  * for any purpose. It is provided "as is" without express or implied warranty.
  * See the GNU General Public License for more details.
  *
@@ -28,7 +26,7 @@ typedef yyguts_t *yyscan_t;
 
 %{
 
-  
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stack>
@@ -40,6 +38,7 @@ typedef yyguts_t *yyscan_t;
 #include "config.h"
 #include "doxygen.h"
 #include "util.h"
+#include "aliases.h"
 #include "condparser.h"
 
 #include <assert.h>
@@ -47,32 +46,33 @@ typedef yyguts_t *yyscan_t;
 #define YY_NO_INPUT 1
 #define YY_NO_UNISTD_H 1
 
-#define ADDCHAR(c)    yyextra->outBuf->addChar(c)
-#define ADDARRAY(a,s) yyextra->outBuf->addArray(a,s)
+#define ADDCHAR(c)    yyextra->outBuf.addChar(c)
+#define ADDARRAY(a,s) yyextra->outBuf.addArray(a,s)
 
 #define USE_STATE2STRING 0
-  
+
 struct commentcnvYY_CondCtx
 {
-  commentcnvYY_CondCtx(int line,QCString id,bool b) 
+  commentcnvYY_CondCtx(int line,const QCString &id,bool b)
     : lineNr(line),sectionId(id), skip(b) {}
   int lineNr;
   QCString sectionId;
   bool skip;
 };
-  
+
 struct CommentCtx
 {
-  CommentCtx(int line) 
+  CommentCtx(int line)
     : lineNr(line) {}
   int lineNr;
 };
-  
+
 struct commentcnvYY_state
 {
-  BufStr * inBuf = 0;
-  BufStr * outBuf = 0;
-  yy_size_t inBufPos = 0;
+  commentcnvYY_state(const BufStr &i,BufStr &o) : inBuf(i), outBuf(o) {}
+  const BufStr &inBuf;
+  BufStr &outBuf;
+  int      inBufPos = 0;
   int      col = 0;
   int      blockHeadCol = 0;
   bool     mlBrief = FALSE;
@@ -116,7 +116,7 @@ static void startCondSection(yyscan_t yyscanner,const QCString &sectId);
 static void endCondSection(yyscan_t yyscanner);
 static void handleCondSectionId(yyscan_t yyscanner,const char *expression);
 static void replaceAliases(yyscan_t yyscanner,const QCString &s);
-static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
+static int yyread(yyscan_t yyscanner,char *buf,int max_size);
 static void replaceComment(yyscan_t yyscanner,int offset);
 static void clearCommentStack(yyscan_t yyscanner);
 
@@ -176,11 +176,11 @@ FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL}
 NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER}
   //- end: NUMBER ---------------------------------------------------------------------------
 
-  // C start comment 
+  // C start comment
 CCS   "/\*"
   // C end comment
 CCE   "*\/"
-  // Cpp comment 
+  // Cpp comment
 CPPC  "/\/"
 
   // Optional any character
@@ -197,12 +197,12 @@ SLASHopt [/]*
 
 <Scan>{NUMBER}                     { //Note similar code in code.l
                                       if (yyextra->lang!=SrcLangExt_Cpp) REJECT;
-                                      copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                      copyToOutput(yyscanner,yytext,(int)yyleng);
                                     }
 <Scan>[^"'!\/\n\\#,\-=; \t]*        { /* eat anything that is not " / , or \n */
                                        copyToOutput(yyscanner,yytext,(int)yyleng);
                                     }
-<Scan>[,= ;\t]                      { /* eat , so we have a nice separator in long initialization lines */ 
+<Scan>[,= ;\t]                      { /* eat , so we have a nice separator in long initialization lines */
                                        copyToOutput(yyscanner,yytext,(int)yyleng);
                                     }
 <Scan>"\"\"\""!                     { /* start of python long comment */
@@ -220,6 +220,25 @@ SLASHopt [/]*
                                        yyextra->commentStack.push(yyextra->lineNr);
                                     }
                                    }
+<Scan>"\"\"\""                     { /* start of python long comment */
+                                     if (yyextra->lang!=SrcLangExt_Python)
+                                    {
+                                      REJECT;
+                                    }
+                                     else if (Config_getBool(PYTHON_DOCSTRING))
+                                     {
+                                      REJECT;
+                                     }
+                                    else
+                                    { /* handle as if """! */
+                                       yyextra->pythonDocString = TRUE;
+                                       yyextra->nestingCount=1;
+                                       clearCommentStack(yyscanner); /*  to be on the save side */
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
+                                      BEGIN(CComment);
+                                       yyextra->commentStack.push(yyextra->lineNr);
+                                    }
+                                   }
 <Scan>![><!]/.*\n         {
                                      if (yyextra->lang!=SrcLangExt_Fortran)
                                     {
@@ -227,7 +246,7 @@ SLASHopt [/]*
                                     }
                                     else
                                     {
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                        yyextra->nestingCount=0; // Fortran doesn't have an end comment
                                        clearCommentStack(yyscanner); /*  to be on the save side */
                                       BEGIN(CComment);
@@ -244,7 +263,7 @@ SLASHopt [/]*
                                        /* check for fixed format; we might have some conditional as part of multiline if like C<5 .and. & */
                                        if (yyextra->isFixedForm && (yyextra->col == 0))
                                        {
-                                         copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                         copyToOutput(yyscanner,yytext,(int)yyleng);
                                          yyextra->nestingCount=0; // Fortran doesn't have an end comment
                                          clearCommentStack(yyscanner); /*  to be on the save side */
                                         BEGIN(CComment);
@@ -263,7 +282,7 @@ SLASHopt [/]*
                                     }
                                     else
                                     {
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                     }
                                    }
 <Scan>[Cc\*].*\n                  {
@@ -275,7 +294,7 @@ SLASHopt [/]*
                                     {
                                        if (yyextra->col == 0)
                                        {
-                                         copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                         copyToOutput(yyscanner,yytext,(int)yyleng);
                                       }
                                       else
                                       {
@@ -283,25 +302,25 @@ SLASHopt [/]*
                                       }
                                     }
                                    }
-<Scan>"\""                         { /* start of a string */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<Scan>"\""                         { /* start of a string */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->stringContext = YY_START;
-                                    BEGIN(SkipString); 
+                                    BEGIN(SkipString);
                                    }
 <Scan>'                                   {
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->charContext = YY_START;
                                      if (yyextra->lang!=SrcLangExt_VHDL)
                                      {
                                       BEGIN(SkipChar);
                                      }
                                   }
-<Scan>\n                           { /* new line */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<Scan>\n                           { /* new line */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <Scan>{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] | /* start C++ style special comment block */
 <Scan>({CPPC}"/"[/]*)/[^/].*\n[ \t]*{CPPC}[\/!][^\/] { /* start C++ style special comment block */
-                                    if (yyextra->mlBrief) 
+                                    if (yyextra->mlBrief)
                                     {
                                       REJECT; // bail out if we do not need to convert
                                     }
@@ -313,10 +332,10 @@ SLASHopt [/]*
                                         while (i<(int)yyleng && yytext[i]=='/') i++;
                                       }
                                       yyextra->blockHeadCol=yyextra->col;
-                                      copyToOutput(yyscanner,"/**",3); 
+                                      copyToOutput(yyscanner,"/**",3);
                                       replaceAliases(yyscanner,QCString(yytext+i));
                                       yyextra->inSpecialComment=TRUE;
-                                      //BEGIN(SComment); 
+                                      //BEGIN(SComment);
                                       yyextra->readLineCtx=SComment;
                                       BEGIN(ReadLine);
                                     }
@@ -332,13 +351,13 @@ SLASHopt [/]*
                                   }
 <Scan>{CPPC}[!\/]/.*\n[ \t]*{CPPC}[|\/][ \t]*[@\\]"}" { // next line contains an end marker, see bug 752712
                                     yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!';
-                                    copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                    copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->readLineCtx=YY_START;
                                     BEGIN(ReadLine);
                                    }
-<Scan>{CPPC}/.*\n                         { /* one line C++ comment */ 
+<Scan>{CPPC}/.*\n                         { /* one line C++ comment */
                                     yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!';
-                                    copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                    copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->readLineCtx=YY_START;
                                     BEGIN(ReadLine);
                                   }
@@ -353,13 +372,20 @@ SLASHopt [/]*
                                     yyextra->specialComment=(int)yyleng==3;
                                      yyextra->nestingCount=1;
                                      clearCommentStack(yyscanner); /*  to be on the save side */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                      if (yyextra->specialComment)
-                                      BEGIN(CComment); 
+                                      BEGIN(CComment);
                                      else
-                                      BEGIN(CNComment); 
+                                      BEGIN(CNComment);
                                      yyextra->commentStack.push(yyextra->lineNr);
                                    }
+<Scan>"#"[^\n]*\n                  {
+                                     if (yyextra->lang!=SrcLangExt_PHP)
+                                    {
+                                      REJECT;
+                                    }
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
+                                   }
 <Scan>"#"("#")?                           {
                                      if (yyextra->lang!=SrcLangExt_Python)
                                     {
@@ -367,7 +393,7 @@ SLASHopt [/]*
                                     }
                                     else
                                     {
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                        yyextra->nestingCount=0; // Python doesn't have an end comment for #
                                        clearCommentStack(yyscanner); /*  to be on the save side */
                                       BEGIN(CComment);
@@ -381,7 +407,7 @@ SLASHopt [/]*
                                     }
                                     else
                                     {
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                     }
                                   }
 <Scan>"--!"                       {
@@ -392,7 +418,7 @@ SLASHopt [/]*
                                     else
                                     {
                                        yyextra->vhdl = TRUE;
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                        yyextra->nestingCount=0;  // VHDL doesn't have an end comment
                                        clearCommentStack(yyscanner); /*  to be on the save side */
                                       BEGIN(CComment);
@@ -406,7 +432,7 @@ SLASHopt [/]*
                                     }
                                     else
                                     {
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                        yyextra->nestingCount=0;  // Fortran doesn't have an end comment
                                        clearCommentStack(yyscanner); /*  to be on the save side */
                                       BEGIN(CComment);
@@ -418,14 +444,14 @@ SLASHopt [/]*
                                      copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <CComment>"{"[ \t]*"@code"/[ \t\n] {
-                                     copyToOutput(yyscanner,"@iliteral{code}",15); 
+                                     copyToOutput(yyscanner,"@iliteral{code}",15);
                                     yyextra->lastCommentContext = YY_START;
                                     yyextra->javaBlock=1;
                                     yyextra->blockName=&yytext[1];
                                      BEGIN(VerbatimCode);
                                   }
 <CComment>"{"[ \t]*"@literal"/[ \t\n] {
-                                     copyToOutput(yyscanner,"@iliteral",9); 
+                                     copyToOutput(yyscanner,"@iliteral",9);
                                     yyextra->lastCommentContext = YY_START;
                                     yyextra->javaBlock=1;
                                     yyextra->blockName=&yytext[1];
@@ -439,11 +465,11 @@ SLASHopt [/]*
                                      copyToOutput(yyscanner,yytext,(int)yyleng);
                                      yyextra->lastCommentContext = YY_START;
                                      yyextra->javaBlock=0;
-                                     yyextra->blockName=QCString(yytext).stripWhiteSpace().left(3);
+                                     yyextra->blockName=QCString(yytext).stripWhiteSpace().left(3); // take the ``` or ~~~ part
                                      BEGIN(VerbatimCode);
                                    }
 <CComment,ReadLine>[\\@]("dot"|"code"|"msc"|"startuml")/[^a-z_A-Z0-9] { /* start of a verbatim block */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->lastCommentContext = YY_START;
                                     yyextra->javaBlock=0;
                                      if (qstrcmp(&yytext[1],"startuml")==0)
@@ -457,7 +483,7 @@ SLASHopt [/]*
                                      BEGIN(VerbatimCode);
                                   }
 <CComment,ReadLine>[\\@]("f$"|"f["|"f{"|"f(") {
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->blockName=&yytext[1];
                                     if (yyextra->blockName.at(1)=='[')
                                     {
@@ -475,7 +501,7 @@ SLASHopt [/]*
                                     BEGIN(Verbatim);
                                   }
 <CComment,ReadLine>[\\@]("verbatim"|"iliteral"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly")/[^a-z_A-Z0-9] { /* start of a verbatim block */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->blockName=&yytext[1];
                                     yyextra->lastCommentContext = YY_START;
                                      BEGIN(Verbatim);
@@ -547,7 +573,7 @@ SLASHopt [/]*
 <VerbatimCode>^[ \t]*{CPPC}[\!\/]?   { /* skip leading comments */
                                     if (!yyextra->inSpecialComment)
                                     {
-                                       copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                       copyToOutput(yyscanner,yytext,(int)yyleng);
                                     }
                                      else
                                      {
@@ -568,10 +594,10 @@ SLASHopt [/]*
                                      }
                                   }
 <Verbatim,VerbatimCode>[^`~@\/\\\n{}]* { /* any character not a backslash or new line or } */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <Verbatim,VerbatimCode>\n         { /* new line in verbatim block */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <Verbatim>^[ \t]*{CPPC}[/!]          {
                                     if (yyextra->blockName=="dot" || yyextra->blockName=="msc" || yyextra->blockName=="uml" || yyextra->blockName.at(0)=='f')
@@ -591,7 +617,7 @@ SLASHopt [/]*
                                     }
                                   }
 <Verbatim,VerbatimCode>.          { /* any other character */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <SkipString>\\.                    { /* escaped character in string */
                                      if (yyextra->lang==SrcLangExt_Fortran || yyextra->lang==SrcLangExt_VHDL)
@@ -604,15 +630,15 @@ SLASHopt [/]*
                                        copyToOutput(yyscanner,yytext,(int)yyleng);
                                      }
                                    }
-<SkipString>"\""                          { /* end of string */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
-                                    BEGIN(yyextra->stringContext); 
+<SkipString>"\""                          { /* end of string */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
+                                    BEGIN(yyextra->stringContext);
                                    }
-<SkipString>.                      { /* any other string character */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<SkipString>.                      { /* any other string character */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
-<SkipString>\n                     { /* new line inside string (illegal for some compilers) */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<SkipString>\n                     { /* new line inside string (illegal for some compilers) */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <SkipChar>\\.                     { /* escaped character */
                                      if (yyextra->lang==SrcLangExt_Fortran || yyextra->lang==SrcLangExt_VHDL)
@@ -625,22 +651,22 @@ SLASHopt [/]*
                                        copyToOutput(yyscanner,yytext,(int)yyleng);
                                      }
                                    }
-<SkipChar>'                        { /* end of character literal */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<SkipChar>'                        { /* end of character literal */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                      BEGIN(yyextra->charContext);
                                    }
-<SkipChar>.                        { /* any other string character */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<SkipChar>.                        { /* any other string character */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <SkipChar>\n                       { /* new line character */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 
-<CComment,CNComment>[^ `~<\\!@*\n{\"\/]*     { /* anything that is not a '*' or command */ 
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+<CComment,CNComment>[^ `~<\\!@*\n{\"\/]*     { /* anything that is not a '*' or command */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <CComment,CNComment>"*"+[^*\/\\@\n{\"]*      { /* stars without slashes */
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                    }
 <CComment>"\"\"\""                 { /* end of Python docstring */
                                      if (yyextra->lang!=SrcLangExt_Python)
@@ -663,6 +689,10 @@ SLASHopt [/]*
                                       BEGIN(Scan);
                                     }
                                    }
+<CComment,CNComment>"/""/"+/"*/"   { /* we are already in C-comment so not a start of a nested comment but
+                                      * just the end of the comment (the end part is handled later). */
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
+                                   }
 <CComment,CNComment>"/"+"*"                  { /* nested C comment */
                                      if (yyextra->lang==SrcLangExt_Python ||
                                          yyextra->lang==SrcLangExt_Markdown)
@@ -769,29 +799,29 @@ SLASHopt [/]*
                                   }
    */
 <CComment,CNComment>.                     {
-                                     copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                   }
 <SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n     {
                                     replaceComment(yyscanner,0);
                                   }
 <SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n    {
-                                     replaceComment(yyscanner,1); 
+                                     replaceComment(yyscanner,1);
                                    }
-<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n { 
+<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n {
                                     replaceComment(yyscanner,0);
                                     yyextra->readLineCtx=YY_START;
                                     BEGIN(ReadLine);
                                   }
-<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*[\\@]"}".*\n {   
+<SComment>\n[ \t]*{CPPC}[\/!]("<")?[ \t]*[\\@]"}".*\n {
                                      /* See Bug 752712: end the multiline comment when finding a @} or \} command */
-                                     copyToOutput(yyscanner," */",3); 
-                                    copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner," */",3);
+                                    copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->inSpecialComment=FALSE;
                                     yyextra->inRoseComment=FALSE;
-                                    BEGIN(Scan); 
+                                    BEGIN(Scan);
                                    }
-<SComment>\n[ \t]*{CPPC}"/"[^\/\n]/.*\n  { 
-                                     replaceComment(yyscanner,1); 
+<SComment>\n[ \t]*{CPPC}"/"[^\/\n]/.*\n  {
+                                     replaceComment(yyscanner,1);
                                     yyextra->readLineCtx=YY_START;
                                     BEGIN(ReadLine);
                                   }
@@ -804,8 +834,8 @@ SLASHopt [/]*
                                    }
 <SComment>\n[ \t]*{CPPC}"!"            |
 <SComment>\n[ \t]*{CPPC}"!<"/.*\n      |
-<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n { 
-                                     replaceComment(yyscanner,1); 
+<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n {
+                                     replaceComment(yyscanner,1);
                                     yyextra->readLineCtx=YY_START;
                                     BEGIN(ReadLine);
                                    }
@@ -828,17 +858,19 @@ SLASHopt [/]*
                                     }
                                     else
                                     {
-                                       replaceComment(yyscanner,1); 
+                                       replaceComment(yyscanner,1);
                                       yyextra->readLineCtx=YY_START;
                                       BEGIN(ReadLine);
                                     }
                                    }
 <SComment>\n                      { /* end of special comment */
-                                     copyToOutput(yyscanner," */",3); 
-                                    copyToOutput(yyscanner,yytext,(int)yyleng); 
+                                     copyToOutput(yyscanner," */",3);
+                                    copyToOutput(yyscanner,yytext,(int)yyleng);
                                     yyextra->inSpecialComment=FALSE;
                                     yyextra->inRoseComment=FALSE;
-                                    BEGIN(Scan); 
+                                     yyextra->readLineCtx = Scan; // reset, otherwise there will be problems with:
+                                                                  //   static void handleCondSectionId
+                                    BEGIN(Scan);
                                    }
 <ReadLine>{CCS}"*"                    {
                                     copyToOutput(yyscanner,"/&zwj;**",8);
@@ -860,13 +892,13 @@ SLASHopt [/]*
                                     copyToOutput(yyscanner,yytext,(int)yyleng);
                                   }
 <CComment,ReadLine>[\\@]"cond"/[^a-z_A-Z0-9]      { // conditional section
-                                    yyextra->condCtx = YY_START; 
+                                    yyextra->condCtx = YY_START;
                                     BEGIN(CondLine);
                                   }
 <CComment,ReadLine>[\\@]"endcond"/[^a-z_A-Z0-9] { // end of conditional section
                                     bool oldSkip=yyextra->skip;
                                     endCondSection(yyscanner);
-                                    if (YY_START==CComment && oldSkip && !yyextra->skip) 
+                                    if (YY_START==CComment && oldSkip && !yyextra->skip)
                                     {
                                       //printf("** Adding start of comment!\n");
                                       if (yyextra->lang!=SrcLangExt_Python &&
@@ -895,10 +927,10 @@ SLASHopt [/]*
                                      handleCondSectionId(yyscanner," "); // fake section id causing the section to be hidden unconditionally
                                     if (*yytext=='\n') { yyextra->lineNr++; copyToOutput(yyscanner,"\n",1);}
                                   }
-<CComment,ReadLine>[\\@][a-z_A-Z][a-z_A-Z0-9]*  { // expand alias without arguments
+<CComment,ReadLine>[\\@][a-z_A-Z][a-z_A-Z0-9-]*  { // expand alias without arguments
                                     replaceAliases(yyscanner,QCString(yytext));
                                   }
-<CComment,ReadLine>[\\@][a-z_A-Z][a-z_A-Z0-9]*"{" { // expand alias with arguments
+<CComment,ReadLine>[\\@][a-z_A-Z][a-z_A-Z0-9-]*"{" { // expand alias with arguments
                                      yyextra->lastBlockContext=YY_START;
                                     yyextra->blockCount=1;
                                     yyextra->aliasString=yytext;
@@ -970,7 +1002,7 @@ static void replaceCommentMarker(yyscan_t yyscanner,const char *s,int len)
   const char *p=s;
   char c;
   // copy leading blanks
-  while ((c=*p) && (c==' ' || c=='\t' || c=='\n')) 
+  while ((c=*p) && (c==' ' || c=='\t' || c=='\n'))
   {
     ADDCHAR(c);
     yyextra->lineNr += c=='\n';
@@ -978,14 +1010,14 @@ static void replaceCommentMarker(yyscan_t yyscanner,const char *s,int len)
   }
   // replace start of comment marker by blanks and the last character by a *
   int blanks=0;
-  while ((c=*p) && (c=='/' || c=='!' || c=='#')) 
+  while ((c=*p) && (c=='/' || c=='!' || c=='#'))
   {
     blanks++;
     p++;
-    if (*p=='<') // comment-after-item marker 
-    { 
+    if (*p=='<') // comment-after-item marker
+    {
       blanks++;
-      p++; 
+      p++;
     }
     if (c=='!') // end after first !
     {
@@ -1009,13 +1041,13 @@ static void replaceCommentMarker(yyscan_t yyscanner,const char *s,int len)
 static inline int computeIndent(const char *s)
 {
   int col=0;
-  static int tabSize=Config_getInt(TAB_SIZE);
+  int tabSize=Config_getInt(TAB_SIZE);
   const char *p=s;
   char c;
   while ((c=*p++))
   {
     if (c==' ') col++;
-    else if (c=='\t') col+=tabSize-(col%tabSize); 
+    else if (c=='\t') col+=tabSize-(col%tabSize);
     else break;
   }
   return col;
@@ -1049,11 +1081,11 @@ static inline void copyToOutput(yyscan_t yyscanner,const char *s,int len)
   else if (len>0)
   {
     ADDARRAY(s,len);
-    for (i=0;i<len;i++) 
+    for (i=0;i<len;i++)
     {
       switch (s[i])
       {
-       case '\n': yyextra->col=0; 
+       case '\n': yyextra->col=0;
                   //fprintf(stderr,"---> copy %d\n",g_lineNr);
                   yyextra->lineNr++; break;
        case '\t': yyextra->col+=tabSize-(yyextra->col%tabSize); break;
@@ -1104,8 +1136,8 @@ static void handleCondSectionId(yyscan_t yyscanner,const char *expression)
   struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
   bool oldSkip=yyextra->skip;
   startCondSection(yyscanner,QCString(expression));
-  if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) && 
-      !oldSkip && yyextra->skip) 
+  if ((yyextra->condCtx==CComment || yyextra->readLineCtx==SComment) &&
+      !oldSkip && yyextra->skip)
   {
     if (yyextra->lang!=SrcLangExt_Python &&
         yyextra->lang!=SrcLangExt_VHDL &&
@@ -1126,23 +1158,23 @@ static void handleCondSectionId(yyscan_t yyscanner,const char *expression)
   }
 }
 
-/** copies string \a s with length \a len to the output, while 
+/** copies string \a s with length \a len to the output, while
  *  replacing any alias commands found in the string.
  */
 static void replaceAliases(yyscan_t yyscanner,const QCString &s)
 {
   QCString result = resolveAliasCmd(s);
-  //printf("replaceAliases(%s)->'%s'\n",s,result.data());
+  //printf("replaceAliases(%s)->'%s'\n",qPrint(s),qPrint(result));
   copyToOutput(yyscanner,result.data(),result.length());
 }
 
 
-static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size)
+static int yyread(yyscan_t yyscanner,char *buf,int max_size)
 {
   struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
-  yy_size_t bytesInBuf = yyextra->inBuf->curPos()-yyextra->inBufPos;
-  yy_size_t bytesToCopy = std::min(max_size,bytesInBuf);
-  memcpy(buf,yyextra->inBuf->data()+yyextra->inBufPos,bytesToCopy);
+  int bytesInBuf = static_cast<int>(yyextra->inBuf.curPos())-yyextra->inBufPos;
+  int bytesToCopy = std::min(max_size,bytesInBuf);
+  memcpy(buf,yyextra->inBuf.data()+yyextra->inBufPos,bytesToCopy);
   yyextra->inBufPos+=bytesToCopy;
   return bytesToCopy;
 }
@@ -1178,18 +1210,16 @@ static void replaceComment(yyscan_t yyscanner,int offset)
  *  -# It replaces aliases with their definition (see ALIASES)
  *  -# It handles conditional sections (cond...endcond blocks)
  */
-void convertCppComments(BufStr *inBuf,BufStr *outBuf,const QCString &fileName)
+void convertCppComments(const BufStr &inBuf,BufStr &outBuf,const QCString &fileName)
 {
   yyscan_t yyscanner;
-  commentcnvYY_state extra;
+  commentcnvYY_state extra(inBuf,outBuf);
   commentcnvYYlex_init_extra(&extra,&yyscanner);
 #ifdef FLEX_DEBUG
-  commentcnvYYset_debug(1,yyscanner);
+  commentcnvYYset_debug(Debug::isFlagSet(Debug::Lex_commentcnv)?1:0,yyscanner);
 #endif
   struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
   //printf("convertCppComments(%s)\n",fileName);
-  yyextra->inBuf    = inBuf;
-  yyextra->outBuf   = outBuf;
   yyextra->inBufPos = 0;
   yyextra->col      = 0;
   yyextra->mlBrief = Config_getBool(MULTILINE_CPP_IS_BRIEF);
@@ -1202,12 +1232,12 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const QCString &fileName)
   clearCommentStack(yyscanner);
   yyextra->vhdl = FALSE;
 
-  printlex(yy_flex_debug, TRUE, __FILE__, qPrint(fileName));
+  DebugLex debugLex(Debug::Lex_commentcnv,__FILE__, qPrint(fileName));
   yyextra->isFixedForm = FALSE;
   if (yyextra->lang==SrcLangExt_Fortran)
   {
     FortranFormat fmt = convertFileNameFortranParserCode(fileName);
-    yyextra->isFixedForm = recognizeFixedForm(QCString(inBuf->data()),fmt);
+    yyextra->isFixedForm = recognizeFixedForm(QCString(inBuf.data()),fmt);
   }
 
   if (yyextra->lang==SrcLangExt_Markdown)
@@ -1249,12 +1279,11 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const QCString &fileName)
   yyextra->nestingCount = 0;
   if (Debug::isFlagSet(Debug::CommentCnv))
   {
-    yyextra->outBuf->at(yyextra->outBuf->curPos())='\0';
+    yyextra->outBuf.at(yyextra->outBuf.curPos())='\0';
     Debug::print(Debug::CommentCnv,0,"-----------\nCommentCnv: %s\n"
-                 "output=[\n%s]\n-----------\n",qPrint(fileName),yyextra->outBuf->data()
+                 "output=[\n%s]\n-----------\n",qPrint(fileName),yyextra->outBuf.data()
                 );
   }
-  printlex(yy_flex_debug, FALSE, __FILE__, qPrint(fileName));
   commentcnvYYlex_destroy(yyscanner);
 }