help-bison
[Top][All Lists]
Advanced

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

Re: How to use C++ types in '%union declaration'


From: Hans Aberg
Subject: Re: How to use C++ types in '%union declaration'
Date: Sat, 24 Feb 2007 21:08:15 +0100

Is it the C-parser you compile as C++? The "specifier-qualifier-list" seems to be a C-thing; see line 50 of
  http://home.att.ne.jp/omega/kikuchi/036.html

  Hans Aberg


On 24 Feb 2007, at 19:09, Bob Rossi wrote:

Hi,

I'm using bison, and giving it an input parser named foo.yxx. Doing
this has it generate a foo.cxx file. So, I use g++ to compile the
generated parser.

I'm using the %union declaration described here,
http://www.gnu.org/software/bison/manual/html_mono/ bison.html#Union-Decl

How come if I do

  %union {
    std::string *foo;
  }

I get,
  error: expected specifier-qualifier-list before ‘std’

I found a work around, which is to do
  struct s {
    std::string foo;
  };
  %union {
    struct s *foo;
  };

Do I have to do it this way? Is there a better work around?

Thanks,
Bob Rossi






reply via email to

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