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: Mon, 4 Dec 2006 14:01:56 -0500 (EST)

On Mon, 4 Dec 2006, Joel E. Denny wrote:

> > , 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:

Although you can read about this in the NEWS entry for 2.3a, there's a 
caveat you should be aware of if you're using %skeleton "lalr1.cc".  In 
Yacc, %{...%} only writes to tab.c and never to tab.h.  For this reason 
(and because of some other confusion it causes), we agreed it was a 
mistake that %{...%} sometimes writes to tab.hpp for C++.  Thus, as of 
2.3a, it's back to Yacc functionality again.

Assuming this Yacc functionality, %code-top and %code are like %{...%} 
appearing before and after the first %union.  That is, %{...%} before the 
first %union and %code-top (no matter where it appears) insert code into 
tab.cpp before the contents of the header file.  %{...%} after the first 
%union and %code (no matter where it appears) insert code into tab.cpp 
after the contents of the header file.  Since tab.cpp is often referred to 
as the "code file", these names are actually quite easy to remember, in my 
opinion.

%requires and %provides insert code into tab.hpp before and after the 
union definition.  Thus, %requires declares code that's required by the 
union. %provides declares code (containing declarations and definitions) 
to be provided to external modules.

Well, maybe I'm wasting your time, but I hope that helps you to get a 
better feel for the names than my original post did.




reply via email to

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