diff options
Diffstat (limited to 'src/scanner.l')
-rw-r--r-- | src/scanner.l | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/src/scanner.l b/src/scanner.l index 7b24d39..2342795 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -18,6 +18,9 @@ %option prefix="scannerYY" %option reentrant %option extra-type="struct scannerYY_state *" +%top{ +#include <stdint.h> +} %{ @@ -48,10 +51,10 @@ #include "defargs.h" #include "language.h" #include "commentscan.h" -#include "code.h" #include "arguments.h" #include "clangparser.h" +#include "markdown.h" #define YY_NO_INPUT 1 #define YY_NO_UNISTD_H 1 @@ -59,6 +62,7 @@ struct scannerYY_state { OutlineParserInterface *thisParser; + CommentScanner commentScanner; const char * inputString = 0; int inputPosition = 0; int lastContext = 0; @@ -1025,9 +1029,16 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->current->explicitExternal = TRUE; lineCount(yyscanner); } -<FindMembers>{B}*"const"{BN}+ { yyextra->current->type += " const "; - if (yyextra->insideCS) yyextra->current->stat = TRUE; - lineCount(yyscanner); +<FindMembers>{B}*"const"{BN}+ { if (yyextra->insideCS) + { + yyextra->current->type += " const "; + if (yyextra->insideCS) yyextra->current->stat = TRUE; + lineCount(yyscanner); + } + else + { + REJECT; + } } <FindMembers>{B}*"virtual"{BN}+ { yyextra->current->type += " virtual "; yyextra->current->virt = Virtual; @@ -1426,7 +1437,6 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->isTypedef=decl.find("typedef")!=-1; bool isConst=decl.find("const")!=-1; bool isVolatile=decl.find("volatile")!=-1; - uint64 spec = yyextra->current->spec; yyextra->current->section = Entry::CLASS_SEC ; // preserve UNO IDL & Inline attributes, Slice local yyextra->current->spec = Entry::Struct | @@ -2483,12 +2493,12 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) if (yyextra->previous && yyextra->previous->section==Entry::GROUPDOC_SEC) { // link open command to the group defined in the yyextra->previous entry - Doxygen::docGroup.open(yyextra->previous.get(),yyextra->yyFileName,yyextra->yyLineNr); + yyextra->commentScanner.open(yyextra->previous.get(),yyextra->yyFileName,yyextra->yyLineNr); } else { // link open command to the yyextra->current entry - Doxygen::docGroup.open(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr); + yyextra->commentScanner.open(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr); } //yyextra->current = tmp; initEntry(yyscanner); @@ -2532,7 +2542,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <FindMembers,FindFields,ReadInitializer>"//"([!/]){B}*{CMD}"}".*|"/*"([!*]){B}*{CMD}"}"[^*]*"*/" { bool insideEnum = YY_START==FindFields || (YY_START==ReadInitializer && yyextra->lastInitializerContext==FindFields); // see bug746226 - Doxygen::docGroup.close(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr,insideEnum); + yyextra->commentScanner.close(yyextra->current.get(),yyextra->yyFileName,yyextra->yyLineNr,insideEnum); lineCount(yyscanner); } <FindMembers>"=" { // in PHP code this could also be due to "<?=" @@ -3614,10 +3624,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->current->name = yyextra->current->name.left(split_point); if (!yyextra->current_root->name.isEmpty()) yyextra->current->name.prepend(yyextra->current_root->name+"::"); - std::shared_ptr<Entry> tmp = yyextra->current; yyextra->current_root->moveToSubEntryAndKeep(yyextra->current); - yyextra->current_root = tmp; - + yyextra->current_root = yyextra->current; yyextra->current = new_current; } // restore documentation values @@ -3661,7 +3669,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else { yyextra->memspecEntry = yyextra->current; - yyextra->current_root->copyToSubEntry( yyextra->current ) ; + yyextra->current_root->moveToSubEntryAndKeep( yyextra->current ) ; + yyextra->current = std::make_shared<Entry>(*yyextra->current); if (yyextra->current->section==Entry::NAMESPACE_SEC || (yyextra->current->spec==Entry::Interface) || yyextra->insideJava || yyextra->insidePHP || yyextra->insideCS || yyextra->insideD || yyextra->insideJS || @@ -4272,7 +4281,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) unput(yyextra->lastCopyArgChar); BEGIN( yyextra->lastCommentInArgContext ); } -<CopyArgCommentLine>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"dot"|"code")/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!) +<CopyArgCommentLine>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"rtfonly"|"docbookonly"|"dot"|"code")/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!) yyextra->docBlockName=&yytext[1]; yyextra->fullArgString+=yytext; BEGIN(CopyArgVerbatim); @@ -4290,7 +4299,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->fullArgString+=yytext; BEGIN(CopyArgVerbatim); } -<CopyArgVerbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"enddot"|"endcode"|"f$"|"f]"|"f}")/[^a-z_A-Z0-9\-] { // end of verbatim block +<CopyArgVerbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endcode"|"f$"|"f]"|"f}")/[^a-z_A-Z0-9\-] { // end of verbatim block yyextra->fullArgString+=yytext; if (yytext[1]=='f') // end of formula { @@ -4743,23 +4752,25 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->current->startLine = yyextra->yyBegLineNr; yyextra->current->startColumn = yyextra->yyBegColNr; static QRegExp re("([^)]*[*&][^)]*)"); // (...*...) + int ts=yyextra->current->type.find('<'); + int te=yyextra->current->type.findRev('>'); + int ti=yyextra->current->type.find(re,0); + + // bug677315: A<int(void *, char *)> get(); is not a function pointer + bool isFunction = ti==-1 || // not a (...*...) pattern + (ts!=-1 && ts<te && ts<ti && ti<te); // (...*...) is part of a template argument list + bool isVariable = (!yyextra->current->type.isEmpty() && + (!isFunction || yyextra->current->type.left(8)=="typedef ")); + + //printf("type=%s ts=%d te=%d ti=%d isFunction=%d\n", + // yyextra->current->type.data(),ts,te,ti,isFunction); + if (*yytext!=';' || (yyextra->current_root->section&Entry::COMPOUND_MASK) ) { int tempArg=yyextra->current->name.find('<'); - int ts=yyextra->current->type.find('<'); - int te=yyextra->current->type.findRev('>'); - int ti=yyextra->current->type.find(re,0); - - // bug677315: A<int(void *, char *)> get(); is not a function pointer - bool isFunction = ti==-1 || // not a (...*...) pattern - (ts!=-1 && ts<te && ts<ti && ti<te); // (...*...) is part of a template argument list - - //printf("type=%s ts=%d te=%d ti=%d isFunction=%d\n", - // yyextra->current->type.data(),ts,te,ti,isFunction); QCString tempName; if (tempArg==-1) tempName=yyextra->current->name; else tempName=yyextra->current->name.left(tempArg); - if (!yyextra->current->type.isEmpty() && - (!isFunction || yyextra->current->type.left(8)=="typedef ")) + if (isVariable) { //printf("Scanner.l: found in class variable: '%s' '%s' '%s'\n", yyextra->current->type.data(),yyextra->current->name.data(),yyextra->current->args.data()); if (yyextra->isTypedef && yyextra->current->type.left(8)!="typedef ") @@ -4768,7 +4779,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } yyextra->current->section = Entry::VARIABLE_SEC ; } - else + else { //printf("Scanner.l: found in class function: '%s' '%s' '%s'\n", yyextra->current->type.data(),yyextra->current->name.data(),yyextra->current->args.data()); yyextra->current->section = Entry::FUNCTION_SEC ; @@ -4778,8 +4789,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else // a global function prototype or function variable { //printf("Scanner.l: prototype? type='%s' name='%s' args='%s'\n",yyextra->current->type.data(),yyextra->current->name.data(),yyextra->current->args.data()); - if (!yyextra->current->type.isEmpty() && - (yyextra->current->type.find(re,0)!=-1 || yyextra->current->type.left(8)=="typedef ")) + if (isVariable) { if (yyextra->isTypedef && yyextra->current->type.left(8)!="typedef ") { @@ -4912,7 +4922,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } <SkipCurly>"}"{BN}*("/*!"|"/**"|"//!"|"///")"<" { lineCount(yyscanner); - if ( yyextra->curlyCount ) + if ( yyextra->curlyCount ) { //addToBody(yytext); --yyextra->curlyCount ; @@ -4920,10 +4930,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) else { yyextra->current->endBodyLine=yyextra->yyLineNr; - // take yyextra->previous out of yyextra->current_root and move it into yyextra->current - yyextra->tempEntry = yyextra->current; // remember yyextra->current - yyextra->current_root->moveFromSubEntry(yyextra->previous.get(),yyextra->current); - yyextra->previous.reset(); + yyextra->tempEntry = yyextra->current; // temporarily switch to the previous entry + yyextra->current = yyextra->previous; yyextra->docBlockContext = SkipCurlyEndDoc; yyextra->docBlockInBody = FALSE; @@ -6252,7 +6260,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->nestedComment=FALSE; BEGIN(DocCopyBlock); } -<DocBlock>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"dot"|"code")/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!) +<DocBlock>{CMD}("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"manonly"|"rtfonly"|"docbookonly"|"dot"|"code")/[^a-z_A-Z0-9\-] { // verbatim command (which could contain nested comments!) yyextra->docBlock+=yytext; yyextra->docBlockName=&yytext[1]; yyextra->fencedSize=0; @@ -6320,7 +6328,7 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) yyextra->docBlock+=yytext; BEGIN(DocBlock); } -<DocCopyBlock>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"enddot"|"endcode")/[^a-z_A-Z0-9] { // end of verbatim block +<DocCopyBlock>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endcode")/[^a-z_A-Z0-9] { // end of verbatim block yyextra->docBlock+=yytext; if (&yytext[4]==yyextra->docBlockName) { @@ -6639,7 +6647,7 @@ static void initEntry(yyscan_t yyscanner) yyextra->current->stat = yyextra->stat; yyextra->current->lang = yyextra->language; //printf("*** initEntry(yyscanner) yyextra->language=%d\n",yyextra->language); - Doxygen::docGroup.initGroupInfo(yyextra->current.get()); + yyextra->commentScanner.initGroupInfo(yyextra->current.get()); yyextra->isTypedef=FALSE; } @@ -6965,8 +6973,8 @@ static void handleCommentBlock(yyscan_t yyscanner,const QCString &doc,bool brief int position=0; bool needsEntry=FALSE; - QCString processedDoc = preprocessCommentBlock(stripIndentation(doc),yyextra->yyFileName,lineNr); - while (parseCommentBlock( + QCString processedDoc = processMarkdownForCommentBlock(stripIndentation(doc),yyextra->yyFileName,lineNr); + while (yyextra->commentScanner.parseCommentBlock( yyextra->thisParser, yyextra->docBlockInBody && yyextra->previous ? yyextra->previous.get() : yyextra->current.get(), processedDoc, // text @@ -7025,7 +7033,7 @@ static void handleParametersCommentBlocks(yyscan_t yyscanner,ArgumentList &al) yyextra->current->brief.resize(0); //printf("handleParametersCommentBlock [%s]\n",doc.data()); - while (parseCommentBlock( + while (yyextra->commentScanner.parseCommentBlock( yyextra->thisParser, yyextra->current.get(), a.docs, // text @@ -7151,13 +7159,13 @@ static void parseCompounds(yyscan_t yyscanner,const std::shared_ptr<Entry> &rt) //memberGroupRelates.resize(0); //memberGroupInside.resize(0); QCString name = ce->name; - Doxygen::docGroup.enterCompound(yyextra->yyFileName,yyextra->yyLineNr,name); + yyextra->commentScanner.enterCompound(yyextra->yyFileName,yyextra->yyLineNr,name); scannerYYlex(yyscanner); yyextra->lexInit=TRUE; //forceEndGroup(); - Doxygen::docGroup.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name); + yyextra->commentScanner.leaveCompound(yyextra->yyFileName,yyextra->yyLineNr,name); ce->program.resize(0); @@ -7217,7 +7225,7 @@ static void parseMain(yyscan_t yyscanner, yyextra->current_root = rt; initParser(yyscanner); - Doxygen::docGroup.enterFile(yyextra->yyFileName,yyextra->yyLineNr); + yyextra->commentScanner.enterFile(yyextra->yyFileName,yyextra->yyLineNr); yyextra->current = std::make_shared<Entry>(); //printf("yyextra->current=%p yyextra->current_root=%p\n",yyextra->current,yyextra->current_root); int sec=guessSection(yyextra->yyFileName); @@ -7247,7 +7255,7 @@ static void parseMain(yyscan_t yyscanner, } //forceEndGroup(); - Doxygen::docGroup.leaveFile(yyextra->yyFileName,yyextra->yyLineNr); + yyextra->commentScanner.leaveFile(yyextra->yyFileName,yyextra->yyLineNr); rt->program.resize(0); |