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: Joel E. Denny
Subject: Re: inserting into tab.h, after %union
Date: Sat, 2 Dec 2006 15:56:10 -0500 (EST)

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.




reply via email to

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