@@ -260,6 +260,8 @@ static bool skipLanguageSpecificKeyword(yyscan_t yyscanner,const char *kw);
260
260
static int yyread (yyscan_t yyscanner,char *buf,int max_size);
261
261
static void addVariable (yyscan_t yyscanner,QCString type,QCString name);
262
262
static bool startsWithKeyword (const QCString &str,const QCString &kw);
263
+ static void endCodeFold (yyscan_t yyscanner);
264
+ static void skipHiddenComment (yyscan_t yyscanner,const char *text);
263
265
264
266
/* -----------------------------------------------------------------
265
267
*/
@@ -1976,12 +1978,12 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
1976
1978
yyextra->code ->codify (yytext);
1977
1979
}
1978
1980
<RemoveSpecialCComment>{CCE}{B}*\n ({B}*\n)*({B}*(({CPPC}" @" [{}])|({CCS}" @" [{}]{CCE})){B}*\n)?{B}*{CCS}[*!]/{NCOMM} {
1979
- yyextra-> yyLineNr += QCString ( yytext). contains ( ' \n ' );
1981
+ skipHiddenComment (yyscanner, yytext);
1980
1982
}
1981
1983
<RemoveSpecialCComment>{CCE}{B}*\n ({B}*\n)*({B}*(({CPPC}" @" [{}])|({CCS}" @" [{}]{CCE})){B}*\n)? {
1982
1984
if (yyextra->lastSpecialCContext ==SkipCxxComment)
1983
1985
{ // force end of C++ comment here
1984
- yyextra-> yyLineNr += QCString ( yytext). contains ( ' \n ' );
1986
+ skipHiddenComment (yyscanner, yytext);
1985
1987
nextCodeLine (yyscanner);
1986
1988
endFontClass (yyscanner);
1987
1989
BEGIN ( yyextra->lastCContext ) ;
@@ -2006,7 +2008,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2006
2008
}
2007
2009
<RemoveSpecialCComment>[^*\n]+
2008
2010
<RemoveSpecialCComment>{CPPC}|{CCS}
2009
- <RemoveSpecialCComment>\n { yyextra->yyLineNr ++; }
2011
+ <RemoveSpecialCComment>\n { yyextra->yyLineNr ++; endCodeFold (yyscanner); }
2010
2012
<RemoveSpecialCComment>.
2011
2013
<MemberCall>[^a-z_A-Z0-9 (\n] {
2012
2014
yyextra->code ->codify (yytext);
@@ -2018,7 +2020,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2018
2020
if (YY_START==SkipCPP) REJECT;
2019
2021
if (Config_getBool (STRIP_CODE_COMMENTS))
2020
2022
{
2021
- yyextra-> yyLineNr += QCString ( yytext). contains ( ' \n ' );
2023
+ skipHiddenComment (yyscanner, yytext);
2022
2024
nextCodeLine (yyscanner);
2023
2025
}
2024
2026
else
@@ -2041,7 +2043,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2041
2043
<*>\n{B}*{CPPC}" @" [{}].*\n { // remove one-line group marker
2042
2044
if (Config_getBool (STRIP_CODE_COMMENTS))
2043
2045
{
2044
- yyextra-> yyLineNr += 2 ;
2046
+ skipHiddenComment (yyscanner,yytext) ;
2045
2047
nextCodeLine (yyscanner);
2046
2048
}
2047
2049
else
@@ -2078,7 +2080,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2078
2080
<*>^{B}*{CPPC}" @" [{}].*\n { // remove one-line group marker
2079
2081
if (Config_getBool (STRIP_CODE_COMMENTS))
2080
2082
{
2081
- yyextra-> yyLineNr ++ ;
2083
+ skipHiddenComment (yyscanner,yytext) ;
2082
2084
nextCodeLine (yyscanner);
2083
2085
}
2084
2086
else
@@ -2123,11 +2125,11 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2123
2125
endFontClass (yyscanner);
2124
2126
}
2125
2127
}
2126
- <*>\n{B}*{CCS}[!*]/{NCOMM} {
2128
+ <*>\n{B}*{CCS}[!*]/{NCOMM} {
2127
2129
if (Config_getBool (STRIP_CODE_COMMENTS))
2128
2130
{
2131
+ skipHiddenComment (yyscanner,yytext);
2129
2132
if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START;
2130
- yyextra->yyLineNr ++;
2131
2133
BEGIN (RemoveSpecialCComment);
2132
2134
}
2133
2135
else
@@ -2160,7 +2162,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2160
2162
BEGIN (SkipComment);
2161
2163
}
2162
2164
}
2163
- <*>^{B}*{CCS}[!*]/{NCOMM} { // special C comment block at a new line
2165
+ <*>^{B}*{CCS}[!*]/{NCOMM} { // special C comment block at a new line
2164
2166
if (Config_getBool (STRIP_CODE_COMMENTS))
2165
2167
{
2166
2168
if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START;
@@ -2178,7 +2180,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2178
2180
BEGIN (SkipComment);
2179
2181
}
2180
2182
}
2181
- <*>{CCS}[!*]/{NCOMM} { // special C comment block half way a line
2183
+ <*>{CCS}[!*]/{NCOMM} { // special C comment block half way a line
2182
2184
if (YY_START==SkipString) REJECT;
2183
2185
if (Config_getBool (STRIP_CODE_COMMENTS))
2184
2186
{
@@ -2197,7 +2199,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2197
2199
BEGIN (SkipComment);
2198
2200
}
2199
2201
}
2200
- <*>{CCS}(" !" ?){CCE} {
2202
+ <*>{CCS}(" !" ?){CCE} {
2201
2203
if (YY_START==SkipString) REJECT;
2202
2204
if (!Config_getBool (STRIP_CODE_COMMENTS))
2203
2205
{
@@ -2209,7 +2211,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2209
2211
<SkipComment>[^\*\n]+ {
2210
2212
yyextra->code ->codify (yytext);
2211
2213
}
2212
- <*>{CCS} {
2214
+ <*>{CCS} {
2213
2215
startFontClass (yyscanner," comment" );
2214
2216
yyextra->code ->codify (yytext);
2215
2217
// check is to prevent getting stuck in skipping C++ comments
@@ -2251,15 +2253,6 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
2251
2253
yyextra->yyColNr++;
2252
2254
yyextra->code->codify(yytext);
2253
2255
}
2254
- /*
2255
- <*>([ \t\n ]*" \n" ){2,} { // combine multiple blank lines
2256
- //QCString sepLine=yytext;
2257
- //yyextra->code->codify(" \n\n" );
2258
- //yyextra->yyLineNr+=sepLine.contains('\n ');
2259
- //char sepLine[3]=" \n\n" ;
2260
- codifyLines(yyscanner,yytext);
2261
- }
2262
- */
2263
2256
2264
2257
%%
2265
2258
@@ -2431,27 +2424,51 @@ static void setClassScope(yyscan_t yyscanner,const QCString &name)
2431
2424
DBG_CTX((stderr," --->New class scope ' %s' \n" ,qPrint(yyextra->classScope)));
2432
2425
}
2433
2426
2427
+ static void endCodeFold(yyscan_t yyscanner)
2428
+ {
2429
+ struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2430
+ while (!yyextra->foldStack.empty())
2431
+ {
2432
+ const Definition *dd = yyextra->foldStack.back();
2433
+ if (dd->getEndBodyLine()+1==yyextra->yyLineNr) // +1 to close the section after the end of the body
2434
+ {
2435
+ yyextra->code->endFold();
2436
+ //fprintf(stderr," %d: end codeFolding for %s [%d..%d]\n" ,yyextra->yyLineNr,qPrint(dd->name()),dd->getStartDefLine(),dd->getEndBodyLine());
2437
+ yyextra->foldStack.pop_back();
2438
+ }
2439
+ else
2440
+ {
2441
+ //fprintf(stderr," no end of block dd=%s end=%d\n" ,qPrint(dd->qualifiedName()),dd->getEndBodyLine());
2442
+ break;
2443
+ }
2444
+ }
2445
+ }
2446
+
2447
+ static void skipHiddenComment(yyscan_t yyscanner,const char *text)
2448
+ {
2449
+ struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2450
+ int count=QCString(text).contains('\n ');
2451
+ if (yyextra->insideCodeLine)
2452
+ {
2453
+ endCodeLine(yyscanner);
2454
+ }
2455
+ for (int i=0;i<count;i++)
2456
+ {
2457
+ yyextra->yyLineNr++;
2458
+ endCodeFold(yyscanner);
2459
+ }
2460
+ }
2461
+
2462
+
2434
2463
static void codeFolding(yyscan_t yyscanner,const Definition *d)
2435
2464
{
2436
2465
if (Config_getBool(HTML_CODE_FOLDING))
2437
2466
{
2438
2467
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2468
+ //fprintf(stderr," codeFolding at %d\n" ,yyextra->yyLineNr);
2439
2469
//if (d)
2440
- // printf(" %d: codeFolding: candidate=%s [%d..%d]\n" ,yyextra->yyLineNr,qPrint(d->qualifiedName()),d->getStartDefLine(),d->getEndBodyLine());
2441
- while (!yyextra->foldStack.empty())
2442
- {
2443
- const Definition *dd = yyextra->foldStack.back();
2444
- if (dd->getEndBodyLine()+1==yyextra->yyLineNr) // +1 to close the section after the end of the body
2445
- {
2446
- yyextra->code->endFold();
2447
- //printf(" %d: end codeFolding for %s [%d..%d]\n" ,yyextra->yyLineNr,qPrint(dd->name()),dd->getStartDefLine(),dd->getEndBodyLine());
2448
- yyextra->foldStack.pop_back();
2449
- }
2450
- else
2451
- {
2452
- break;
2453
- }
2454
- }
2470
+ // fprintf(stderr," %d: codeFolding: candidate=%s [%d..%d]\n" ,yyextra->yyLineNr,qPrint(d->qualifiedName()),d->getStartDefLine(),d->getEndBodyLine());
2471
+ endCodeFold(yyscanner);
2455
2472
if (d)
2456
2473
{
2457
2474
int startLine = d->getStartDefLine();
0 commit comments