[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why isn't YYSTYPE created?
From: |
Akim Demaille |
Subject: |
Re: Why isn't YYSTYPE created? |
Date: |
Wed, 27 Nov 2013 16:10:55 +0100 |
Hi!
Le 20 nov. 2013 à 16:45, Arthur Schwarz <address@hidden> a écrit :
> Win7
> cygwin cygcheck (cygwin) 1.7.25
>
> bison (GNU Bison) 2.7.1
>
> The typedef for YYSTYPE is not created in the parser output file (in my case)
> Slip.bison.cpp nor in any file imported by flex. Is there any reason, e.g.,
> am I doing something wrong or not using a bison option correctly?
>
> The indication seems to be that if I use %union then YYSTYPE is not defined.
> Is my reading accurate?
In the case of C++, yes. It's a completely different interface
compared to the yacc-like API, there is not much point in
reproducing parts of it.
Support for "incoming" YYSTYPE, however, is a different matter,
as it provides the user with a means to define exotic semantic
value types. However since Bison 3.0 the %define variable
api.value.type makes user-defined YYSTYPE quite obsolete.
> The input from the grammar definition file (Slip.y) is:
>
>
> %file-prefix "Slip.bison"
> %language "C++"
> %name-prefix "Slip"
> %output "Slip.Bison.cpp"
>
> %union {
> int everything;
> }
>
>
> The generated parser fragment (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