[Doxygen-develop] [PATCH] handling gcc attributes
Brought to you by:
dimitri
From: <de...@vt...> - 2006-01-14 13:14:22
|
The following patch allows doxygen to process C code which contains GCC attributes. http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Attribute-Syntax.html#Attribute-Syntax Symptom: Doxygen gets confused when trying to process C code that contains attributes, it usually throws off the parser causing everything from the start of the first attribute to the end of the file to be mis-processed. Cause: The scanner doesn't know to look for attributes. Index: doxygen-1.4.6/src/scanner.l =================================================================== --- doxygen-1.4.6/src/scanner.l 2005-12-27 13:04:40.000000000 -0500 +++ doxygen-1.4.6-tlw/src/scanner.l 2006-01-14 07:51:22.210391347 -0500 @@ -1195,7 +1195,7 @@ } } <FindMembers>{B}*(("typedef"{BN}+)?)("volatile"{BN}+)?"struct{" | -<FindMembers>{B}*(("typedef"{BN}+)?)("volatile"{BN}+)?"struct"/{BN}+ { +<FindMembers>{B}*(("typedef"{BN}+)?) ("volatile"{BN}+)?"struct"({BN}+"__attribute__"{BN}*"((".*"))")?/{BN}+ { isTypedef=((QCString)yytext).find("typedef")!=-1; current->section = Entry::STRUCT_SEC ; addType( current ) ; @@ -1233,6 +1233,8 @@ if (yytext[yyleng-1]=='{') unput('{'); BEGIN( CompoundName ) ; } +<FindMembers>"__attribute__"{BN}+"((".*"))"{BN}+ { + } <Operator>"("{BN}*")"({BN}*"<"[^>]*">"){BN}*/"(" { // A::operator()<int>(int arg) lineCount(); current->name += "()"; @@ -1874,7 +1876,8 @@ <FindMembers,FindFields,ReadInitializer>"//"([!/]?) {B}*{CMD}"}".*|"/*"([!*]?){B}*{CMD}"}".*"*/" { closeGroup(current,yyFileName,yyLineNr); } -<FindMembers>"=" { +<FindMembers>"=" | +<FindMember>({BN}+"__attribute__"{BN}*"((".*"))"{BN}+)?"=" { current->bodyLine = yyLineNr; lastInitializerContext = YY_START; initBracketCount=0; @@ -2202,7 +2205,9 @@ BEGIN( Array ) ; } } -<Array>"]" { current->args += *yytext ; +<Array>"]" | +<Array>"]"({BN}+"__attribute__"{BN}*"((".*"))")? { + current->args += *yytext ; if (--squareCount<=0) BEGIN( FindMembers ) ; } @@ -2211,7 +2216,8 @@ } <Array>. { current->args += *yytext ; } <SkipSquare>"[" { squareCount++; } -<SkipSquare>"]" { +<SkipSquare>"]" | +<SkipSquare>"]"({BN}+"__attribute__"{BN}*"((".*"))")? { if (--squareCount<=0) BEGIN( lastSquareContext ); } @@ -2238,7 +2244,7 @@ <FindFields>{ID} { current->name = yytext; } -<FindFields>"=" { +<FindFields>({BN}*"__attribute__"{BN}*"((".*"))"{BN}*)?"=" { lastInitializerContext = YY_START; initBracketCount=0; BEGIN(ReadInitializer); @@ -2443,7 +2449,7 @@ unput(';'); BEGIN( MemberSpec ) ; } -<MemberSpec>([*&]*{BN}*)*{ID}{BN}*("["[^\]\n]*"]")* { // the [] part could be improved. +<MemberSpec>([*&]*{BN}*)*{ID} {BN}*("["[^\]\n]*"]")*({BN}*"__attribute__"{BN}*"((".*"))")? { // the [] part could be improved. lineCount(); int i=0,l=yyleng,j; while (i<l && (!isId(yytext[i]))) i++; @@ -2574,7 +2580,7 @@ BEGIN( FindMembers ); } } -<MemberSpec>"=" { +<MemberSpec>({BN}*"__attribute__"{BN}*"((".*"))"{BN}*)?"=" { lastInitializerContext=YY_START; initBracketCount=0; BEGIN(ReadInitializer); |