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 | |
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')
-rw-r--r-- | src/code.l | 79 | ||||
-rw-r--r-- | src/commentcnv.l | 85 | ||||
-rw-r--r-- | src/commentscan.l | 29 | ||||
-rw-r--r-- | src/declinfo.l | 5 | ||||
-rw-r--r-- | src/defargs.l | 18 | ||||
-rw-r--r-- | src/doctokenizer.l | 7 | ||||
-rw-r--r-- | src/fortrancode.l | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | src/fortranscanner.l | 3 | ||||
-rw-r--r-- | src/lexcode.l | 85 | ||||
-rw-r--r-- | src/lexscanner.l | 85 | ||||
-rw-r--r-- | src/pre.l | 80 | ||||
-rw-r--r-- | src/pycode.l | 2 | ||||
-rw-r--r-- | src/scanner.l | 180 | ||||
-rw-r--r-- | src/sqlcode.l | 2 |
14 files changed, 397 insertions, 270 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 ; diff --git a/src/commentcnv.l b/src/commentcnv.l index 817feb3..1aee6bf 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -171,6 +171,23 @@ FLOAT_NUMBER {FLOAT_DECIMAL}|{FLOAT_HEXADECIMAL} NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} //- end: NUMBER --------------------------------------------------------------------------- + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + + // Optional any character +ANYopt .* + + // Optional white space +WSopt [ \t\r]* + // readline non special +RLopt [^\\@\n\*\/]* + // Optional slash +SLASHopt [/]* + %% <Scan>{NUMBER} { //Note similar code in code.l @@ -277,8 +294,8 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <Scan>\n { /* new line */ copyToOutput(yyscanner,yytext,(int)yyleng); } -<Scan>"//!"/.*\n[ \t]*"//"[\/!][^\/] | /* start C++ style special comment block */ -<Scan>("///"[/]*)/[^/].*\n[ \t]*"//"[\/!][^\/] { /* start C++ style special comment block */ +<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) { REJECT; // bail out if we do not need to convert @@ -299,7 +316,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(ReadLine); } } -<Scan>"//##Documentation".*/\n { /* Start of Rational Rose ANSI C++ comment block */ +<Scan>{CPPC}"##Documentation"{ANYopt}/\n { /* Start of Rational Rose ANSI C++ comment block */ if (yyextra->mlBrief) REJECT; int i=17; //=strlen("//##Documentation"); yyextra->blockHeadCol=yyextra->col; @@ -308,22 +325,22 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->inRoseComment=TRUE; BEGIN(SComment); } -<Scan>"//"[!\/]/.*\n[ \t]*"//"[|\/][ \t]*[@\\]"}" { // next line contains an end marker, see bug 752712 +<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); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -<Scan>"//"/.*\n { /* one line C++ comment */ +<Scan>{CPPC}/.*\n { /* one line C++ comment */ yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!'; copyToOutput(yyscanner,yytext,(int)yyleng); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -<Scan>"/**/" { /* avoid matching next rule for empty C comment, see bug 711723 */ +<Scan>{CCS}{CCE} { /* avoid matching next rule for empty C comment, see bug 711723 */ copyToOutput(yyscanner,yytext,(int)yyleng); } -<Scan>"/*"[*!]? { /* start of a C comment */ +<Scan>{CCS}[*!]? { /* start of a C comment */ if (yyextra->lang==SrcLangExt_Python) { REJECT; @@ -444,8 +461,14 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->lastCommentContext = YY_START; BEGIN(Verbatim); } +<Scan>"\\\"" { /* escaped double quote */ + copyToOutput(yyscanner,yytext,(int)yyleng); + } +<Scan>"\\\\" { /* escaped backslash */ + copyToOutput(yyscanner,yytext,(int)yyleng); + } <Scan>. { /* any other character */ - copyToOutput(yyscanner,yytext,(int)yyleng); + copyToOutput(yyscanner,yytext,(int)yyleng); } <Verbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}") { /* end of verbatim block */ copyToOutput(yyscanner,yytext,(int)yyleng); @@ -502,7 +525,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(yyextra->lastCommentContext); } } -<VerbatimCode>^[ \t]*"//"[\!\/]? { /* skip leading comments */ +<VerbatimCode>^[ \t]*{CPPC}[\!\/]? { /* skip leading comments */ if (!yyextra->inSpecialComment) { copyToOutput(yyscanner,yytext,(int)yyleng); @@ -531,7 +554,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <Verbatim,VerbatimCode>\n { /* new line in verbatim block */ copyToOutput(yyscanner,yytext,(int)yyleng); } -<Verbatim>^[ \t]*"//"[/!] { +<Verbatim>^[ \t]*{CPPC}[/!] { if (yyextra->blockName=="dot" || yyextra->blockName=="msc" || yyextra->blockName=="uml" || yyextra->blockName.at(0)=='f') { // see bug 487871, strip /// from dot images and formulas. @@ -597,7 +620,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <CComment>[^ `~<\\!@*\n{\"\/]* { /* anything that is not a '*' or command */ copyToOutput(yyscanner,yytext,(int)yyleng); } -<CComment>"*"+[^*/\\@\n{\"]* { /* stars without slashes */ +<CComment>"*"+[^*\/\\@\n{\"]* { /* stars without slashes */ copyToOutput(yyscanner,yytext,(int)yyleng); } <CComment>"\"\"\"" { /* end of Python docstring */ @@ -729,18 +752,18 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <CComment>. { copyToOutput(yyscanner,yytext,(int)yyleng); } -<SComment>^[ \t]*"///"[\/]*/\n { +<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n { replaceComment(yyscanner,0); } -<SComment>\n[ \t]*"///"[\/]*/\n { +<SComment>\n[ \t]*{CPPC}"/"{SLASHopt}/\n { replaceComment(yyscanner,1); } -<SComment>^[ \t]*"///"[^\/\n]/.*\n { +<SComment>^[ \t]*{CPPC}"/"[^\/\n]/.*\n { replaceComment(yyscanner,0); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -<SComment>\n[ \t]*"//"[\/!]("<")?[ \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); @@ -748,26 +771,26 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->inRoseComment=FALSE; BEGIN(Scan); } -<SComment>\n[ \t]*"///"[^\/\n]/.*\n { +<SComment>\n[ \t]*{CPPC}"/"[^\/\n]/.*\n { replaceComment(yyscanner,1); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -<SComment>^[ \t]*"//!" | // just //! -<SComment>^[ \t]*"//!<"/.*\n | // or //!< something -<SComment>^[ \t]*"//!"[^<]/.*\n { // or //!something +<SComment>^[ \t]*{CPPC}"!" | // just //! +<SComment>^[ \t]*{CPPC}"!<"/.*\n | // or //!< something +<SComment>^[ \t]*{CPPC}"!"[^<]/.*\n { // or //!something replaceComment(yyscanner,0); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -<SComment>\n[ \t]*"//!" | -<SComment>\n[ \t]*"//!<"/.*\n | -<SComment>\n[ \t]*"//!"[^<\n]/.*\n { +<SComment>\n[ \t]*{CPPC}"!" | +<SComment>\n[ \t]*{CPPC}"!<"/.*\n | +<SComment>\n[ \t]*{CPPC}"!"[^<\n]/.*\n { replaceComment(yyscanner,1); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -<SComment>^[ \t]*"//##"/.*\n { +<SComment>^[ \t]*{CPPC}"##"/.*\n { if (!yyextra->inRoseComment) { REJECT; @@ -779,7 +802,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(ReadLine); } } -<SComment>\n[ \t]*"//##"/.*\n { +<SComment>\n[ \t]*{CPPC}"##"/.*\n { if (!yyextra->inRoseComment) { REJECT; @@ -798,19 +821,19 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->inRoseComment=FALSE; BEGIN(Scan); } -<ReadLine>"/**" { +<ReadLine>{CCS}"*" { copyToOutput(yyscanner,"/‍**",8); } -<ReadLine>"*/" { +<ReadLine>{CCE} { copyToOutput(yyscanner,"*‍/",7); } <ReadLine>"*" { copyToOutput(yyscanner,yytext,(int)yyleng); } -<ReadLine>[^\\@\n\*/]* { +<ReadLine>{RLopt} { copyToOutput(yyscanner,yytext,(int)yyleng); } -<ReadLine>[^\\@\n\*/]*/\n { +<ReadLine>{RLopt}/\n { copyToOutput(yyscanner,yytext,(int)yyleng); BEGIN(yyextra->readLineCtx); } @@ -844,7 +867,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} <CondLine>[!()&| \ta-z_A-Z0-9.\-]+ { handleCondSectionId(yyscanner,yytext); } -<CComment,ReadLine>[\\@]"cond"[ \t\r]*/\n { +<CComment,ReadLine>[\\@]"cond"{WSopt}/\n { yyextra->condCtx=YY_START; handleCondSectionId(yyscanner," "); // fake section id causing the section to be hidden unconditionally } @@ -862,9 +885,9 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->lastEscaped=0; BEGIN( ReadAliasArgs ); } -<ReadAliasArgs>^[ \t]*"//"[/!]/[^\n]+ { // skip leading special comments (see bug 618079) +<ReadAliasArgs>^[ \t]*{CPPC}[/!]/[^\n]+ { // skip leading special comments (see bug 618079) } -<ReadAliasArgs>"*/" { // oops, end of comment in the middle of an alias? +<ReadAliasArgs>{CCE} { // oops, end of comment in the middle of an alias? if (yyextra->lang==SrcLangExt_Python) { REJECT; diff --git a/src/commentscan.l b/src/commentscan.l index 767b964..8f43d7b 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -469,7 +469,8 @@ DETAILEDHTMLOPT {CODE} BN [ \t\n\r] BL [ \t\r]*"\n" B [ \t] -BS ^(({B}*"//")?)(({B}*"*"+)?){B}* +Bopt {B}* +BS ^(({B}*"/""/")?)(({B}*"*"+)?){B}* ATTR ({B}+[^>\n]*)? DOCNL "\n"|"\\ilinebr" LC "\\"{B}*"\n" @@ -488,6 +489,18 @@ TMPLSPEC "<"{BN}*[^>]+{BN}*">" MAILADDR [a-z_A-Z0-9.+\-]+"@"[a-z_A-Z0-9\-]+("."[a-z_A-Z0-9\-]+)+[a-z_A-Z0-9\-]+ RCSTAG "$"{ID}":"[^\n$]+"$" + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + + // end of section title with asterisk +STAopt [^\n@\\*]* + // end of section title without asterisk +STopt [^\n@\\]* + %option noyywrap /* comment parsing states. */ @@ -541,7 +554,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" /* What can happen in while parsing a comment block: * commands (e.g. @page, or \page) * escaped commands (e.g. @@page or \\page). - * formulas (e.g. \f$ \f[ \f{..) + * formulas (e.g. \f$...\f$ \f[...\f] \f{...\f}) * directories (e.g. \doxygen\src\) * autolist end. (e.g. a dot on an otherwise empty line) * newlines. @@ -770,7 +783,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" <Comment>[a-z_A-Z]+ { // normal word addOutput(yyscanner,yytext); } -<Comment>^{B}*"."{B}*/\n { // explicit end autolist: e.g " ." +<Comment>^{B}*"."{Bopt}/\n { // explicit end autolist: e.g " ." addOutput(yyscanner,yytext); } <Comment>^{B}*[1-9][0-9]*"."{B}+ | @@ -797,7 +810,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" } addOutput(yyscanner,yytext); } -<Comment>^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{B}*/\n { // horizontal line (dashed) +<Comment>^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{Bopt}/\n { // horizontal line (dashed) addOutput(yyscanner,yytext); } <Comment>{CMD}"---" { // escaped mdash @@ -1344,12 +1357,12 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ); BEGIN(Comment); } -<SectionTitle>[^\n@\\*]*/"\n" { // end of section title +<SectionTitle>{STAopt}/"\n" { // end of section title addSection(yyscanner); addOutput(yyscanner,yytext); BEGIN( Comment ); } -<SectionTitle>[^\n@\\]*/"\\ilinebr" { // end of section title +<SectionTitle>{STopt}/"\\ilinebr" { // end of section title addSection(yyscanner); addOutput(yyscanner,yytext); BEGIN( Comment ); @@ -1451,11 +1464,11 @@ RCSTAG "$"{ID}":"[^\n$]+"$" if (*yytext=='\n') yyextra->lineNr++; addOutput(yyscanner,'\n'); } -<FormatBlock>"/*" { // start of a C-comment +<FormatBlock>{CCS} { // start of a C-comment if (!(yyextra->blockName=="code" || yyextra->blockName=="verbatim")) yyextra->commentCount++; addOutput(yyscanner,yytext); } -<FormatBlock>"*/" { // end of a C-comment +<FormatBlock>{CCE} { // end of a C-comment addOutput(yyscanner,yytext); if (!(yyextra->blockName=="code" || yyextra->blockName=="verbatim")) { diff --git a/src/declinfo.l b/src/declinfo.l index 014ef75..9ed7738 100644 --- a/src/declinfo.l +++ b/src/declinfo.l @@ -83,6 +83,7 @@ static yy_size_t yyread(char *buf,yy_size_t max_size, yyscan_t yyscanner); %} B [ \t] +Bopt {B}* ID "$"?([a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]*)|(@[0-9]+) %x Start @@ -188,11 +189,11 @@ ID "$"?([a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]*)|(@[0-9]+) <Template>. { yyextra->name+=*yytext; } -<Operator>{B}*"("{B}*")"{B}*"<>"{B}*/"(" { +<Operator>{B}*"("{B}*")"{B}*"<>"{Bopt}/"(" { yyextra->name+="() <>"; BEGIN(ReadArgs); } -<Operator>{B}*"("{B}*")"{B}*/"(" { +<Operator>{B}*"("{B}*")"{Bopt}/"(" { yyextra->name+="()"; BEGIN(ReadArgs); } diff --git a/src/defargs.l b/src/defargs.l index 76d07ec..ce97492 100644 --- a/src/defargs.l +++ b/src/defargs.l @@ -115,10 +115,18 @@ static bool nameIsActuallyPartOfType(QCString &name); %} B [ \t] +Bopt {B}* ID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"(" RAWEND ")"[^ \t\(\)\\]{0,16}\" + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + %option noyywrap %x Start @@ -169,7 +177,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" yyextra->curArgDefValue+=*yytext; BEGIN( CopyArgString ); } -<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{B}*/{ID} { +<ReadFuncArgType>"("([^:)]+{B}*"::")*{B}*[&*\^]+{Bopt}/{ID} { // function pointer as argument yyextra->curArgTypeName+=yytext; //yyextra->curArgTypeName=yyextra->curArgTypeName.simplifyWhiteSpace(); @@ -337,7 +345,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" <ReadFuncArgType>"=" { BEGIN( ReadFuncArgDef ); } -<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*("/*"[*!]|"//"[/!])"<" { +<ReadFuncArgType,ReadFuncArgDef>[,)>]{B}*({CCS}[*!]|{CPPC}[/!])"<" { yyextra->lastDocContext=YY_START; yyextra->lastDocChar=*yytext; QCString text=yytext; @@ -547,7 +555,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" <ReadDocLine>[^\n]+ { yyextra->curArgDocs+=yytext; } -<ReadDocBlock>"*/" { +<ReadDocBlock>{CCE} { if (yyextra->lastDocChar!=0) unput(yyextra->lastDocChar); BEGIN(yyextra->lastDocContext); @@ -563,7 +571,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\" <ReadDocBlock>. { yyextra->curArgDocs+=*yytext; } -<*>("/*"[*!]|"//"[/!])("<"?) { +<*>({CCS}[*!]|{CPPC}[/!])("<"?) { yyextra->lastDocContext=YY_START; yyextra->lastDocChar=0; if (yytext[1]=='/') @@ -764,8 +772,8 @@ static bool nameIsActuallyPartOfType(QCString &name) } /*! Converts an argument string into an ArgumentList. + * \param[in] lang langage of the current argument list * \param[in] argsString the list of Arguments. - * \param[out] al a reference to resulting argument list pointer. * \param[out] extraTypeChars point to string to which trailing characters * for complex types are written to */ diff --git a/src/doctokenizer.l b/src/doctokenizer.l index 0c167ca..d994340 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -365,6 +365,7 @@ CMD ("\\"|"@") WS [ \t\r\n] NONWS [^ \t\r\n] BLANK [ \t\r] +BLANKopt {BLANK}* ID "$"?[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* LABELID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF\-]* PHPTYPE [\\:a-z_A-Z0-9\x80-\xFF\-]+ @@ -374,7 +375,7 @@ CITEID {CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*|"\""{CITESCHAR}{C MAILADDR ("mailto:")?[a-z_A-Z0-9.+-]+"@"[a-z_A-Z0-9-]+("."[a-z_A-Z0-9\-]+)+[a-z_A-Z0-9\-]+ MAILWS [\t a-z_A-Z0-9+-] MAILADDR2 {MAILWS}+{BLANK}+("at"|"AT"|"_at_"|"_AT_"){BLANK}+{MAILWS}+("dot"|"DOT"|"_dot_"|"_DOT_"){BLANK}+{MAILWS}+ -OPTSTARS ("//"{BLANK}*)?"*"*{BLANK}* +OPTSTARS ("/""/"{BLANK}*)?"*"*{BLANK}* LISTITEM {BLANK}*[-]("#")?{WS} MLISTITEM {BLANK}*[+*]{WS} OLISTITEM {BLANK}*[1-9][0-9]*"."{BLANK} @@ -965,11 +966,11 @@ RCSID "$"("Author"|"Date"|"Header"|"Id"|"Locker"|"Log"|"Name"|"RCSfile"|"Revisio g_token->sectionId = QCString(yytext).stripWhiteSpace(); return RetVal_OK; } -<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANK}*/\n { // case 4: plain file name specified without title or attributes +<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANKopt}/\n { // case 4: plain file name specified without title or attributes g_token->sectionId = QCString(yytext).stripWhiteSpace(); return RetVal_OK; } -<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANK}*/"\\ilinebr" { // case 5: plain file name specified without title or attributes +<St_PlantUMLOpt>{BLANK}*{FILEMASK}{BLANKopt}/"\\ilinebr" { // case 5: plain file name specified without title or attributes g_token->sectionId = QCString(yytext).stripWhiteSpace(); return RetVal_OK; } diff --git a/src/fortrancode.l b/src/fortrancode.l index d2febb9..fbc1a64 100644 --- a/src/fortrancode.l +++ b/src/fortrancode.l @@ -321,7 +321,7 @@ LANGUAGE_BIND_SPEC BIND{BS}"("{BS}C{BS}(,{BS}NAME{BS}"="{BS}"\""(.*)"\""{BS})?") codifyLines(yyscanner,yytext); endFontClass(yyscanner); } -<Start>^{BS}"namelist"/[//] { // Namelist specification +<Start>^{BS}"namelist"/[/] { // Namelist specification startFontClass(yyscanner,"keywordtype"); codifyLines(yyscanner,yytext); endFontClass(yyscanner); @@ -1067,7 +1067,7 @@ static bool getFortranNamespaceDefs(const QCString &mname, @param tname the name of the type @param moduleName name of enclosing module or null, if global entry @param cd the entry, if found or null - @param usedict dictionary of data of USE-statement + @param useMap map of data of USE-statement @returns true, if type is found */ static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName, @@ -1105,9 +1105,10 @@ static bool getFortranTypeDefs(const QCString &tname, const QCString &moduleName /** searches for definition of function memberName + @param yyscanner the scanner data to be used @param memberName the name of the function/variable @param moduleName name of enclosing module or null, if global entry - @param usedict array of data of USE-statement + @param useMap map of data of USE-statement @returns MemberDef pointer, if found, or nullptr otherwise */ static MemberDef *getFortranDefs(yyscan_t yyscanner,const QCString &memberName, const QCString &moduleName, diff --git a/src/fortranscanner.l b/src/fortranscanner.l index 74d6d03..c0f7457 100644..100755 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -1795,7 +1795,8 @@ static void copyEntry(std::shared_ptr<Entry> dest, const std::shared_ptr<Entry> /** fill empty interface module procedures with info from corresponding module subprogs - @TODO: handle procedures in used modules + + TODO: handle procedures in used modules */ void resolveModuleProcedures(yyscan_t yyscanner,Entry *current_root) { diff --git a/src/lexcode.l b/src/lexcode.l index d6b41b0..a118703 100644 --- a/src/lexcode.l +++ b/src/lexcode.l @@ -127,6 +127,7 @@ CMD ("\\"|"@") BN [ \t\n\r] BL [ \t\r]*"\n" B [ \t] +Bopt {B}* ID "$"?[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* PRE [pP][rR][eE] CODE [cC][oO][dD][eE] @@ -134,6 +135,22 @@ RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"(" RAWEND ")"[^ \t\(\)\\]{0,16}\" CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) + /* no comment start / end signs inside square brackets */ +NCOMM [^/\*] + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + // doxygen start comment +DCOMM ("/\*!"|"/\**"|"/\/!"|"/\/\/") + + // Optional any character +ANYopt .* + // Optional all but newline +NONLopt [^\n]* + %x DefSection %x DefSectionLine %x RulesSectionInit @@ -197,22 +214,22 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; yyextra->yyLineNr++; } -<DefSection>"//".*{nl} { +<DefSection>{CPPC}.*{nl} { yyextra->CCodeBuffer += yytext; yyextra->yyLineNr++; } -<DefSection>^{ws}*"/*" { +<DefSection>^{ws}*{CCS} { yyextra->CCodeBuffer += yytext; yyextra->lastContext = YY_START; BEGIN(COMMENT); } -<COMMENT>"*/"{ws}*{nl} { +<COMMENT>{CCE}{ws}*{nl} { yyextra->CCodeBuffer+=yytext; yyextra->yyLineNr++; handleCCode(yyscanner); BEGIN(yyextra->lastContext); } -<COMMENT>"*/" { +<COMMENT>{CCE} { yyextra->CCodeBuffer+=yytext; handleCCode(yyscanner); BEGIN(yyextra->lastContext); @@ -220,7 +237,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <COMMENT>[^*\n]+ { yyextra->CCodeBuffer += yytext; } -<COMMENT>"//"|"/*" { +<COMMENT>{CPPC}|{CCS} { yyextra->CCodeBuffer += yytext; } <COMMENT>{nl} { @@ -407,7 +424,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <RulesPattern>"\\\\" { yyextra->rulesPatternBuffer += yytext; } -<RulesPattern>"/*" { +<RulesPattern>{CCS} { if (!yyextra->rulesPatternBuffer.isEmpty()) { startFontClass(yyscanner,"stringliteral"); @@ -442,7 +459,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; ++yyextra->curlyCount ; } -<SkipCurly>"}"/{BN}*("/*!"|"/**"|"//!"|"///")"<!--" | /* see bug710917 */ +<SkipCurly>"}"/{BN}*{DCOMM}"<!--" | /* see bug710917 */ <SkipCurly>"}" { yyextra->CCodeBuffer += yytext; lineCount(yyscanner); @@ -451,7 +468,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) --yyextra->curlyCount ; } } -<SkipCurly>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { +<SkipCurly>"}"{BN}*{DCOMM}"<" { yyextra->CCodeBuffer += yytext; lineCount(yyscanner); if ( yyextra->curlyCount ) @@ -492,12 +509,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCurly>[^\n#"'@\\/{}<]+ { yyextra->CCodeBuffer += yytext; } -<SkipCurly>"/*" { +<SkipCurly>{CCS} { yyextra->CCodeBuffer += yytext; yyextra->lastCContext = YY_START; BEGIN(SkipComment); } -<SkipCurly>"//" { +<SkipCurly>{CPPC} { yyextra->CCodeBuffer += yytext; yyextra->lastCContext = YY_START; BEGIN(SkipCxxComment); @@ -511,12 +528,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCurly>. { yyextra->CCodeBuffer += yytext; } -<SkipCurly>("//"{B}*)?"/*!" { +<SkipCurly>({CPPC}{B}*)?{CCS}"!" { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocBlock ); } -<SkipCurly>"/**"[*]+{BL} { +<SkipCurly>{CCS}"*"[*]+{BL} { bool javadocBanner = Config_getBool(JAVADOC_BANNER); yyextra->CCodeBuffer += yytext; yyextra->yyLineNr++; @@ -530,17 +547,17 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN( Comment ) ; } } -<SkipCurly>("//"{B}*)?"/**"/[^/*] { +<SkipCurly>({CPPC}{B}*)?{CCS}"*"/{NCOMM} { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocBlock ); } -<SkipCurly>"//!" { +<SkipCurly>{CPPC}"!" { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocLine ); } -<SkipCurly>"///"/[^/] { +<SkipCurly>{CPPC}"/"/[^/] { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocLine ); @@ -562,7 +579,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; BEGIN( yyextra->lastStringContext ); } -<SkipString>"/*"|"*/"|"//" { +<SkipString>{CCS}|{CCE}|{CPPC} { yyextra->CCodeBuffer += yytext; } <SkipString>\n { @@ -576,7 +593,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; yyextra->yyLineNr++; } -<SkipCxxComment>.*/\n { +<SkipCxxComment>{ANYopt}/\n { yyextra->CCodeBuffer += yytext; BEGIN( yyextra->lastCContext ) ; } @@ -584,8 +601,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext ; lineCount(yyscanner); } -<Comment>"/*" { yyextra->CCodeBuffer += yytext ; } -<Comment>"//" { yyextra->CCodeBuffer += yytext ; } +<Comment>{CCS} { yyextra->CCodeBuffer += yytext ; } +<Comment>{CPPC} { yyextra->CCodeBuffer += yytext ; } <Comment>{CMD}("code"|"verbatim") { yyextra->insideCode=TRUE; yyextra->CCodeBuffer += yytext ; @@ -595,13 +612,13 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext ; } <Comment>[^ \.\t\r\n\/\*]+ { yyextra->CCodeBuffer += yytext ; } -<Comment>"*/" { +<Comment>{CCE} { yyextra->CCodeBuffer += yytext ; if (!yyextra->insideCode) BEGIN( yyextra->lastContext ) ; } <Comment>. { yyextra->CCodeBuffer += *yytext ; } -<SkipComment>"//"|"/*" { +<SkipComment>{CPPC}|{CCS} { yyextra->CCodeBuffer += yytext; } <SkipComment>[^\*\n]+ { @@ -611,7 +628,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; yyextra->yyLineNr++; } -<SkipComment>{B}*"*/" { +<SkipComment>{B}*{CCE} { yyextra->CCodeBuffer += yytext; BEGIN( yyextra->lastCContext ); } @@ -640,42 +657,42 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) /* ---- Single line comments ------ */ -<DocLine>[^\n]*"\n"[ \t]*"//"[/!][<]? { // continuation of multiline C++-style comment +<DocLine>[^\n]*"\n"[ \t]*{CPPC}[/!][<]? { // continuation of multiline C++-style comment yyextra->CCodeBuffer += yytext; lineCount(yyscanner); } -<DocLine>{B}*"///"[/]+{B}*/"\n" { // ignore marker line (see bug700345) +<DocLine>{B}*{CPPC}"/"[/]+{Bopt}/"\n" { // ignore marker line (see bug700345) yyextra->CCodeBuffer += yytext; BEGIN( yyextra->docBlockContext ); } -<DocLine>[^\n]*/"\n"{B}*"//"[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712 +<DocLine>{NONLopt}/"\n"{B}*{CPPC}[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712 yyextra->CCodeBuffer += yytext; BEGIN( yyextra->docBlockContext ); } -<DocLine>[^\n]*/"\n" { // whole line +<DocLine>{NONLopt}/"\n" { // whole line yyextra->CCodeBuffer += yytext; BEGIN( yyextra->docBlockContext ); } /* ---- Comments blocks ------ */ -<DocBlock>"*"*"*/" { // end of comment block +<DocBlock>"*"*{CCE} { // end of comment block yyextra->CCodeBuffer += yytext; BEGIN(yyextra->docBlockContext); } <DocBlock>^{B}*"*"+/[^/] { yyextra->CCodeBuffer += yytext; } -<DocBlock>^{B}*("//")?{B}*"*"+/[^//a-z_A-Z0-9*] { // start of a comment line +<DocBlock>^{B}*({CPPC})?{B}*"*"+/[^/a-z_A-Z0-9*] { // start of a comment line yyextra->CCodeBuffer += yytext; } -<DocBlock>^{B}*("//"){B}* { // strip embedded C++ comments if at the start of a line +<DocBlock>^{B}*({CPPC}){B}* { // strip embedded C++ comments if at the start of a line yyextra->CCodeBuffer += yytext; } -<DocBlock>"//" { // slashes in the middle of a comment block +<DocBlock>{CPPC} { // slashes in the middle of a comment block yyextra->CCodeBuffer += yytext; } -<DocBlock>"/*" { // start of a new comment in the +<DocBlock>{CCS} { // start of a new comment in the // middle of a comment block yyextra->CCodeBuffer += yytext; } @@ -831,10 +848,10 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(DocBlock); } } -<DocCopyBlock>[^\<@/*\]~\$\\\n]+ { // any character that is not special +<DocCopyBlock>[^\<@/\*\]~\$\\\n]+ { // any character that is not special yyextra->CCodeBuffer += yytext; } -<DocCopyBlock>"/*"|"*/"|"//" { +<DocCopyBlock>{CCS}|{CCE}|{CPPC} { if (yytext[1]=='*') { yyextra->nestedComment=TRUE; @@ -852,7 +869,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <DocCopyBlock>. { // any other character yyextra->CCodeBuffer += yytext; } -<SkipCurlyEndDoc>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { // desc is followed by another one +<SkipCurlyEndDoc>"}"{BN}*{DCOMM}"<" { // desc is followed by another one yyextra->docBlockContext = SkipCurlyEndDoc; yyextra->CCodeBuffer += yytext; if (yytext[yyleng-3]=='/') diff --git a/src/lexscanner.l b/src/lexscanner.l index e0f3a92..47d3443 100644 --- a/src/lexscanner.l +++ b/src/lexscanner.l @@ -124,6 +124,7 @@ CMD ("\\"|"@") BN [ \t\n\r] BL [ \t\r]*"\n" B [ \t] +Bopt {B}* ID "$"?[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* PRE [pP][rR][eE] CODE [cC][oO][dD][eE] @@ -131,6 +132,22 @@ RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"(" RAWEND ")"[^ \t\(\)\\]{0,16}\" CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) + /* no comment start / end signs inside square brackets */ +NCOMM [^/\*] + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + // doxygen start comment +DCOMM ("/\*!"|"/\**"|"/\/!"|"/\/\/") + + // Optional any character +ANYopt .* + // Optional all but newline +NONLopt [^\n]* + %x DefSection %x OptPrefix %x DefSectionLine @@ -205,26 +222,26 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <DefSection>^{nws} { BEGIN(DefSectionLine); } -<DefSection>"//".*{nl} { +<DefSection>{CPPC}.*{nl} { yyextra->CCodeBuffer += yytext; } -<DefSection>^{ws}*"/*" { +<DefSection>^{ws}*{CCS} { yyextra->CCodeBuffer += yytext; yyextra->lastContext = YY_START; BEGIN(COMMENT); } -<COMMENT>"*/"{ws}*{nl} { +<COMMENT>{CCE}{ws}*{nl} { yyextra->CCodeBuffer+=yytext; BEGIN(yyextra->lastContext); } -<COMMENT>"*/" { +<COMMENT>{CCE} { yyextra->CCodeBuffer+=yytext; BEGIN(yyextra->lastContext); } <COMMENT>[^*\n]+ { yyextra->CCodeBuffer += yytext; } -<COMMENT>"//"|"/*" { +<COMMENT>{CPPC}|{CCS} { yyextra->CCodeBuffer += yytext; } <COMMENT>{nl} { @@ -374,7 +391,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <RulesPattern>"\\\\" { yyextra->CCodeBuffer += repeatChar(' ', yyleng); } -<RulesPattern>"/*" { +<RulesPattern>{CCS} { yyextra->CCodeBuffer += yytext; yyextra->lastContext = YY_START; BEGIN(COMMENT); @@ -401,7 +418,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; ++yyextra->curlyCount ; } -<SkipCurly>"}"/{BN}*("/*!"|"/**"|"//!"|"///")"<!--" | /* see bug710917 */ +<SkipCurly>"}"/{BN}*{DCOMM}"<!--" | /* see bug710917 */ <SkipCurly>"}" { yyextra->CCodeBuffer += yytext; if( yyextra->curlyCount ) @@ -409,7 +426,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) --yyextra->curlyCount ; } } -<SkipCurly>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { +<SkipCurly>"}"{BN}*{DCOMM}"<" { yyextra->CCodeBuffer += yytext; if ( yyextra->curlyCount ) { @@ -449,12 +466,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCurly>[^\n#"'@\\/{}<]+ { yyextra->CCodeBuffer += yytext; } -<SkipCurly>"/*" { +<SkipCurly>{CCS} { yyextra->CCodeBuffer += yytext; yyextra->lastCContext = YY_START; BEGIN(SkipComment); } -<SkipCurly>"//" { +<SkipCurly>{CPPC} { yyextra->CCodeBuffer += yytext; yyextra->lastCContext = YY_START; BEGIN(SkipCxxComment); @@ -468,12 +485,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCurly>. { yyextra->CCodeBuffer += yytext; } -<SkipCurly>("//"{B}*)?"/*!" { +<SkipCurly>({CPPC}{B}*)?{CCS}"!" { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocBlock ); } -<SkipCurly>"/**"[*]+{BL} { +<SkipCurly>{CCS}"*"[*]+{BL} { bool javadocBanner = Config_getBool(JAVADOC_BANNER); yyextra->CCodeBuffer += yytext; if( javadocBanner ) @@ -486,17 +503,17 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN( Comment ) ; } } -<SkipCurly>("//"{B}*)?"/**"/[^/*] { +<SkipCurly>({CPPC}{B}*)?{CCS}"*"/{NCOMM} { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocBlock ); } -<SkipCurly>"//!" { +<SkipCurly>{CPPC}"!" { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocLine ); } -<SkipCurly>"///"/[^/] { +<SkipCurly>{CPPC}"/"/[^/] { yyextra->CCodeBuffer += yytext; yyextra->docBlockContext = YY_START; BEGIN( DocLine ); @@ -516,7 +533,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext; BEGIN( yyextra->lastStringContext ); } -<SkipString>"/*"|"*/"|"//" { +<SkipString>{CCS}|{CCE}|{CPPC} { yyextra->CCodeBuffer += yytext; } <SkipString>\n { @@ -528,15 +545,15 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCxxComment>.*"\\\n" { // line continuation yyextra->CCodeBuffer += yytext; } -<SkipCxxComment>.*/\n { +<SkipCxxComment>{ANYopt}/\n { yyextra->CCodeBuffer += yytext; BEGIN( yyextra->lastCContext ) ; } <Comment>{BN}+ { yyextra->CCodeBuffer += yytext ; } -<Comment>"/*" { yyextra->CCodeBuffer += yytext ; } -<Comment>"//" { yyextra->CCodeBuffer += yytext ; } +<Comment>{CCS} { yyextra->CCodeBuffer += yytext ; } +<Comment>{CPPC} { yyextra->CCodeBuffer += yytext ; } <Comment>{CMD}("code"|"verbatim") { yyextra->insideCode=TRUE; yyextra->CCodeBuffer += yytext ; @@ -546,12 +563,12 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->CCodeBuffer += yytext ; } <Comment>[^ \.\t\r\n\/\*]+ { yyextra->CCodeBuffer += yytext ; } -<Comment>"*/" { yyextra->CCodeBuffer += yytext ; +<Comment>{CCE} { yyextra->CCodeBuffer += yytext ; if (!yyextra->insideCode) BEGIN( yyextra->lastContext ) ; } <Comment>. { yyextra->CCodeBuffer += *yytext ; } -<SkipComment>"//"|"/*" { +<SkipComment>{CPPC}|{CCS} { yyextra->CCodeBuffer += yytext; } <SkipComment>[^\*\n]+ { @@ -560,7 +577,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipComment>\n { yyextra->CCodeBuffer += yytext; } -<SkipComment>{B}*"*/" { +<SkipComment>{B}*{CCE} { yyextra->CCodeBuffer += yytext; BEGIN( yyextra->lastCContext ); } @@ -588,41 +605,41 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) /* ---- Single line comments ------ */ -<DocLine>[^\n]*"\n"[ \t]*"//"[/!][<]? { // continuation of multiline C++-style comment +<DocLine>[^\n]*"\n"[ \t]*{CPPC}[/!][<]? { // continuation of multiline C++-style comment yyextra->CCodeBuffer += yytext; } -<DocLine>{B}*"///"[/]+{B}*/"\n" { // ignore marker line (see bug700345) +<DocLine>{B}*{CPPC}"/"[/]+{Bopt}/"\n" { // ignore marker line (see bug700345) yyextra->CCodeBuffer += yytext; BEGIN( yyextra->docBlockContext ); } -<DocLine>[^\n]*/"\n"{B}*"//"[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712 +<DocLine>{NONLopt}/"\n"{B}*{CPPC}[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712 yyextra->CCodeBuffer += yytext; BEGIN( yyextra->docBlockContext ); } -<DocLine>[^\n]*/"\n" { // whole line +<DocLine>{NONLopt}/"\n" { // whole line yyextra->CCodeBuffer += yytext; BEGIN( yyextra->docBlockContext ); } /* ---- Comments blocks ------ */ -<DocBlock>"*"*"*/" { // end of comment block +<DocBlock>"*"*{CCE} { // end of comment block yyextra->CCodeBuffer += yytext; BEGIN(yyextra->docBlockContext); } <DocBlock>^{B}*"*"+/[^/] { yyextra->CCodeBuffer += yytext; } -<DocBlock>^{B}*("//")?{B}*"*"+/[^//a-z_A-Z0-9*] { // start of a comment line +<DocBlock>^{B}*({CPPC})?{B}*"*"+/[^/a-z_A-Z0-9*] { // start of a comment line yyextra->CCodeBuffer += yytext; } -<DocBlock>^{B}*("//"){B}* { // strip embedded C++ comments if at the start of a line +<DocBlock>^{B}*({CPPC}){B}* { // strip embedded C++ comments if at the start of a line yyextra->CCodeBuffer += yytext; } -<DocBlock>"//" { // slashes in the middle of a comment block +<DocBlock>{CPPC} { // slashes in the middle of a comment block yyextra->CCodeBuffer += yytext; } -<DocBlock>"/*" { // start of a new comment in the +<DocBlock>{CCS} { // start of a new comment in the // middle of a comment block yyextra->CCodeBuffer += yytext; } @@ -777,10 +794,10 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(DocBlock); } } -<DocCopyBlock>[^\<@/*\]~\$\\\n]+ { // any character that is not special +<DocCopyBlock>[^\<@/\*\]~\$\\\n]+ { // any character that is not special yyextra->CCodeBuffer += yytext; } -<DocCopyBlock>"/*"|"*/"|"//" { +<DocCopyBlock>{CCS}|{CCE}|{CPPC} { if (yytext[1]=='*') { yyextra->nestedComment=TRUE; @@ -797,7 +814,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <DocCopyBlock>. { // any other character yyextra->CCodeBuffer += yytext; } -<SkipCurlyEndDoc>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { // desc is followed by another one +<SkipCurlyEndDoc>"}"{BN}*{DCOMM}"<" { // desc is followed by another one yyextra->docBlockContext = SkipCurlyEndDoc; yyextra->CCodeBuffer += yytext; if (yytext[yyleng-3]=='/') @@ -340,11 +340,23 @@ static Define * isDefined(yyscan_t yyscanner,const char *name); ID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* B [ \t] +Bopt {B}* BN [ \t\r\n] RAWBEGIN (u|U|L|u8)?R\"[^ \t\(\)\\]{0,16}"(" RAWEND ")"[^ \t\(\)\\]{0,16}\" CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + // optional characters after import +ENDIMPORTopt [^\\\n]* + // Optional white space +WSopt [ \t\r]* + %option noyywrap %x Start @@ -402,7 +414,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) outputArray(yyscanner,yytext,(int)yyleng); BEGIN(LexCopyLine); } -<Start>^{B}*/[^#] { +<Start>^{Bopt}/[^#] { outputArray(yyscanner,yytext,(int)yyleng); BEGIN(CopyLine); } @@ -650,7 +662,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <FindDefineArgs>{CHARLIT} { yyextra->defArgsStr+=yytext; } -<FindDefineArgs>"/*"[*]? { +<FindDefineArgs>{CCS}[*]? { yyextra->defArgsStr+=yytext; BEGIN(ArgCopyCComment); } @@ -677,7 +689,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <ArgCopyCComment>[^*\n]+ { yyextra->defArgsStr+=yytext; } -<ArgCopyCComment>"*/" { +<ArgCopyCComment>{CCE} { yyextra->defArgsStr+=yytext; BEGIN(FindDefineArgs); } @@ -699,7 +711,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(FindDefineArgs); } -<ReadString>"//"|"/*" { +<ReadString>{CPPC}|{CCS} { yyextra->defArgsStr+=yytext; } <ReadString>\\/\r?\n { // line continuation @@ -875,7 +887,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) } <DefinedExpr1,DefinedExpr2>. <SkipCPPBlock>^{B}*"#" { BEGIN(SkipCommand); } -<SkipCPPBlock>^{B}*/[^#] { BEGIN(SkipLine); } +<SkipCPPBlock>^{Bopt}/[^#] { BEGIN(SkipLine); } <SkipCPPBlock>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); } <SkipCPPBlock>. <SkipCommand>"if"(("n")?("def"))?/[ \t(!] { @@ -931,15 +943,15 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(SkipString); } <SkipLine>. -<SkipString>"//"/[^\n]* { +<SkipString>{CPPC}/[^\n]* { } -<SkipLine,SkipCommand,SkipCPPBlock>"//"[^\n]* { +<SkipLine,SkipCommand,SkipCPPBlock>{CPPC}[^\n]* { yyextra->lastCPPContext=YY_START; BEGIN(RemoveCPPComment); } -<SkipString>"/*"/[^\n]* { +<SkipString>{CCS}/[^\n]* { } -<SkipLine,SkipCommand,SkipCPPBlock>"/*"/[^\n]* { +<SkipLine,SkipCommand,SkipCPPBlock>{CCS}/[^\n]* { yyextra->lastCContext=YY_START; BEGIN(RemoveCComment); } @@ -954,7 +966,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(SkipLine); } <SkipString>. { } -<IncludeID>{ID}{B}*/"(" { +<IncludeID>{ID}{Bopt}/"(" { yyextra->nospaces=TRUE; yyextra->roundCount=0; yyextra->defArgsStr=yytext; @@ -978,7 +990,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(Start); } } -<EndImport>[^\\\n]*/\n { +<EndImport>{ENDIMPORTopt}/\n { BEGIN(Start); } <EndImport>\\[\r]?"\n" { @@ -1117,20 +1129,20 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->insideComment=FALSE; } */ -<DefineText>"/*"[!*]? { +<DefineText>{CCS}[!*]? { yyextra->defText+=yytext; yyextra->defLitText+=yytext; yyextra->lastCContext=YY_START; yyextra->commentCount=1; BEGIN(CopyCComment); } -<DefineText>"//"[!/]? { +<DefineText>{CPPC}[!/]? { outputArray(yyscanner,yytext,(int)yyleng); yyextra->lastCPPContext=YY_START; yyextra->defLitText+=' '; BEGIN(SkipCPPComment); } -<SkipCComment>[/]?"*/" { +<SkipCComment>[/]?{CCE} { if (yytext[0]=='/') outputChar(yyscanner,'/'); outputChar(yyscanner,'*');outputChar(yyscanner,'/'); if (--yyextra->commentCount<=0) @@ -1144,10 +1156,10 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(yyextra->lastCContext); } } -<SkipCComment>"//"("/")* { +<SkipCComment>{CPPC}("/")* { outputArray(yyscanner,yytext,(int)yyleng); } -<SkipCComment>"/*" { +<SkipCComment>{CCS} { outputChar(yyscanner,'/');outputChar(yyscanner,'*'); //yyextra->commentCount++; } @@ -1257,7 +1269,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(yyextra->condCtx); } } -<SkipCComment,SkipCPPComment>[\\@]"cond"[ \t\r]*/\n { // no guard +<SkipCComment,SkipCPPComment>[\\@]"cond"{WSopt}/\n { // no guard if (YY_START==SkipCComment) { yyextra->ccomment=TRUE; @@ -1275,8 +1287,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCond>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); } <SkipCond>. { } <SkipCond>[^\/\!*\\@\n]+ { } -<SkipCond>"//"[/!] { yyextra->ccomment=FALSE; } -<SkipCond>"/*"[*!] { yyextra->ccomment=TRUE; } +<SkipCond>{CPPC}[/!] { yyextra->ccomment=FALSE; } +<SkipCond>{CCS}[*!] { yyextra->ccomment=TRUE; } <SkipCond,SkipCComment,SkipCPPComment>[\\@][\\@]"endcond"/[^a-z_A-Z0-9\x80-\xFF] { if (!yyextra->skip) { @@ -1328,7 +1340,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(SkipCComment); } } -<SkipVerbatim>"*/"|"/*" { +<SkipVerbatim>{CCE}|{CCS} { outputArray(yyscanner,yytext,(int)yyleng); } <SkipCComment,SkipVerbatim>[^*\\@\x06~`\n\/]+ { @@ -1351,7 +1363,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->yyLineNr++; yyextra->yyMLines++; } -<CopyCComment>"*/" { +<CopyCComment>{CCE} { yyextra->defLitText+=yytext; yyextra->defText+=yytext; BEGIN(yyextra->lastCContext); @@ -1361,7 +1373,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->defLitText+=yytext; yyextra->defText+=' '; } -<RemoveCComment>"*/"{B}*"#" { // see bug 594021 for a usecase for this rule +<RemoveCComment>{CCE}{B}*"#" { // see bug 594021 for a usecase for this rule if (yyextra->lastCContext==SkipCPPBlock) { BEGIN(SkipCommand); @@ -1371,9 +1383,9 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) REJECT; } } -<RemoveCComment>"*/" { BEGIN(yyextra->lastCContext); } -<RemoveCComment>"//" -<RemoveCComment>"/*" +<RemoveCComment>{CCE} { BEGIN(yyextra->lastCContext); } +<RemoveCComment>{CPPC} +<RemoveCComment>{CCS} <RemoveCComment>[^*\x06\n]+ <RemoveCComment>\n { yyextra->yyLineNr++; outputChar(yyscanner,'\n'); } <RemoveCComment>. @@ -1384,10 +1396,10 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) unput(*yytext); BEGIN(yyextra->lastCPPContext); } -<SkipCPPComment>"/*" { +<SkipCPPComment>{CCS} { outputChar(yyscanner,'/');outputChar(yyscanner,'*'); } -<SkipCPPComment>"//" { +<SkipCPPComment>{CPPC} { outputChar(yyscanner,'/');outputChar(yyscanner,'/'); } <SkipCPPComment>[^\x06\@\\\n]+ { @@ -1396,8 +1408,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) <SkipCPPComment>. { outputChar(yyscanner,*yytext); } -<RemoveCPPComment>"/*" -<RemoveCPPComment>"//" +<RemoveCPPComment>{CCS} +<RemoveCPPComment>{CPPC} <RemoveCPPComment>[^\x06\n]+ <RemoveCPPComment>. <DefineText>"#" { @@ -1510,8 +1522,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(SkipSingleQuote); } } -<SkipDoubleQuote>"//"[/]? { yyextra->defText += yytext; yyextra->defLitText+=yytext; } -<SkipDoubleQuote>"/*"[*]? { yyextra->defText += yytext; yyextra->defLitText+=yytext; } +<SkipDoubleQuote>{CPPC}[/]? { yyextra->defText += yytext; yyextra->defLitText+=yytext; } +<SkipDoubleQuote>{CCS}[*]? { yyextra->defText += yytext; yyextra->defLitText+=yytext; } <SkipDoubleQuote>\" { yyextra->defText += *yytext; yyextra->defLitText+=yytext; BEGIN(DefineText); @@ -1591,8 +1603,8 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) yyextra->localDefines.clear(); } } -<*>"/*"/"*/" | -<*>"/*"[*!]? { +<*>{CCS}/{CCE} | +<*>{CCS}[*!]? { if (YY_START==SkipVerbatim || YY_START==SkipCond) { REJECT; @@ -1614,7 +1626,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'")) BEGIN(SkipCComment); } } -<*>"//"[/!]? { +<*>{CPPC}[/!]? { if (YY_START==SkipVerbatim || YY_START==SkipCond || getLanguageFromFileName(yyextra->yyFileName)==SrcLangExt_Fortran) { REJECT; diff --git a/src/pycode.l b/src/pycode.l index 1ab724b..f63e885 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -247,7 +247,7 @@ KEYWORD_ARGUMENTS {KEYWORD_ITEM}(","{KEYWORD_ITEM})* KEYWORD_ITEM {IDENTIFIER}"="{EXPRESSION} POWER {PRIMARY}("**"{U_EXPR})? U_EXPR ({POWER}|"-"{U_EXPR}|"+"{U_EXPR}|"\~"{U_EXPR}) -M_EXPR ({U_EXPR}|{M_EXPR}"*"{U_EXPR}|{M_EXPR}"//"{U_EXPR}|{M_EXPR}"/"{U_EXPR}|{M_EXPR}"\%"{U_EXPR}) +M_EXPR ({U_EXPR}|{M_EXPR}"*"{U_EXPR}|{M_EXPR}"/""/"{U_EXPR}|{M_EXPR}"/"{U_EXPR}|{M_EXPR}"\%"{U_EXPR}) A_EXPR ({M_EXPR}|{A_EXPR}"+"{M_EXPR}|{A_EXPR}"-"{M_EXPR} SHIFT_EXPR ({A_EXPR}|{SHIFT_EXPR}("<<"|">>"){A_EXPR}) AND_EXPR ({SHIFT_EXPR}|{AND_EXPR}"\;SPMamp;"{SHIFT_EXPR} diff --git a/src/scanner.l b/src/scanner.l index 7edfc9b..4ff57b7 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -234,8 +234,10 @@ static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size); /* start command character */ CMD ("\\"|"@") BN [ \t\n\r] +BNopt {BN}* BL [ \t\r]*"\n" B [ \t] +Bopt {B}* ID "$"?[a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF]* SCOPENAME "$"?(({ID}?{BN}*"::"{BN}*)*)(((~|!){BN}*)?{ID}) TSCOPE {ID}("<"[a-z_A-Z0-9 \t\*\&,:]*">")? @@ -255,6 +257,22 @@ LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"|"<=>" BITOP "&"|"|"|"^"|"<<"|">>"|"~" OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) + /* no comment start / end signs inside square brackets */ +NCOMM [^/\*] + // C start comment +CCS "/\*" + // C end comment +CCE "*\/" + // Cpp comment +CPPC "/\/" + // doxygen start comment +DCOMM ("/\*!"|"/\**"|"/\/!"|"/\/\/") + + // Optional any character +ANYopt .* + // Optional all but newline +NONLopt [^\n]* + %option noyywrap /* language parsing states */ @@ -1124,7 +1142,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } */ <FindMembers>{B}*"typename"{BN}+ { lineCount(yyscanner); } -<FindMembers>{B}*"namespace"{BN}*/[^a-z_A-Z0-9] { +<FindMembers>{B}*"namespace"{BNopt}/[^a-z_A-Z0-9] { yyextra->isTypedef=FALSE; yyextra->current->section = Entry::NAMESPACE_SEC; yyextra->current->type = "namespace" ; @@ -1598,12 +1616,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) if (yytext[yyleng-1]=='{') unput('{'); BEGIN( CompoundName ) ; } -<Operator>"("{BN}*")"({BN}*"<"[^>]*">"){BN}*/"(" { // A::operator()<int>(int arg) +<Operator>"("{BN}*")"({BN}*"<"[^>]*">"){BNopt}/"(" { // A::operator()<int>(int arg) lineCount(yyscanner); yyextra->current->name += "()"; BEGIN( FindMembers ); } -<Operator>"("{BN}*")"{BN}*/"(" { +<Operator>"("{BN}*")"{BNopt}/"(" { lineCount(yyscanner); yyextra->current->name += yytext ; yyextra->current->name = yyextra->current->name.simplifyWhiteSpace(); @@ -1770,7 +1788,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->previous->spec |= Entry::Alias; BEGIN(FindMembers); } -<UsingAlias>";"{BN}*("/**"|"//!"|"/*!"|"///")"<" { +<UsingAlias>";"{BN}*{DCOMM}"<" { yyextra->docBlockContext = UsingAliasEnd; yyextra->docBlockInBody = FALSE; yyextra->docBlockAutoBrief = ( yytext[yyleng-2]=='*' && Config_getBool(JAVADOC_AUTOBRIEF) ) || @@ -1823,7 +1841,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) addType(yyscanner); yyextra->current->name=n.left(n.length()-2); } -<FindMembers>{SCOPENAME}{BN}*/"<" { // Note: this could be a return type! +<FindMembers>{SCOPENAME}{BNopt}/"<" { // Note: this could be a return type! yyextra->roundCount=0; yyextra->sharpCount=0; lineCount(yyscanner); @@ -1837,7 +1855,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else BEGIN( EndTemplate ); } -<FindMemberName>{SCOPENAME}{BN}*/"<" { +<FindMemberName>{SCOPENAME}{BNopt}/"<" { yyextra->sharpCount=0; yyextra->roundCount=0; lineCount(yyscanner); @@ -1910,7 +1928,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( ReadFuncArgType ) ; } } -<EndTemplate>">"{BN}*/"("({BN}*{ID}{BN}*"::")*({BN}*"*"{BN}*)+ { // function pointer returning a template instance +<EndTemplate>">"{BNopt}/"("({BN}*{ID}{BN}*"::")*({BN}*"*"{BN}*)+ { // function pointer returning a template instance lineCount(yyscanner); yyextra->current->name+='>'; if (yyextra->roundCount==0) @@ -1918,7 +1936,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN(FindMembers); } } -<EndTemplate>">"{BN}*/"::" { +<EndTemplate>">"{BNopt}/"::" { lineCount(yyscanner); yyextra->current->name+='>'; // *yyextra->currentTemplateSpec+='>'; @@ -2436,7 +2454,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->current->name += yytext ; addType(yyscanner); } -<FindMembers,MemberSpec,Function,NextSemi,EnumBaseType,BitFields,ReadInitializer,ReadInitializerPtr,OldStyleArgs,DefinePHPEnd>";"{BN}*("/**"|"//!"|"/*!"|"///")"<" { +<FindMembers,MemberSpec,Function,NextSemi,EnumBaseType,BitFields,ReadInitializer,ReadInitializerPtr,OldStyleArgs,DefinePHPEnd>";"{BN}*{DCOMM}"<" { if (yyextra->current->bodyLine==-1) { yyextra->current->bodyLine=yyextra->yyLineNr; @@ -2471,7 +2489,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( DocBlock ); } } -<MemberSpec,FindFields,FindMembers,NextSemi,EnumBaseType,BitFields,ReadInitializer,ReadInitializerPtr,OldStyleArgs>","{BN}*("/**"|"//!"|"/*!"|"///")"<" { +<MemberSpec,FindFields,FindMembers,NextSemi,EnumBaseType,BitFields,ReadInitializer,ReadInitializerPtr,OldStyleArgs>","{BN}*{DCOMM}"<" { yyextra->docBlockContext = YY_START; yyextra->docBlockInBody = FALSE; yyextra->docBlockAutoBrief = ( yytext[yyleng-2]=='*' && Config_getBool(JAVADOC_AUTOBRIEF) ) || @@ -2500,7 +2518,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( DocBlock ); } } -<DefineEnd,FindFields,FindFieldArg,ReadInitializer,ReadInitializerPtr,OldStyleArgs>{BN}*("/**"|"//!"|"/*!"|"///")"<" { +<DefineEnd,FindFields,FindFieldArg,ReadInitializer,ReadInitializerPtr,OldStyleArgs>{BN}*{DCOMM}"<" { if (yyextra->current->bodyLine==-1) { yyextra->current->bodyLine=yyextra->yyLineNr; @@ -2528,7 +2546,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } -<FindMembers,FindFields>("//"([!/]){B}*{CMD}"{")|("/*"([!*]){B}*{CMD}"{") { +<FindMembers,FindFields>({CPPC}([!/]){B}*{CMD}"{")|({CCS}([!*]){B}*{CMD}"{") { //handleGroupStartCommand(yyextra->current->name); if (yyextra->previous && yyextra->previous->section==Entry::GROUPDOC_SEC) { @@ -2580,7 +2598,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } } -<FindMembers,FindFields,ReadInitializer,ReadInitializerPtr>"//"([!/]){B}*{CMD}"}".*|"/*"([!*]){B}*{CMD}"}"[^*]*"*/" { +<FindMembers,FindFields,ReadInitializer,ReadInitializerPtr>{CPPC}([!/]){B}*{CMD}"}".*|{CCS}([!*]){B}*{CMD}"}"[^*]*{CCE} { bool insideEnum = YY_START==FindFields || ((YY_START==ReadInitializer || YY_START==ReadInitializerPtr) && yyextra->lastInitializerContext==FindFields); // see bug746226 yyextra->commentScanner.close(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr,insideEnum); lineCount(yyscanner); @@ -2838,7 +2856,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) *yyextra->pCopyQuotedString+=*yytext; BEGIN( yyextra->lastStringContext ); } -<CopyString,CopyPHPString>"/*"|"*/"|"//" { +<CopyString,CopyPHPString>{CCS}|{CCE}|{CPPC} { *yyextra->pCopyQuotedString+=yytext; } <CopyString,CopyPHPString>\n { @@ -2865,7 +2883,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) *yyextra->pCopyQuotedGString += yytext; BEGIN( yyextra->lastStringContext ); } -<CopyGString,CopyPHPGString>"/*"|"*/"|"//" { +<CopyGString,CopyPHPGString>{CCS}|{CCE}|{CPPC} { *yyextra->pCopyQuotedGString+=yytext; } <CopyGString,CopyPHPGString>\n { @@ -3386,20 +3404,20 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( IDLProp ); } <IDLPropName>{BN}*"("{BN}*{ID}{BN}*")"{BN}* { - if (yyextra->odlProp) - { - yyextra->idlProp += yytext; - } + if (yyextra->odlProp) + { + yyextra->idlProp += yytext; + } } -<IDLPropName>{ID}{BN}*/";" { - if (yyextra->odlProp) - { - yyextra->current->name = yytext; - yyextra->idlProp = yyextra->idlProp.stripWhiteSpace(); - yyextra->odlProp = false; +<IDLPropName>{ID}{BNopt}/";" { + if (yyextra->odlProp) + { + yyextra->current->name = yytext; + yyextra->idlProp = yyextra->idlProp.stripWhiteSpace(); + yyextra->odlProp = false; - BEGIN( IDLProp ); - } + BEGIN( IDLProp ); + } } <IDLProp>{BN}*"["[^\]]*"]"{BN}* { // attribute of a parameter yyextra->idlAttr = yytext; @@ -3577,7 +3595,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <FindFieldArg>"," { unput(*yytext); BEGIN(FindFields); } */ <ReadBody,ReadNSBody,ReadBodyIntf>[^\r\n\#{}"@'/<]* { yyextra->current->program += yytext ; } -<ReadBody,ReadNSBody,ReadBodyIntf>"//".* { yyextra->current->program += yytext ; } +<ReadBody,ReadNSBody,ReadBodyIntf>{CPPC}.* { yyextra->current->program += yytext ; } <ReadBody,ReadNSBody,ReadBodyIntf>"#".* { if (!yyextra->insidePHP) REJECT; // append PHP comment. @@ -3605,11 +3623,11 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->lastStringContext=YY_START; BEGIN( CopyGString ); } -<ReadBody,ReadNSBody,ReadBodyIntf>"/*"{B}* { yyextra->current->program += yytext ; +<ReadBody,ReadNSBody,ReadBodyIntf>{CCS}{B}* { yyextra->current->program += yytext ; yyextra->lastContext = YY_START ; BEGIN( Comment ) ; } -<ReadBody,ReadNSBody,ReadBodyIntf>"/*"{BL} { yyextra->current->program += yytext ; +<ReadBody,ReadNSBody,ReadBodyIntf>{CCS}{BL} { yyextra->current->program += yytext ; ++yyextra->yyLineNr ; yyextra->lastContext = YY_START ; BEGIN( Comment ) ; @@ -4041,7 +4059,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <FuncPtr>. { //printf("error: FuncPtr '%c' unexpected at line %d of %s\n",*yytext,yyextra->yyLineNr,yyextra->yyFileName); } -<FuncPtrOperator>"("{BN}*")"{BN}*/"(" { +<FuncPtrOperator>"("{BN}*")"{BNopt}/"(" { yyextra->current->name += yytext; yyextra->current->name = yyextra->current->name.simplifyWhiteSpace(); lineCount(yyscanner); @@ -4057,17 +4075,17 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <FuncPtrOperator>. { yyextra->current->name += *yytext; } -<EndFuncPtr>")"{BN}*/";" { // a variable with extra braces +<EndFuncPtr>")"{BNopt}/";" { // a variable with extra braces lineCount(yyscanner); yyextra->current->type+=yyextra->funcPtrType.data()+1; BEGIN(FindMembers); } -<EndFuncPtr>")"{BN}*/"(" { // a function pointer +<EndFuncPtr>")"{BNopt}/"(" { // a function pointer lineCount(yyscanner); yyextra->current->type+=yyextra->funcPtrType+")"; BEGIN(FindMembers); } -<EndFuncPtr>")"{BN}*/"[" { // an array of variables +<EndFuncPtr>")"{BNopt}/"[" { // an array of variables lineCount(yyscanner); yyextra->current->type+=yyextra->funcPtrType.data(); yyextra->current->args += ")"; @@ -4109,12 +4127,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->current->type+=yyextra->funcPtrType+")("; BEGIN(FuncFuncType); } -<FuncFuncEnd>")"{BN}*/[;{] { +<FuncFuncEnd>")"{BNopt}/[;{] { lineCount(yyscanner); yyextra->current->type+=yyextra->funcPtrType.data()+1; BEGIN(Function); } -<FuncFuncEnd>")"{BN}*/"[" { // function returning a pointer to an array +<FuncFuncEnd>")"{BNopt}/"[" { // function returning a pointer to an array lineCount(yyscanner); yyextra->current->type+=yyextra->funcPtrType; yyextra->current->args+=")"; @@ -4248,7 +4266,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( yyextra->currentArgumentContext ); } /* a special comment */ -<ReadFuncArgType,ReadTempArgs>("/*"[*!]|"//"[/!])("<"?) { +<ReadFuncArgType,ReadTempArgs>({CCS}[*!]|{CPPC}[/!])("<"?) { if (yyextra->currentArgumentContext==DefineEnd) { // for defines we interpret a comment @@ -4275,12 +4293,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } /* a non-special comment */ -<ReadFuncArgType,ReadTempArgs>"/**/" { /* empty comment */ } -<ReadFuncArgType,ReadTempArgs>"/*" { +<ReadFuncArgType,ReadTempArgs>{CCS}{CCE} { /* empty comment */ } +<ReadFuncArgType,ReadTempArgs>{CCS} { yyextra->lastCContext = YY_START; BEGIN( SkipComment ); } -<ReadFuncArgType,ReadTempArgs>"//" { +<ReadFuncArgType,ReadTempArgs>{CPPC} { yyextra->lastCContext = YY_START; BEGIN( SkipCxxComment ); } @@ -4298,7 +4316,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } */ /* ')' followed by a special comment */ -<ReadFuncArgType>")"{BN}*("/*"[*!]|"//"[/!])"<" { +<ReadFuncArgType>")"{BN}*({CCS}[*!]|{CPPC}[/!])"<" { lineCount(yyscanner); if (yyextra->currentArgumentContext==DefineEnd) { @@ -4331,7 +4349,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <CopyArgComment>^{B}*"*"+/{BN}+ <CopyArgComment>[^\n\\\@\*]+ { yyextra->fullArgString+=yytext; } -<CopyArgComment>"*/" { yyextra->fullArgString+=yytext; +<CopyArgComment>{CCE} { yyextra->fullArgString+=yytext; if (yyextra->lastCopyArgChar!=0) unput(yyextra->lastCopyArgChar); BEGIN( yyextra->lastCommentInArgContext ); @@ -4984,7 +5002,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) //addToBody(yytext); ++yyextra->curlyCount ; } -<SkipCurly>"}"/{BN}*("/*!"|"/**"|"//!"|"///")"<!--" | /* see bug710917 */ +<SkipCurly>"}"/{BN}*{DCOMM}"<!--" | /* see bug710917 */) <SkipCurly>"}" { //addToBody(yytext); if( yyextra->curlyCount ) @@ -5002,7 +5020,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( yyextra->lastCurlyContext ) ; } } -<SkipCurly>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { +<SkipCurly>"}"{BN}*{DCOMM}"<" { lineCount(yyscanner); if ( yyextra->curlyCount ) { @@ -5033,7 +5051,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } } -<SkipCurlyEndDoc>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { // desc is followed by another one +<SkipCurlyEndDoc>"}"{BN}*{DCOMM}"<" { // desc is followed by another one yyextra->docBlockContext = SkipCurlyEndDoc; yyextra->docBlockInBody = FALSE; yyextra->docBlockAutoBrief = ( yytext[yyleng-2]=='*' && Config_getBool(JAVADOC_AUTOBRIEF) ) || @@ -5110,12 +5128,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) //addToBody(yytext); lineCount(yyscanner); } -<SkipInits,SkipC11Inits,SkipCurly,SkipCurlyCpp,SkipC11Attribute>"/*" { +<SkipInits,SkipC11Inits,SkipCurly,SkipCurlyCpp,SkipC11Attribute>{CCS} { //addToBody(yytext); yyextra->lastCContext = YY_START; BEGIN(SkipComment); } -<SkipInits,SkipC11Inits,SkipCurly,SkipCurlyCpp,SkipC11Attribute>"//" { +<SkipInits,SkipC11Inits,SkipCurly,SkipCurlyCpp,SkipC11Attribute>{CPPC} { //addToBody(yytext); yyextra->lastCContext = YY_START; BEGIN(SkipCxxComment); @@ -5168,7 +5186,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <SkipPHPString>\' { BEGIN( yyextra->lastStringContext ); } -<SkipString,SkipPHPString>"/*"|"*/"|"//" { } +<SkipString,SkipPHPString>{CCS}|{CCE}|{CPPC} { } <SkipString,SkipPHPString>\n { lineCount(yyscanner); } @@ -5393,7 +5411,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) lineCount(yyscanner); BEGIN( ClassVar ); } -<ClassVar>{SCOPENAME}{BN}*/"(" { +<ClassVar>{SCOPENAME}{BNopt}/"(" { if (yyextra->insideIDL && qstrncmp(yytext,"switch",6)==0 && !isId(yytext[6])) { // Corba IDL style union @@ -5507,8 +5525,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( FindMembers ); } } -<CSConstraintType,CSConstraintName>"/**/" { /* empty comment */ } -<CSConstraintType,CSConstraintName>("/*"[*!]|"//"[/!])("<"?) { // special comment +<CSConstraintType,CSConstraintName>{CCS}{CCE} { /* empty comment */ } +<CSConstraintType,CSConstraintName>({CCS}[*!]|{CPPC}[/!])("<"?) { // special comment yyextra->fullArgString.resize(0); yyextra->lastCopyArgChar='#'; // end marker yyextra->lastCommentInArgContext=YY_START; @@ -5629,7 +5647,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } BEGIN( FindMembers ); } -<Bases,ClassVar>"///"/[^/] { +<Bases,ClassVar>{CPPC}"/"/[^/] { if (!yyextra->insideObjC) { REJECT; @@ -5645,9 +5663,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( ReadBodyIntf ); } } -<Bases,ClassVar>("//"{B}*)?"/**"/[^/*] | -<Bases,ClassVar>("//"{B}*)?"/*!" | -<Bases,ClassVar>"//!" | +<Bases,ClassVar>({CPPC}{B}*)?{CCS}"*"/{NCOMM} | +<Bases,ClassVar>({CPPC}{B}*)?{CCS}"!" | +<Bases,ClassVar>{CPPC}"!" | <Bases,ClassVar>[\-+]{BN}* { if (!yyextra->insideObjC) { @@ -5951,8 +5969,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <Comment>{BN}+ { yyextra->current->program += yytext ; lineCount(yyscanner) ; } -<Comment>"/*" { yyextra->current->program += yytext ; } -<Comment>"//" { yyextra->current->program += yytext ; } +<Comment>{CCS} { yyextra->current->program += yytext ; } +<Comment>{CPPC} { yyextra->current->program += yytext ; } <Comment>{CMD}("code"|"verbatim") { yyextra->insideCode=TRUE; yyextra->current->program += yytext ; @@ -5962,12 +5980,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->current->program += yytext ; } <Comment>[^ \.\t\r\n\/\*]+ { yyextra->current->program += yytext ; } -<Comment>"*/" { yyextra->current->program += yytext ; +<Comment>{CCE} { yyextra->current->program += yytext ; if (!yyextra->insideCode) BEGIN( yyextra->lastContext ) ; } <Comment>. { yyextra->current->program += *yytext ; } -<FindMembers,FindFields,MemberSpec,FuncQual,SkipCurly,Operator,ClassVar,SkipInits,SkipC11Inits,SkipC11Attribute,Bases,OldStyleArgs>("//"{B}*)?"/*!" { +<FindMembers,FindFields,MemberSpec,FuncQual,SkipCurly,Operator,ClassVar,SkipInits,SkipC11Inits,SkipC11Attribute,Bases,OldStyleArgs>({CPPC}{B}*)?{CCS}"!" { //printf("Start doc block at %d\n",yyextra->yyLineNr); if (!yyextra->current->doc.isEmpty()) { @@ -6000,7 +6018,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) startCommentBlock(yyscanner,FALSE); BEGIN( DocBlock ); } -<FindMembers,FindFields,MemberSpec,FuncQual,SkipCurly,Operator,ClassVar,SkipInits,Bases,OldStyleArgs>"/**"[*]+{BL} { +<FindMembers,FindFields,MemberSpec,FuncQual,SkipCurly,Operator,ClassVar,SkipInits,Bases,OldStyleArgs>{CCS}"*"[*]+{BL} { bool javadocBanner = Config_getBool(JAVADOC_BANNER); lineCount(yyscanner); @@ -6039,7 +6057,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN( Comment ) ; } } -<FindMembers,FindFields,MemberSpec,FuncQual,SkipCurly,Operator,ClassVar,SkipInits,Bases,OldStyleArgs>("//"{B}*)?"/**"/[^/*] { +<FindMembers,FindFields,MemberSpec,FuncQual,SkipCurly,Operator,ClassVar,SkipInits,Bases,OldStyleArgs>({CPPC}{B}*)?{CCS}"*"/{NCOMM} { yyextra->lastDocContext = YY_START; //printf("Found comment block at %s:%d\n",yyextra->yyFileName,yyextra->yyLineNr); @@ -6066,7 +6084,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) startCommentBlock(yyscanner,FALSE); BEGIN( DocBlock ); } -<FindMembers,FindFields,MemberSpec,SkipCurly,FuncQual,Operator,ClassVar,Bases,OldStyleArgs>"//!" { +<FindMembers,FindFields,MemberSpec,SkipCurly,FuncQual,Operator,ClassVar,Bases,OldStyleArgs>{CPPC}"!" { yyextra->lastDocContext = YY_START; if (yyextra->current_root->section & Entry::SCOPE_MASK) { @@ -6083,7 +6101,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) startCommentBlock(yyscanner,yyextra->current->brief.isEmpty()); BEGIN( DocLine ); } -<FindMembers,FindFields,MemberSpec,SkipCurly,FuncQual,Operator,ClassVar,Bases,OldStyleArgs>"///"/[^/] { +<FindMembers,FindFields,MemberSpec,SkipCurly,FuncQual,Operator,ClassVar,Bases,OldStyleArgs>{CPPC}"/"/[^/] { yyextra->lastDocContext = YY_START; if (yyextra->current_root->section & Entry::SCOPE_MASK) { @@ -6209,8 +6227,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) <CSAccessorDecl>"." {} <CSAccessorDecl>\n { lineCount(yyscanner); } <CSString>"\"" { BEGIN(CSAccessorDecl);} -<CSString>"//" {} // Otherwise the rule <*>"//" will kick in -<CSString>"/*" {} // Otherwise the rule <*>"/*" will kick in +<CSString>{CPPC} {} // Otherwise the rule <*>"//" will kick in +<CSString>{CCS} {} // Otherwise the rule <*>"/*" will kick in <CSString>\n { lineCount(yyscanner); } <CSString>"." {} @@ -6279,22 +6297,22 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) /**********************************************************************************/ /* ---- Single line comments ------ */ -<DocLine>[^\n]*"\n"[ \t]*"//"[/!][<]? { // continuation of multiline C++-style comment +<DocLine>[^\n]*"\n"[ \t]*{CPPC}[/!][<]? { // continuation of multiline C++-style comment yyextra->docBlock+=yytext; int markerLen = yytext[yyleng-1]=='<' ? 4 : 3; yyextra->docBlock.resize(yyextra->docBlock.length() - markerLen); lineCount(yyscanner); } -<DocLine>{B}*"///"[/]+{B}*/"\n" { // ignore marker line (see bug700345) +<DocLine>{B}*{CPPC}"/"[/]+{Bopt}/"\n" { // ignore marker line (see bug700345) handleCommentBlock(yyscanner,yyextra->docBlock.data(),yyextra->current->brief.isEmpty()); BEGIN( yyextra->docBlockContext ); } -<DocLine>[^\n]*/"\n"{B}*"//"[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712 +<DocLine>{NONLopt}/"\n"{B}*{CPPC}[!/]{B}*{CMD}"}" { // next line is an end group marker, see bug 752712 yyextra->docBlock+=yytext; handleCommentBlock(yyscanner,yyextra->docBlock.data(),yyextra->current->brief.isEmpty()); BEGIN( yyextra->docBlockContext ); } -<DocLine>[^\n]*/"\n" { // whole line +<DocLine>{NONLopt}/"\n" { // whole line yyextra->docBlock+=yytext; handleCommentBlock(yyscanner,yyextra->docBlock.data(),yyextra->current->brief.isEmpty()); BEGIN( yyextra->docBlockContext ); @@ -6302,7 +6320,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) /* ---- Comments blocks ------ */ -<DocBlock>"*"*"*/" { // end of comment block +<DocBlock>"*"*{CCE} { // end of comment block handleCommentBlock(yyscanner,yyextra->docBlock.data(),FALSE); BEGIN(yyextra->docBlockContext); } @@ -6312,17 +6330,17 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) indent.fill(' ',computeIndent(yytext,yyextra->column)); yyextra->docBlock+=indent; } -<DocBlock>^{B}*("//")?{B}*"*"+/[^//a-z_A-Z0-9*] { // start of a comment line +<DocBlock>^{B}*({CPPC})?{B}*"*"+/[^/a-z_A-Z0-9*] { // start of a comment line QCString indent; indent.fill(' ',computeIndent(yytext,yyextra->column)); yyextra->docBlock+=indent; } -<DocBlock>^{B}*("//"){B}* { // strip embedded C++ comments if at the start of a line +<DocBlock>^{B}*({CPPC}){B}* { // strip embedded C++ comments if at the start of a line } -<DocBlock>"//" { // slashes in the middle of a comment block +<DocBlock>{CPPC} { // slashes in the middle of a comment block yyextra->docBlock+=yytext; } -<DocBlock>"/*" { // start of a new comment in the +<DocBlock>{CCS} { // start of a new comment in the // middle of a comment block yyextra->docBlock+=yytext; } @@ -6498,10 +6516,10 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN(DocBlock); } } -<DocCopyBlock>[^\<@/*\]~\$\\\n]+ { // any character that is not special +<DocCopyBlock>[^\<@/\*\]~\$\\\n]+ { // any character that is not special yyextra->docBlock+=yytext; } -<DocCopyBlock>"/*"|"*/"|"//" { +<DocCopyBlock>{CCS}|{CCE}|{CPPC} { if (yytext[1]=='*') { yyextra->nestedComment=TRUE; @@ -6618,7 +6636,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) lineCount(yyscanner); } } -<SkipCxxComment>.*/\n { +<SkipCxxComment>{ANYopt}/\n { BEGIN( yyextra->lastCContext ) ; } <SkipComment>[^\*\n]+ @@ -6676,12 +6694,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } <*>. -<SkipComment>"//"|"/*" -<*>"/*" { yyextra->lastCContext = YY_START ; +<SkipComment>{CPPC}|{CCS} +<*>{CCS} { yyextra->lastCContext = YY_START ; BEGIN( SkipComment ) ; } -<SkipComment>{B}*"*/" { BEGIN( yyextra->lastCContext ) ; } -<*>"//" { +<SkipComment>{B}*{CCE} { BEGIN( yyextra->lastCContext ) ; } +<*>{CPPC} { yyextra->lastCContext = YY_START ; BEGIN( SkipCxxComment ) ; } diff --git a/src/sqlcode.l b/src/sqlcode.l index c5af17f..b3a71d9 100644 --- a/src/sqlcode.l +++ b/src/sqlcode.l @@ -119,7 +119,7 @@ variable @{idchar}+ simplecomment --.* commentopen "/\*" -commentclose "\*/" +commentclose "\*\/" %x COMMENT |