help-bison
[Top][All Lists]
Advanced

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

Re: inserting into tab.h, after %union


From: Jeff Inman
Subject: Re: inserting into tab.h, after %union
Date: Mon, 4 Dec 2006 06:59:39 -0700


On Dec 2, 2006, at 2:11 PM, Joel E. Denny wrote:
On Sat, 2 Dec 2006, Joel E. Denny wrote:

On Fri, 1 Dec 2006, Jeff Inman wrote:

It seems wrong to me that the second set of "%{ ... %}", after a "%union{
...}",  should insert
into the tab.cpp file, instead of into the tab.hpp file. I want to make more
declarations
that depend on the type produced by the union.

I definitely agree that the relationship between %{...%} and % union is confusing. We're working on a set of alternatives to %{...%} that will
hopefully make things more explicit and more flexible:

1. %code {...} will insert code into your tab.cpp after the contents of the header, which include the union definition. You can, for example,
declare static globals here.

2. %requires {...} will insert code into your tab.hpp and tab.cpp before the union definition. This is the right place for dependencies of your
union.

3. %provides {...} will insert code into your tab.hpp and tab.cpp after the union definition. In other words, it's a place to write code that
your parser module provides to external code.

4. %code-top {...} is not as often useful. It inserts code at the very
top of your tab.cpp.

These are implemented in CVS now.  We will consider them experimental
until we can get some user feedback.  I can't promise when the next
release will be though.

I meant to ask: does this sound like it will address your needs?

Thanks for your reply.  Yes, these sound like they will more than
solve my problem.   I can use a manual (and your message) to help
me remember which is which, but if your design is still flexible, I'd suggest
using names that are more obvious about where the code will be
generated.  For example:

%header{...}
%both{...}

Or maybe:

%declare{...}
%define{...}
%both{...}

But, whatever they are called, these will be welcome additions.
Thanks.

Jeff



Jeff Inman
Parallel and Distributed Visualization
Los Alamos National Laboratory
PO Box 1663, B287 / Los Alamos, NM 87545





reply via email to

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