I am revamping an inhouse C language bison/flex-based parser, amongst others introducing proper __ attribute__ support.
Since I cannot find any official BNF-style grammar which describes GNU GCC __ attribute__ idea (except the http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html document) I am extracting bits and pieces from the C++x11 standard and comments in various implementations found over the web.
I have almost got it done (at least when it comes to parsing examples included in GCC's doc cited above) but one particular example has given me a headache with no hint of solution in external sources.
The example is as follow:
__attribute__((noreturn)) void d0 (void),
__attribute__((format(printf, 1, 2))) d1 (const char *, ...),
d2 (void);
The description attached says that:
An attribute specifier list may appear immediately before a declarator (other than the first) in a comma-separated list of declarators in a declaration of more than one identifier using a single list of specifiers and qualifiers. Such attribute specifiers apply only to the identifier before whose declarator they appear.
Thus, leading me to this solution:
init-declarator-list:
init-declarator
init-declarator-list , attribute-specifier-seq[opt] init-declarator
I know it works but I would like to seek for a verification/support if this is a proper way to resolve the above-mentioned case.
Thanks,
Wojciech
EDIT: this link (a bit dated, though) gives a solution just as mine: http://plg.uwaterloo.ca/~cforall/gcc.y strangely, I haven't stumbled upon it earlier, only now when I did a search for __ extension__ keyword.