I recently made some changes to pycparser (see PR #169) to fix an aspect of its parsing. This has the unfortunate side effect of breaking
cffi's handling of its
c_parser module is replacing certain instances of
__dotdotdot__ or similar, and then typedef'ing
__dotdotdot__ so it's a typedef name. With the recent changes, it's now invalid to have more than one type in a type declaration if one of them is a typedef name. For example,
typedef __dotdotdot__ int; int __dotdotdot__ a;
will not parse. (I'll note here that this behavior is in agreement with the C spec as well as GCC and clang).
Below I'll quote a proposal I made in that PR thread when this issue was raised:
Maybe we could add a minor way for users of pycparser to do this sort of thing, but I'm not sure how Eli feels about this. I do know that cffi uses another hack to work around handling of __stdcall using volatile volatile const which it would be nice to get rid of.
Here's a basic proposal: Add dummy token type called USERQUOTE, which can be any sequence of characters surrounded by backticks (or whatever invalid C we decide). Then we say USERQUOTE is a valid type-qualifier. Now cffi or whoever can insert arbitrary notes to themselves wherever type qualifiers are allowed. I just tested this out and it works with 6 lines of code added.
Please let me know if this sounds like a reasonable solution, or if there are other possible solutions. I'd be willing to code up the pycparser end of this (or at least see if it's likely to be accepted), but first I'd like to know what you cffi folks think of this.