I'm sorry for the delays.
I am not convinced this was the right move. I feel there is too many
possible choices here, driven by C's model where you split definitions
and declarations. BTW, I dislike %definition as opposed to
%declaration, because
extern int foo; // is a declaration
int foo; // is a definition
and we mean declarations here.
If we were programming in some other model than C or C++, we would not
have all these sections, and I much preferred when we had that
illusion. I understand that compatibility with Yacc is an issue, but
let's keep the bad things installed only when %yacc.
The fact that people use #define YYSTYPE is something which should
fight rather than encourage. Why don't we simply complement %union
with %struct and %typedef (I don't like the name of the latter, it is
too C oriented, but %type is not precise enough and already used, and
%yystype is... bah). Since we are making here an interface change, we
can.
I propose that
- we don't keep two %declaration keywords, that's only an implementation
detail.
- Having a keyword to clarify that we are exporting declarations is
nice, but let's keep it unsplit, and keep %{ %} as a synonym.
Something like %declare, or %declaration, or %export.
- We use the header in the generated parser.
- We introduce a keyword that means that they are local to the parser file,
maybe %private. It is pasted after the inclusion of the header.