[Top][All Lists]

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

So is this OK to write #include "parser.tab.hh" in parser.yy?

From: Askar Safin
Subject: So is this OK to write #include "parser.tab.hh" in parser.yy?
Date: Thu, 13 Dec 2018 07:09:39 +0300

Hi, Akim and others.
Is this OK to explicitly include bison-generated header in .yy file? In 
http://lists.gnu.org/archive/html/bug-bison/2018-12/msg00011.html you said this 
is not OK. But it seems this is exactly what you do in "Complete C++ Example". 
In parser.yy you write:

%code {
# include "driver.hh"

And driver.hh includes parser.hh . And, if I understand correctly, parser.hh is 
generated by bison (side note: why not call it parser.tab.hh then?). So, here 
parser.yy explicitly has #include for parser.hh .

So, is having such #include OK or no?

Please, answer this question in docs.

If example needs to be fixed, then fix. If not, then warn the reader that here 
we include parser.hh, and write something like this: "generally this is not 
good idea, but we include it anyway, because <insert explanation here>".

This is important. I use bison, and it seems to work. But I still don't know 
how to use it "right way". And when I try to figure out what this "right way" 
is, I face contradictions. This time I faced contradiction between your words 
and example. And so I don't know how I should write my bison files such that 
they can be considered as "right"

Askar Safin

reply via email to

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