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: Paolo Bonzini
Subject: Re: proposal: simplify prologue alternatives into %code
Date: Tue, 09 Jan 2007 12:21:37 +0100
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

Hans Aberg wrote:
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:

You can set up the skeleton like this:

%define "cast" "dynamic_cast"
%define "cast" "static_cast"
%define "cast" "" (or default) -> union

...

In the C++ class polymorphy variations, I had to write something like
  dynamic_cast<type>(*$k.data())
  static_cast<type>(*$k.data())

... if you are ok with

dynamic_cast<type>(*$k)

that is, instead of

struct container {
  top_class *member;
  top_class *data () { return member; }
}

you have to write this:

struct container {
  top_class *member;
  top_class &operator *() { return *member; }
}

Paolo




reply via email to

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