help-bison
[Top][All Lists]
Advanced

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

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


From: Bob Rossi
Subject: How to use C++ types in '%union declaration'
Date: Sat, 24 Feb 2007 13:09:16 -0500
User-agent: Mutt/1.5.12-2006-07-14

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]