help-bison
[Top][All Lists]
Advanced

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

Re: accessing yyval outside lex and yacc


From: Hans Aberg
Subject: Re: accessing yyval outside lex and yacc
Date: Fri, 20 Jul 2001 21:44:24 +0200

At 18:50 +0200 2001/07/20, Akim Demaille wrote:
>Manju> Another puzzle to me though, Hans is the fact that u use a
>Manju> class definition for YYSTYPE - i was under the impression that
>Manju> one had to use %union to define YYSTPE?
>
>Hans has developed a programming style to use plain Bison for C++
>code.  It is probably too soon for you to get into it.  Actually, I
>don't even remember whether you C++.

Bison implements %union as a C/C++ union, and those unions cannot hold data
of user defined classes (specifically, with their own explicit
constructors). So if one wants to use such user defined classes, the Bison
%union feature goes down the drain.

On the other hand, it is very convenient using such user defined classes,
because one does not have to worry about memory management: If only the C++
classes one defines has the appropriate destructors, unused resources will
be released appropriately when the Bison generated parser no longer needs
them.

It is good question how to combine the Bison %union feature with such C++
defined data: One way might be to wait for the next C++ standard, which
perhaps has better union support.

  Hans Aberg





reply via email to

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