help-bison
[Top][All Lists]
Advanced

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

Re: Extra code in y.tab.h


From: Hans Aberg
Subject: Re: Extra code in y.tab.h
Date: Wed, 8 Jun 2011 22:29:22 +0200

[Please keep the cc to the Bison Help list, so that others can follow the 
issue.]

On 8 Jun 2011, at 21:48, Panayiotis Karabassis wrote:

>>> What is the recommended way to get extra declarations in y.tab.h (in my
>>> case Parser.h) for a C++ parser?
>> 
>> Have you checked the Bison manual, sec. 10.1.6 A Complete C++ Example? One 
>> can put it into a new header and include the header.

> Yes, but I am a bit nitpicky and I have this convention of one foo.h
> file for each foo.cc file. Anyway the other solution is to include bar.h
> before Parser.h if Parser.h depends on bar.h. A little less awkward.

You can put code in various locations; see the %code directive, sec. 3.7.14. 
You might even tweak the skeleton file to define more code places, but then you 
may have to patch when the original is changed with new Bison releases.

However, Akim wrote the C++ parser and the example, I think, so I think that 
would be the recommended way - I tried it, and found it fine. In addition, the 
error messages are nice.

Hans





reply via email to

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