diff options
author | albert-github <albert.tests@gmail.com> | 2021-02-18 14:52:08 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2021-02-18 14:52:08 (GMT) |
commit | 789625caed4097a075819b7d7299ab1a808fcf08 (patch) | |
tree | fa46abf59bcab172963b3c719a883d2bff662926 /src/code.l | |
parent | 0f0b282be4762cbbae0808f4e21dba3aa157fd37 (diff) | |
download | Doxygen-789625caed4097a075819b7d7299ab1a808fcf08.zip Doxygen-789625caed4097a075819b7d7299ab1a808fcf08.tar.gz Doxygen-789625caed4097a075819b7d7299ab1a808fcf08.tar.bz2 |
Adding support for lex files
- Correct handling of C comment start and end tokens as well as Cpp comment start in rules. These tokes can give "Reached end of file while still inside a (nested) comment..."
- Correct other warnings in respect to lex files
Diffstat (limited to 'src/code.l')
-rw-r--r-- | src/code.l | 79 |
1 files changed, 47 insertions, 32 deletions
@@ -261,6 +261,7 @@ static std::mutex g_countFlowKeywordsMutex; %} B [ \t] +Bopt {B}* BN [ \t\n\r] ID "$"?[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* SEP ("::"|"\\") @@ -284,6 +285,8 @@ OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP} RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"(" RAWEND ")"[^ \t\(\)\\]{0,16}\" + /* no comment start / end signs inside square brackets */ +NCOMM [^/\*] //- start: NUMBER ------------------------------------------------------------------------- // Note same defines in commentcnv.l: keep in sync DECIMAL_INTEGER [1-9][0-9']*[0-9]?[uU]?[lL]?[lL]? @@ -312,6 +315,18 @@ FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL} NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} //- end: NUMBER --------------------------------------------------------------------------- + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + + // ENDIDopt +ENDIDopt ("::"{ID})* + // Optional end qualifiers +ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))* + %option noyywrap %x SkipString @@ -540,7 +555,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <SkipCPP>\\[\r]?\n { codifyLines(yyscanner,yytext); } -<SkipCPP>"//"/[^/!] { +<SkipCPP>{CPPC}/[^/!] { REJECT; } <Body,FuncCall>"{" { @@ -744,7 +759,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN( Bases ); } <PackageName>[ \t]*";" | -<Bases>^{B}*/"@"{ID} | // Objective-C interface +<Bases>^{Bopt}/"@"{ID} | // Objective-C interface <Bases,ClassName,ClassVar,CppCliTypeModifierFollowup>{B}*"{"{B}* { yyextra->theVarContext.pushScope(); yyextra->code->codify(yytext); @@ -864,7 +879,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} } -<Body>{SCOPEPREFIX}?"operator"{B}*"()"{B}*/"(" { +<Body>{SCOPEPREFIX}?"operator"{B}*"()"{Bopt}/"(" { addType(yyscanner); generateFunctionLink(yyscanner,*yyextra->code,yytext); yyextra->bracketCount=0; @@ -1097,7 +1112,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} generatePHPVariableLink(yyscanner,*yyextra->code,yytext); yyextra->name+=yytext+7; } -<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>\(]*">"("::"{ID})*/{B}* { // A<T> *pt; +<Body,TemplCast>{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>\(]*">"{ENDIDopt}/{B}* { // A<T> *pt; if (isCastKeyword(yytext) && YY_START==Body) { REJECT; @@ -1175,7 +1190,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <SkipStringS>[^\'\\\r\n]* { yyextra->code->codify(yytext); } -<SkipString,SkipStringS>"//"|"/*" { +<SkipString,SkipStringS>{CPPC}|{CCS} { yyextra->code->codify(yytext); } <SkipString>@?\" { @@ -1420,21 +1435,21 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} } //printf("close\n"); } -<ObjCCall,ObjCMName>"//".* { +<ObjCCall,ObjCMName>{CPPC}.* { yyextra->currentCtx->format+=escapeComment(yyscanner,yytext); } -<ObjCCall,ObjCMName>"/*" { +<ObjCCall,ObjCMName>{CCS} { yyextra->lastObjCCallContext = YY_START; yyextra->currentCtx->comment=yytext; BEGIN(ObjCCallComment); } -<ObjCCallComment>"*/" { +<ObjCCallComment>{CCE} { yyextra->currentCtx->comment+=yytext; yyextra->currentCtx->format+=escapeComment(yyscanner,yyextra->currentCtx->comment); BEGIN(yyextra->lastObjCCallContext); } <ObjCCallComment>[^*\n]+ { yyextra->currentCtx->comment+=yytext; } -<ObjCCallComment>"//"|"/*" { yyextra->currentCtx->comment+=yytext; } +<ObjCCallComment>{CPPC}|{CCS} { yyextra->currentCtx->comment+=yytext; } <ObjCCallComment>\n { yyextra->currentCtx->comment+=*yytext; } <ObjCCallComment>. { yyextra->currentCtx->comment+=*yytext; } <ObjCCall>{ID} { @@ -1675,7 +1690,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN( SkipInits ); } } -<CallEnd>("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*/{BN}*(";"|"="|"throw"{BN}*"(") { +<CallEnd>{ENDQopt}/{BN}*(";"|"="|"throw"{BN}*"(") { startFontClass(yyscanner,"keyword"); codifyLines(yyscanner,yytext); endFontClass(yyscanner); @@ -1855,18 +1870,18 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->memCallContext = YY_START; BEGIN( MemberCall ); } -<SkipComment>"/*"("!"?)"*/" { +<SkipComment>{CCS}("!"?){CCE} { yyextra->code->codify(yytext); endFontClass(yyscanner); BEGIN( yyextra->lastCContext ) ; } -<SkipComment>"//"|"/*" { +<SkipComment>{CPPC}|{CCS} { yyextra->code->codify(yytext); } -<SkipComment>[^*/\n]+ { +<SkipComment>[^*\/\n]+ { yyextra->code->codify(yytext); } -<SkipComment>[ \t]*"*/" { +<SkipComment>[ \t]*{CCE} { yyextra->code->codify(yytext); endFontClass(yyscanner); if (yyextra->lastCContext==SkipCPP) @@ -1890,10 +1905,10 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <SkipCxxComment>. { yyextra->code->codify(yytext); } -<RemoveSpecialCComment>"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)?{B}*"/*"[*!]/[^/*] { +<RemoveSpecialCComment>{CCE}{B}*\n({B}*\n)*({B}*(({CPPC}"@"[{}])|({CCS}"@"[{}]{CCE})){B}*\n)?{B}*{CCS}[*!]/{NCOMM} { yyextra->yyLineNr+=QCString(yytext).contains('\n'); } -<RemoveSpecialCComment>"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)? { +<RemoveSpecialCComment>{CCE}{B}*\n({B}*\n)*({B}*(({CPPC}"@"[{}])|({CCS}"@"[{}]{CCE})){B}*\n)? { if (yyextra->lastSpecialCContext==SkipCxxComment) { // force end of C++ comment here yyextra->yyLineNr+=QCString(yytext).contains('\n'); @@ -1916,11 +1931,11 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(yyextra->lastSpecialCContext); } } -<RemoveSpecialCComment>"*/" { +<RemoveSpecialCComment>{CCE} { BEGIN(yyextra->lastSpecialCContext); } <RemoveSpecialCComment>[^*\n]+ -<RemoveSpecialCComment>"//"|"/*" +<RemoveSpecialCComment>{CPPC}|{CCS} <RemoveSpecialCComment>\n { yyextra->yyLineNr++; } <RemoveSpecialCComment>. <MemberCall>[^a-z_A-Z0-9(\n] { @@ -1929,7 +1944,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->name.resize(0); BEGIN(yyextra->memCallContext); } -<*>\n({B}*"//"[!/][^\n]*\n)+ { // remove special one-line comment +<*>\n({B}*{CPPC}[!/][^\n]*\n)+ { // remove special one-line comment if (YY_START==SkipCPP) REJECT; if (Config_getBool(STRIP_CODE_COMMENTS)) { @@ -1953,7 +1968,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN( yyextra->lastSkipCppContext ) ; unput('\n'); } -<*>\n{B}*"//@"[{}].*\n { // remove one-line group marker +<*>\n{B}*{CPPC}"@"[{}].*\n { // remove one-line group marker if (Config_getBool(STRIP_CODE_COMMENTS)) { yyextra->yyLineNr+=2; @@ -1971,7 +1986,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN( yyextra->lastCContext ) ; } } -<*>\n{B}*"/*@"[{}] { // remove one-line group marker +<*>\n{B}*{CCS}"@"[{}] { // remove one-line group marker if (Config_getBool(STRIP_CODE_COMMENTS)) { if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START; @@ -1990,7 +2005,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(SkipComment); } } -<*>^{B}*"//@"[{}].*\n { // remove one-line group marker +<*>^{B}*{CPPC}"@"[{}].*\n { // remove one-line group marker if (Config_getBool(STRIP_CODE_COMMENTS)) { yyextra->yyLineNr++; @@ -2003,7 +2018,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} endFontClass(yyscanner); } } -<*>^{B}*"/*@"[{}] { // remove multi-line group marker +<*>^{B}*{CCS}"@"[{}] { // remove multi-line group marker if (Config_getBool(STRIP_CODE_COMMENTS)) { if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START; @@ -2021,7 +2036,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(SkipComment); } } -<*>^{B}*"//"[!/][^\n]* { // remove special one-line comment +<*>^{B}*{CPPC}[!/][^\n]* { // remove special one-line comment if (!Config_getBool(STRIP_CODE_COMMENTS)) { startFontClass(yyscanner,"comment"); @@ -2029,7 +2044,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} endFontClass(yyscanner); } } -<*>"//"[!/][^\n]* { // strip special one-line comment +<*>{CPPC}[!/][^\n]* { // strip special one-line comment if (YY_START==SkipComment || YY_START==SkipString) REJECT; if (!Config_getBool(STRIP_CODE_COMMENTS)) { @@ -2038,7 +2053,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} endFontClass(yyscanner); } } -<*>\n{B}*"/*"[!*]/[^/*] { +<*>\n{B}*{CCS}[!*]/{NCOMM} { if (Config_getBool(STRIP_CODE_COMMENTS)) { if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START; @@ -2057,7 +2072,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(SkipComment); } } -<*>^{B}*"/**"[*]+/[^/] { // special C "banner" comment block at a new line +<*>^{B}*{CCS}"*"[*]+/[^/] { // special C "banner" comment block at a new line if (Config_getBool(JAVADOC_BANNER) && Config_getBool(STRIP_CODE_COMMENTS)) { if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START; @@ -2075,7 +2090,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(SkipComment); } } -<*>^{B}*"/*"[!*]/[^/*] { // special C comment block at a new line +<*>^{B}*{CCS}[!*]/{NCOMM} { // special C comment block at a new line if (Config_getBool(STRIP_CODE_COMMENTS)) { if (YY_START != RemoveSpecialCComment) yyextra->lastSpecialCContext = YY_START; @@ -2093,7 +2108,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(SkipComment); } } -<*>"/*"[!*]/[^/*] { // special C comment block half way a line +<*>{CCS}[!*]/{NCOMM} { // special C comment block half way a line if (YY_START==SkipString) REJECT; if (Config_getBool(STRIP_CODE_COMMENTS)) { @@ -2112,7 +2127,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(SkipComment); } } -<*>"/*"("!"?)"*/" { +<*>{CCS}("!"?){CCE} { if (YY_START==SkipString) REJECT; if (!Config_getBool(STRIP_CODE_COMMENTS)) { @@ -2124,7 +2139,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <SkipComment>[^\*\n]+ { yyextra->code->codify(yytext); } -<*>"/*" { +<*>{CCS} { startFontClass(yyscanner,"comment"); yyextra->code->codify(yytext); // check is to prevent getting stuck in skipping C++ comments @@ -2140,7 +2155,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->lastVerbStringContext=YY_START; BEGIN(SkipVerbString); } -<*>"//" { +<*>{CPPC} { startFontClass(yyscanner,"comment"); yyextra->code->codify(yytext); yyextra->lastCContext = YY_START ; |