Re: using yacc union in managed c++

Chris Dodd <cdodd@acm.org>
13 Apr 2007 01:35:14 -0400

          From comp.compilers

Related articles
using yacc union in managed c++ rastrahm@yahoo.com (ras) (2007-04-11)
Re: using yacc union in managed c++ cdodd@acm.org (Chris Dodd) (2007-04-13)
Re: using yacc union in managed c++ gneuner2@comcast.net (George Neuner) (2007-04-13)
| List of all articles for this month |

From: Chris Dodd <cdodd@acm.org>
Newsgroups: comp.compilers
Date: 13 Apr 2007 01:35:14 -0400
Organization: Compilers Central
References: 07-04-032
Keywords: yacc, C++
Posted-Date: 13 Apr 2007 01:35:14 EDT

"ras" <rastrahm@yahoo.com> wrote in news:07-04-032@comp.compilers:
> Is there a way to implement the union in a managed c++ yacc parser?
> visual studio compiler complains about the union, so for strings i
> created an array and returned the index of the string via yylval. but
> i need to return operators, floating point numbers, etc. and this
> seems klutzy. got any better ideas?


There are basically two choices -- you either ensure that the union is
a valid POD type (all the fields are types that don't have constructors or
destructors), or you can not use the %union directive at all and instead
#define YYSTYPE to be some non-union type (usually some kind of smart
pointer type).


Chris Dodd
cdodd@acm.org



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.