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: Hans Aberg
Subject: Re: stl constructs inside the union block
Date: Wed, 3 Oct 2007 10:50:14 +0200

On 2 Oct 2007, at 23:48, Randy Smith wrote:

I'm trying to incorporate c++ stl constructs into the %union { } block of yacc. Specifically, I'm trying to do something similar to this:

%union {
...
   std::list<unsigned int>* int_list;
...
}

This yields the error:

eidd.y:100: error: using-declaration for non-member at class scope
eidd.y:100: error: expected `;' before '<' token


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?

I think this might be a problem with the C++ compiler or a limitation of the C++ standard, because you try to instantiate a pointer to a template class, not the class itself. Bison just implements '%union {...}' verbatim as 'union {...}'. So perhaps write something before that ensures the instantiation of the pointer, experimenting in a separate file with what Bison implements.

  Hans Aberg






reply via email to

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