From 789625caed4097a075819b7d7299ab1a808fcf08 Mon Sep 17 00:00:00 2001 From: albert-github Date: Thu, 18 Feb 2021 15:52:08 +0100 Subject: 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 --- libxml/xml.h | 2 +- src/code.l | 79 +++++++++++++--------- src/commentcnv.l | 85 +++++++++++++++--------- src/commentscan.l | 29 ++++++--- src/declinfo.l | 5 +- src/defargs.l | 18 ++++-- src/doctokenizer.l | 7 +- src/fortrancode.l | 7 +- src/fortranscanner.l | 3 +- src/lexcode.l | 85 ++++++++++++++---------- src/lexscanner.l | 85 ++++++++++++++---------- src/pre.l | 80 +++++++++++++---------- src/pycode.l | 2 +- src/scanner.l | 180 ++++++++++++++++++++++++++++----------------------- src/sqlcode.l | 2 +- 15 files changed, 398 insertions(+), 271 deletions(-) mode change 100644 => 100755 src/fortranscanner.l diff --git a/libxml/xml.h b/libxml/xml.h index 0708d34..9670837 100644 --- a/libxml/xml.h +++ b/libxml/xml.h @@ -76,7 +76,7 @@ class XMLParser : public XMLLocator /*! Parses a file gives the contents of the file as a string. * @param fileName the name of the file, used for error reporting. * @param inputString the contents of the file as a zero terminated UTF-8 string. - * @param debugEnable indicates if debugging via -d lex is enabled or not. + * @param debugEnabled indicates if debugging via -d lex is enabled or not. */ void parse(const char *fileName,const char *inputString,bool debugEnabled); diff --git a/src/code.l b/src/code.l index 083660b..47ff5ee 100644 --- a/src/code.l +++ b/src/code.l @@ -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} \\[\r]?\n { codifyLines(yyscanner,yytext); } -"//"/[^/!] { +{CPPC}/[^/!] { REJECT; } "{" { @@ -744,7 +759,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN( Bases ); } [ \t]*";" | -^{B}*/"@"{ID} | // Objective-C interface +^{Bopt}/"@"{ID} | // Objective-C interface {B}*"{"{B}* { yyextra->theVarContext.pushScope(); yyextra->code->codify(yytext); @@ -864,7 +879,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} } -{SCOPEPREFIX}?"operator"{B}*"()"{B}*/"(" { +{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; } -{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>\(]*">"("::"{ID})*/{B}* { // A *pt; +{SCOPENAME}{B}*"<"[^\n\/\-\.\{\"\>\(]*">"{ENDIDopt}/{B}* { // A *pt; if (isCastKeyword(yytext) && YY_START==Body) { REJECT; @@ -1175,7 +1190,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} [^\'\\\r\n]* { yyextra->code->codify(yytext); } -"//"|"/*" { +{CPPC}|{CCS} { yyextra->code->codify(yytext); } @?\" { @@ -1420,21 +1435,21 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} } //printf("close\n"); } -"//".* { +{CPPC}.* { yyextra->currentCtx->format+=escapeComment(yyscanner,yytext); } -"/*" { +{CCS} { yyextra->lastObjCCallContext = YY_START; yyextra->currentCtx->comment=yytext; BEGIN(ObjCCallComment); } -"*/" { +{CCE} { yyextra->currentCtx->comment+=yytext; yyextra->currentCtx->format+=escapeComment(yyscanner,yyextra->currentCtx->comment); BEGIN(yyextra->lastObjCCallContext); } [^*\n]+ { yyextra->currentCtx->comment+=yytext; } -"//"|"/*" { yyextra->currentCtx->comment+=yytext; } +{CPPC}|{CCS} { yyextra->currentCtx->comment+=yytext; } \n { yyextra->currentCtx->comment+=*yytext; } . { yyextra->currentCtx->comment+=*yytext; } {ID} { @@ -1675,7 +1690,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN( SkipInits ); } } -("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"sealed"|"override"))*/{BN}*(";"|"="|"throw"{BN}*"(") { +{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 ); } -"/*"("!"?)"*/" { +{CCS}("!"?){CCE} { yyextra->code->codify(yytext); endFontClass(yyscanner); BEGIN( yyextra->lastCContext ) ; } -"//"|"/*" { +{CPPC}|{CCS} { yyextra->code->codify(yytext); } -[^*/\n]+ { +[^*\/\n]+ { yyextra->code->codify(yytext); } -[ \t]*"*/" { +[ \t]*{CCE} { yyextra->code->codify(yytext); endFontClass(yyscanner); if (yyextra->lastCContext==SkipCPP) @@ -1890,10 +1905,10 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} . { yyextra->code->codify(yytext); } -"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)?{B}*"/*"[*!]/[^/*] { +{CCE}{B}*\n({B}*\n)*({B}*(({CPPC}"@"[{}])|({CCS}"@"[{}]{CCE})){B}*\n)?{B}*{CCS}[*!]/{NCOMM} { yyextra->yyLineNr+=QCString(yytext).contains('\n'); } -"*/"{B}*\n({B}*\n)*({B}*(("//@"[{}])|("/*@"[{}]"*/")){B}*\n)? { +{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); } } -"*/" { +{CCE} { BEGIN(yyextra->lastSpecialCContext); } [^*\n]+ -"//"|"/*" +{CPPC}|{CCS} \n { yyextra->yyLineNr++; } . [^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} [^\*\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 [/]* + %% {NUMBER} { //Note similar code in code.l @@ -277,8 +294,8 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} \n { /* new line */ copyToOutput(yyscanner,yytext,(int)yyleng); } -"//!"/.*\n[ \t]*"//"[\/!][^\/] | /* start C++ style special comment block */ -("///"[/]*)/[^/].*\n[ \t]*"//"[\/!][^\/] { /* start C++ style special comment block */ +{CPPC}"!"/.*\n[ \t]*{CPPC}[\/!][^\/] | /* start C++ style special comment block */ +({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); } } -"//##Documentation".*/\n { /* Start of Rational Rose ANSI C++ comment block */ +{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); } -"//"[!\/]/.*\n[ \t]*"//"[|\/][ \t]*[@\\]"}" { // next line contains an end marker, see bug 752712 +{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); } -"//"/.*\n { /* one line C++ comment */ +{CPPC}/.*\n { /* one line C++ comment */ yyextra->inSpecialComment=yytext[2]=='/' || yytext[2]=='!'; copyToOutput(yyscanner,yytext,(int)yyleng); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -"/**/" { /* avoid matching next rule for empty C comment, see bug 711723 */ +{CCS}{CCE} { /* avoid matching next rule for empty C comment, see bug 711723 */ copyToOutput(yyscanner,yytext,(int)yyleng); } -"/*"[*!]? { /* start of a C comment */ +{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); } +"\\\"" { /* escaped double quote */ + copyToOutput(yyscanner,yytext,(int)yyleng); + } +"\\\\" { /* escaped backslash */ + copyToOutput(yyscanner,yytext,(int)yyleng); + } . { /* any other character */ - copyToOutput(yyscanner,yytext,(int)yyleng); + copyToOutput(yyscanner,yytext,(int)yyleng); } [\\@]("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); } } -^[ \t]*"//"[\!\/]? { /* skip leading comments */ +^[ \t]*{CPPC}[\!\/]? { /* skip leading comments */ if (!yyextra->inSpecialComment) { copyToOutput(yyscanner,yytext,(int)yyleng); @@ -531,7 +554,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} \n { /* new line in verbatim block */ copyToOutput(yyscanner,yytext,(int)yyleng); } -^[ \t]*"//"[/!] { +^[ \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} [^ `~<\\!@*\n{\"\/]* { /* anything that is not a '*' or command */ copyToOutput(yyscanner,yytext,(int)yyleng); } -"*"+[^*/\\@\n{\"]* { /* stars without slashes */ +"*"+[^*\/\\@\n{\"]* { /* stars without slashes */ copyToOutput(yyscanner,yytext,(int)yyleng); } "\"\"\"" { /* end of Python docstring */ @@ -729,18 +752,18 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} . { copyToOutput(yyscanner,yytext,(int)yyleng); } -^[ \t]*"///"[\/]*/\n { +^[ \t]*{CPPC}"/"{SLASHopt}/\n { replaceComment(yyscanner,0); } -\n[ \t]*"///"[\/]*/\n { +\n[ \t]*{CPPC}"/"{SLASHopt}/\n { replaceComment(yyscanner,1); } -^[ \t]*"///"[^\/\n]/.*\n { +^[ \t]*{CPPC}"/"[^\/\n]/.*\n { replaceComment(yyscanner,0); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -\n[ \t]*"//"[\/!]("<")?[ \t]*[\\@]"}".*\n { +\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); } -\n[ \t]*"///"[^\/\n]/.*\n { +\n[ \t]*{CPPC}"/"[^\/\n]/.*\n { replaceComment(yyscanner,1); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -^[ \t]*"//!" | // just //! -^[ \t]*"//!<"/.*\n | // or //!< something -^[ \t]*"//!"[^<]/.*\n { // or //!something +^[ \t]*{CPPC}"!" | // just //! +^[ \t]*{CPPC}"!<"/.*\n | // or //!< something +^[ \t]*{CPPC}"!"[^<]/.*\n { // or //!something replaceComment(yyscanner,0); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -\n[ \t]*"//!" | -\n[ \t]*"//!<"/.*\n | -\n[ \t]*"//!"[^<\n]/.*\n { +\n[ \t]*{CPPC}"!" | +\n[ \t]*{CPPC}"!<"/.*\n | +\n[ \t]*{CPPC}"!"[^<\n]/.*\n { replaceComment(yyscanner,1); yyextra->readLineCtx=YY_START; BEGIN(ReadLine); } -^[ \t]*"//##"/.*\n { +^[ \t]*{CPPC}"##"/.*\n { if (!yyextra->inRoseComment) { REJECT; @@ -779,7 +802,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} BEGIN(ReadLine); } } -\n[ \t]*"//##"/.*\n { +\n[ \t]*{CPPC}"##"/.*\n { if (!yyextra->inRoseComment) { REJECT; @@ -798,19 +821,19 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} yyextra->inRoseComment=FALSE; BEGIN(Scan); } -"/**" { +{CCS}"*" { copyToOutput(yyscanner,"/‍**",8); } -"*/" { +{CCE} { copyToOutput(yyscanner,"*‍/",7); } "*" { copyToOutput(yyscanner,yytext,(int)yyleng); } -[^\\@\n\*/]* { +{RLopt} { copyToOutput(yyscanner,yytext,(int)yyleng); } -[^\\@\n\*/]*/\n { +{RLopt}/\n { copyToOutput(yyscanner,yytext,(int)yyleng); BEGIN(yyextra->readLineCtx); } @@ -844,7 +867,7 @@ NUMBER {INTEGER_NUMBER}|{FLOAT_NUMBER} [!()&| \ta-z_A-Z0-9.\-]+ { handleCondSectionId(yyscanner,yytext); } -[\\@]"cond"[ \t\r]*/\n { +[\\@]"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 ); } -^[ \t]*"//"[/!]/[^\n]+ { // skip leading special comments (see bug 618079) +^[ \t]*{CPPC}[/!]/[^\n]+ { // skip leading special comments (see bug 618079) } -"*/" { // oops, end of comment in the middle of an alias? +{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$]+"$" [a-z_A-Z]+ { // normal word addOutput(yyscanner,yytext); } -^{B}*"."{B}*/\n { // explicit end autolist: e.g " ." +^{B}*"."{Bopt}/\n { // explicit end autolist: e.g " ." addOutput(yyscanner,yytext); } ^{B}*[1-9][0-9]*"."{B}+ | @@ -797,7 +810,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$" } addOutput(yyscanner,yytext); } -^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{B}*/\n { // horizontal line (dashed) +^{B}*([\-:|]{B}*)*("--"|"---")({B}*[\-:|])*{Bopt}/\n { // horizontal line (dashed) addOutput(yyscanner,yytext); } {CMD}"---" { // escaped mdash @@ -1344,12 +1357,12 @@ RCSTAG "$"{ID}":"[^\n$]+"$" ); BEGIN(Comment); } -[^\n@\\*]*/"\n" { // end of section title +{STAopt}/"\n" { // end of section title addSection(yyscanner); addOutput(yyscanner,yytext); BEGIN( Comment ); } -[^\n@\\]*/"\\ilinebr" { // end of section title +{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'); } -"/*" { // start of a C-comment +{CCS} { // start of a C-comment if (!(yyextra->blockName=="code" || yyextra->blockName=="verbatim")) yyextra->commentCount++; addOutput(yyscanner,yytext); } -"*/" { // end of a C-comment +{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]+)