@@ -43,6 +43,7 @@ typedef yyguts_t *yyscan_t;
4343#include " condparser.h"
4444#include " fileinfo.h"
4545#include " stringutil.h"
46+ #include " regex.h"
4647
4748#include < assert.h>
4849
@@ -72,14 +73,15 @@ struct commentcnv_FileState
7273 QCString fileName;
7374 QCString oldFileName;
7475 QCString oldIncPrefix;
76+ QCString blockId;
7577 int oldState = 0 ;
7678 std::string fileBuf;
7779 const std::string *oldFileBuf = nullptr ;
7880 int oldFileBufPos = 0 ;
7981 int oldIncludeCtx = 0 ;
82+ int oldRaiseLvl = 0 ;
8083};
8184
82-
8385struct commentcnvYY_state
8486{
8587 commentcnvYY_state (const std::string *i,std::string &o) : inBuf(i), outBuf(o) {}
@@ -92,6 +94,8 @@ struct commentcnvYY_state
9294 bool mlBrief = FALSE ;
9395 int readLineCtx = 0 ;
9496 int includeCtx = 0 ;
97+ int raiseLevel = 0 ;
98+ int raiseIncrement = 0 ;
9599 bool skip = FALSE ;
96100 QCString fileName;
97101 int lineNr = 0 ;
@@ -139,6 +143,7 @@ static void replaceComment(yyscan_t yyscanner,int offset);
139143static void clearCommentStack (yyscan_t yyscanner);
140144static bool readIncludeFile (yyscan_t yyscanner,const QCString &inc,const QCString &blockId);
141145static void insertCommentStart (yyscan_t yyscanner);
146+ static void parseIncludeOptions (yyscan_t yyscanner,std::string_view s);
142147
143148#undef YY_INPUT
144149#define YY_INPUT (buf,result,max_size ) result=yyread(yyscanner,buf,max_size);
@@ -207,6 +212,8 @@ FILEMASK {VFILEMASK}|{HFILEMASK}
207212B [ \t ]
208213ID [$a-z_A-Z\x80 -\xFF ][$a-z_A-Z0-9\x80 -\xFF ]*
209214
215+ OPTS (","{B}*{ID}{B}*("="{B}*({ID}|[0-9]*){B}*)?)*
216+
210217 //- end: NUMBER ---------------------------------------------------------------------------
211218
212219 // C start comment
@@ -1023,7 +1030,7 @@ SLASHopt [/]*
10231030 copyToOutput (yyscanner,yytext,yyleng);
10241031 }
10251032
1026- <CComment,ReadLine,IncludeFile>[ \t][ \t][ \t][ \t][\\ @](" include{" {B}*" doc" {B}*" }" |" includedoc" ) { // Markdown code section
1033+ <CComment,ReadLine,IncludeFile>{B}{B}{B}{B}[\\ @](" include{" {B}*" doc" {B}*{OPTS} " }" |" includedoc" ) { // Markdown code section
10271034 if (Config_getBool (MARKDOWN_SUPPORT))
10281035 {
10291036 copyToOutput (yyscanner,yytext,yyleng);
@@ -1033,7 +1040,7 @@ SLASHopt [/]*
10331040 REJECT;
10341041 }
10351042 }
1036- <CComment,ReadLine,IncludeFile>[ \t][ \t][ \t][ \t][\\ @](" snippet{" {B}*" doc" {B}*" }" |" snippetdoc" ) { // Markdown code section
1043+ <CComment,ReadLine,IncludeFile>{B}{B}{B}{B}[\\ @](" snippet{" {B}*" doc" {B}*{OPTS} " }" |" snippetdoc" ) { // Markdown code section
10371044 if (Config_getBool (MARKDOWN_SUPPORT))
10381045 {
10391046 copyToOutput (yyscanner,yytext,yyleng);
@@ -1043,9 +1050,10 @@ SLASHopt [/]*
10431050 REJECT;
10441051 }
10451052 }
1046- <CComment,ReadLine,IncludeFile>[\\@](" include{" {B}*" doc" {B}*" }" |" includedoc" ) {
1053+ <CComment,ReadLine,IncludeFile>[\\@](" include{" {B}*" doc" {B}*{OPTS} " }" |" includedoc" ) {
10471054 yyextra->includeCtx = YY_START;
10481055 yyextra->firstIncludeLine = true ;
1056+ parseIncludeOptions (yyscanner,std::string_view{yytext,static_cast <size_t >(yyleng)});
10491057 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx ==ReadLine || yyextra->includeCtx ==IncludeFile))
10501058 {
10511059 if (yyextra->includeCtx ==ReadLine)
@@ -1056,9 +1064,10 @@ SLASHopt [/]*
10561064 }
10571065 BEGIN (IncludeDoc);
10581066 }
1059- <CComment,ReadLine,IncludeFile>[\\@](" snippet{" {B}*" doc" {B}*" }" |" snippetdoc" ) {
1067+ <CComment,ReadLine,IncludeFile>[\\@](" snippet{" {B}*" doc" {B}*{OPTS} " }" |" snippetdoc" ) {
10601068 yyextra->includeCtx = YY_START;
10611069 yyextra->firstIncludeLine = true ;
1070+ parseIncludeOptions (yyscanner,std::string_view{yytext,static_cast <size_t >(yyleng)});
10621071 if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx ==ReadLine || yyextra->includeCtx ==IncludeFile))
10631072 {
10641073 if (yyextra->includeCtx ==ReadLine)
@@ -1264,12 +1273,17 @@ SLASHopt [/]*
12641273 yy_switch_to_buffer (fs->bufState , yyscanner);
12651274 yy_delete_buffer (oldBuf, yyscanner);
12661275 BEGIN (fs->oldState );
1267- yyextra->fileName = fs->oldFileName ;
1268- yyextra->lineNr = fs->oldLineNr ;
1269- yyextra->inBuf = fs->oldFileBuf ;
1270- yyextra->inBufPos = fs->oldFileBufPos ;
1271- yyextra->includeCtx = fs->oldIncludeCtx ;
1276+ yyextra->fileName = fs->oldFileName ;
1277+ yyextra->lineNr = fs->oldLineNr ;
1278+ yyextra->inBuf = fs->oldFileBuf ;
1279+ yyextra->inBufPos = fs->oldFileBufPos ;
1280+ yyextra->includeCtx = fs->oldIncludeCtx ;
12721281 QCString lineStr= " \\ ilinebr \\ ifile \" " +yyextra->fileName +" \" \\ iline " +QCString ().setNum (yyextra->lineNr )+" " ;
1282+ if (fs->oldRaiseLvl !=yyextra->raiseLevel )
1283+ {
1284+ lineStr+=std::string (" \\ iraise " ) + std::to_string (fs->oldRaiseLvl );
1285+ }
1286+ yyextra->raiseLevel = fs->oldRaiseLvl ;
12731287 copyToOutput (yyscanner,lineStr.view ());
12741288 yyextra->includeStack .pop_back ();
12751289 // printf("<<EOF>> switch back to %s line %d inbufPos=%d outbufPos=%d\n",
@@ -1281,6 +1295,26 @@ SLASHopt [/]*
12811295 */
12821296%%
12831297
1298+ static void parseIncludeOptions (yyscan_t yyscanner,std::string_view s)
1299+ {
1300+ struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
1301+ // printf("parseIncludeOptions=%s\n",qPrint(QCString(s)));
1302+ static const reg::Ex re (R"( ,\s*raise\s*=\s*(\d+))" );
1303+ reg::Match match;
1304+ if (reg::search(s,match,re))
1305+ {
1306+ const int maxLevel = 5 ;
1307+ yyextra->raiseIncrement = atoi (match[1 ].str ().c_str ());
1308+ if (yyextra->raiseLevel +yyextra->raiseIncrement >maxLevel) // check range
1309+ {
1310+ warn (yyextra->fileName ,yyextra->lineNr ," Raising section level from %d to %d, exceeds allowed range [0-5], adjusting" ,
1311+ yyextra->raiseLevel ,yyextra->raiseLevel +yyextra->raiseIncrement );
1312+ yyextra->raiseIncrement = std::max (0 ,maxLevel-yyextra->raiseLevel );
1313+ }
1314+ }
1315+ }
1316+
1317+
12841318static void replaceCommentMarker (yyscan_t yyscanner,std::string_view s)
12851319{
12861320 struct yyguts_t *yyg = (struct yyguts_t *)yyscanner;
@@ -1550,8 +1584,8 @@ static bool readIncludeFile(yyscan_t yyscanner,const QCString &inc,const QCStrin
15501584 bool alreadyProcessed = std::any_of (
15511585 yyextra->includeStack .begin (),
15521586 yyextra->includeStack .end (),
1553- [absFileName](const auto &lfs)
1554- { return lfs->fileName ==absFileName; }
1587+ [& absFileName,&blockId ](const auto &lfs)
1588+ { return lfs->fileName ==absFileName && lfs-> blockId ==blockId ; }
15551589 );
15561590
15571591 if (alreadyProcessed)
@@ -1595,7 +1629,14 @@ static bool readIncludeFile(yyscan_t yyscanner,const QCString &inc,const QCStrin
15951629 fs->fileBuf .append (incText.str ());
15961630 }
15971631 }
1598- QCString lineStr=" \\ ilinebr \\ ifile \" " +absFileName+" \" \\ iline " + QCString ().setNum (lineNr) + " \\ ilinebr " ;
1632+ int oldRaiseLevel = yyextra->raiseLevel ;
1633+ yyextra->raiseLevel +=yyextra->raiseIncrement ;
1634+ QCString lineStr=" \\ ilinebr \\ ifile \" " +absFileName+" \" \\ iline " + std::to_string (lineNr);
1635+ if (yyextra->raiseLevel >0 )
1636+ {
1637+ lineStr+=" \\ iraise " + std::to_string (yyextra->raiseLevel );
1638+ }
1639+ lineStr+=" \\ ilinebr " ;
15991640 copyToOutput (yyscanner,lineStr.view ());
16001641
16011642 fs->fileName = absFileName;
@@ -1606,6 +1647,8 @@ static bool readIncludeFile(yyscan_t yyscanner,const QCString &inc,const QCStrin
16061647 fs->oldFileBuf = yyextra->inBuf ;
16071648 fs->oldFileBufPos = yyextra->inBufPos ;
16081649 fs->oldIncludeCtx = yyextra->includeCtx ;
1650+ fs->oldRaiseLvl = oldRaiseLevel;
1651+ fs->blockId = blockId;
16091652 yy_switch_to_buffer (yy_create_buffer (0 , YY_BUF_SIZE, yyscanner),yyscanner);
16101653 yyextra->fileName = absFileName;
16111654 yyextra->lineNr = lineNr;
@@ -1756,6 +1799,8 @@ void convertCppComments(const std::string &inBuf,std::string &outBuf,const std::
17561799 yyextra->lang = getLanguageFromFileName(fileName);
17571800 yyextra->pythonDocString = FALSE;
17581801 yyextra->lineNr = 1;
1802+ yyextra->raiseLevel = 0;
1803+ yyextra->raiseIncrement = 0;
17591804 yyextra->insertCppCommentMarker=false;
17601805 yyextra->expandedAliases.clear();
17611806 while (!yyextra->condStack.empty()) yyextra->condStack.pop();
0 commit comments