help-bison
[Top][All Lists]
Advanced

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

Re: stl constructs inside the union block


From: lfinsto1
Subject: Re: stl constructs inside the union block
Date: Thu, 4 Oct 2007 22:24:54 +0200 (CEST)
User-agent: SquirrelMail/1.4.9a

>
> One solution to this (and the solution I used), is to define
> a simple class that wraps a pointer of this type.  This works fine, but
> it is a bit of a kludge, and I'm really curious why the direct stl
> reference doesn't work.  Can anybody explain this to me or point me to
> a reference?
>

This isn't an answer to your question, but I strongly recommend putting
`void*' in your `%union' declaration instead of a pointer to a particular
type, especially if you want to use pointers to multiple types as the
values of different rules.  The type should always be clear from the rule
itself, so it's a simple matter to cast to the type for accessing the
value of the symbols and to `void*' for the value of the rule.  Another
reason would be if it doesn't work for some reason, as in your example.

In my experience, it doesn't pay to fight with Bison to get it to
cooperate with C++.  It works fine to generate a C version of `yyparse'
and use C++ in the rules.  I personally have never seen any reason to
generate a C++ parser, although some people may prefer one.  I'm just not
very object-oriented.

Laurence Finston









reply via email to

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