[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: YYSTYPE needs to be defined and moved
From: |
Akim Demaille |
Subject: |
Re: YYSTYPE needs to be defined and moved |
Date: |
Wed, 27 Nov 2013 16:13:00 +0100 |
Hi!
Le 21 nov. 2013 à 15:01, Arthur Schwarz <address@hidden> a écrit :
> Most particularly, if the flex option %option bison-bridge is used and
> YY_DECL is not defined, then the following code is generated (using %option
> prefix="Slip"):
> extern int Sliplex \
> (YYSTYPE * yylval_param );
I know nothing about Flex's bison-bridge, I have to idea if it
works properly.
> which makes Sliplex available to yyparse but requires direct visibility to
> YYSTYPE.
>
> My though is that the actual code generated by bison should be in the
> file/global scope of y.tab.hpp and not located in a class and that YYSTYPE
> should always be generated. As seen in the example below, it is not always
> generated.
>
> In y.tab.hpp the definition of YYSTYPE is placed in the class parser as
> follows:
>
> In the parser input file Slip.y the following appears:
>
>
> %file-prefix "Slip.bison"
> %language "C++"
> %name-prefix "Slip"
> %output "Slip.Bison.cpp"
>
> %union {
> int everything;
> }
>
>
> Which causes the generation of (without #lines) is:
>
>
> namespace Slip {
>
> /// A Bison parser.
> class parser
> {
> public:
> /// Symbol semantic values.
> #ifndef YYSTYPE
> union semantic_type
> {
>
> int everything;
> };
> #else
> typedef YYSTYPE semantic_type;
> #endif
If you want to export your types, then you really need to generate
the header (see -d in the Bison documentation), and include this header
from that scanner.