bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposal: simplify prologue alternatives into %code


From: Hans Aberg
Subject: Re: proposal: simplify prologue alternatives into %code
Date: Tue, 9 Jan 2007 12:04:46 +0100

On 4 Jan 2007, at 06:56, Joel E. Denny wrote:

5. Hans suggested we drop the quotes around "QUALIFIER" or "NAME".  I
think that idea may have some merit, but lets debate this detail only
after resolving the larger issues here.

I agree in that. Though important to get a nice syntax, getting the other stuff together is more important. :-)

In order to get the C++ class polymorphy working with the Bison static type system, would need an additional feature, and I am not sure exactly how it relates to %define and %code, though some additional macro is needed:

When %union is used, Bison uses for semantic type a 'union', and the field 'type' is selected by
  $k.type
Or something - I do not recall the exact details.

In the C++ class polymorphy variations, I had to write something like
  dynamic_type<type>(*$k.data())
  static_type<type>(*$k.data())
I use a class 'object' with a pointer to the class hierarchy; data() extracts this pointer, and should then be dereferenced. One can seek a better interface, but it does not change the discussion at hand much.

The second variation can be used (according to the C++ standard) only if the root class is not declared virtual in the derived classes. One then has, by hand, to guard against the root class being included multiple times if multiple inheritance is used. But not using 'virtual' class inheritance also speeds up dynamic_cast in the places it must be used (where the type isn't statically known). But again, in view of that virtual derivation is the "right one" from the point of view of C++ paradigm, I think one may end up with a library that uses. So Bison, by that, needs to support the use both variations.

In summary, there should be some macro available that admits all three variations above ('union'. as well as the two C++ variations). It will then likely easily accommodate the C++ Boost 'variants' Akim suggested.

  Hans Aberg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]