[PATCH] handling gcc attributes
<detox <at> vtnet.ca>
2006-01-14 13:14:12 GMT
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
<at> <at> -1195,7 +1195,7 <at> <at>
}
}
<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 ) ;
<at> <at> -1233,6 +1233,8 <at> <at>
if (yytext[yyleng-1]=='{') unput('{');
BEGIN( CompoundName ) ;
}
+<FindMembers>"__attribute__"{BN}+"((".*"))"{BN}+ {
+ }
<Operator>"("{BN}*")"({BN}*"<"[^>]*">"){BN}*/"(" { //
A::operator()<int>(int arg)
lineCount();
current->name += "()";
<at> <at> -1874,7 +1876,8 <at> <at>
<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;
<at> <at> -2202,7 +2205,9 <at> <at>
BEGIN( Array ) ;
}
}
-<Array>"]" { current->args += *yytext ;
+<Array>"]" |
+<Array>"]"({BN}+"__attribute__"{BN}*"((".*"))")? {
+ current->args += *yytext ;
if (--squareCount<=0)
BEGIN( FindMembers ) ;
}
<at> <at> -2211,7 +2216,8 <at> <at>
}
<Array>. { current->args += *yytext ; }
<SkipSquare>"[" { squareCount++; }
-<SkipSquare>"]" {
+<SkipSquare>"]" |
+<SkipSquare>"]"({BN}+"__attribute__"{BN}*"((".*"))")? {
if (--squareCount<=0)
BEGIN( lastSquareContext );
}
<at> <at> -2238,7 +2244,7 <at> <at>
<FindFields>{ID} {
current->name = yytext;
}
-<FindFields>"=" {
+<FindFields>({BN}*"__attribute__"{BN}*"((".*"))"{BN}*)?"=" {
lastInitializerContext = YY_START;
initBracketCount=0;
BEGIN(ReadInitializer);
<at> <at> -2443,7 +2449,7 <at> <at>
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++;
<at> <at> -2574,7 +2580,7 <at> <at>
BEGIN( FindMembers );
}
}
-<MemberSpec>"=" {
+<MemberSpec>({BN}*"__attribute__"{BN}*"((".*"))"{BN}*)?"=" {
lastInitializerContext=YY_START;
initBracketCount=0;
BEGIN(ReadInitializer);
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click