bug-bison
[Top][All Lists]
Advanced

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

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


From: Akim Demaille
Subject: Re: So is this OK to write #include "parser.tab.hh" in parser.yy?
Date: Fri, 14 Dec 2018 05:30:17 +0100

Hi Askar,

> Le 13 déc. 2018 à 05:09, Askar Safin <address@hidden> a écrit :
> 
> 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.

I am especially worried when you include the header in itself,
i.e., if you include it in %code requires or provides.  The
delicate part is that the user is allowed to provide information
before the definition of the semantic value type, and after it.
I remember having spent time on such issues, and I just live a
happier life if I don't have to include it at all, since the
parser does it for me at the right place.

Including from %code top or %code is ok.  Useless, but ok.

However, we have double-inclusion guards, and now I fail to see
how things could possibly go wrong.  So you are probably safe
in the other %code sections, but still, I would avoid it.


> parser.hh is generated by bison (side note: why not call it parser.tab.hh 
> then?). 

I don't understand what you mean.  We generate consistently
parser.tab.{hh,cc} or parser.{hh,cc}, but nothing mixed.  We
generate parser.tab.{hh,cc} by default, because I was too stupid
when I introduced the C++ skeleton to allow myself not to follow
the idiotic and historic naming scheme.




reply via email to

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