On Tue, 3 Oct 2006, Paolo Bonzini wrote:
> 3) %{...%} maps to before header if it is seen before %union or after the
> first %%, otherwise it maps to after header.
>
> 4) %header { ... } maps to beginning of header if it is seen before %union or
> after the first %%, otherwise it maps to after header.
But the dependence on the %union position is one of the key problems I was
trying to eliminate. I don't have time to examine your patch right now,
but, if I understand the explanation above, the only way to do the
equivalent of %end-header or %after-header is to have a %union. What if
the user doesn't have a %union? It doesn't make sense that %union should
matter.
Also, I'd like to see this kind of grammar organization work:
%start-header { #include "type1.h" }
%union { type1 field1; }
%destructor { type1_destroy ($$); } <type1>
%start-header { #include "type2.h" }
%union { type2 field2; }
%destructor { type2_destroy ($$); } <type2>
This should be allowed in the definitions or rules section. If you change
%start-header to %header under your proposal, it won't work.
Thanks for your interest in this problem. Maybe you'd like to catch up
with our latest discussion starting here:
http://lists.gnu.org/archive/html/bison-patches/2006-09/msg00048.html