[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: %union with STL
From: |
Akim Demaille |
Subject: |
Re: %union with STL |
Date: |
Wed, 27 May 2009 20:52:44 +0200 |
Le 27 mai 09 à 10:32, Vincent Zweije a écrit :
In short, I see no problem with this union at all as bison uses it,
semantics-wise, but it is unfortunate that you cannot put your own
classes in there in general.
You will be able to do that in Bison 2.6. A preview is available at
http://www.lrde.epita.fr/~akim/download/bison-2.4.266-4ff3b.tar.bz2
Using that version, you can use actual objects (not pointers to), as
in the attached sample file.
%token <::std::string> TEXT;
%token <int> NUMBER;
%printer { debug_stream () << $$; }
<int> <::std::string> <::std::list<std::string>>;
%token END_OF_FILE 0;
%type <::std::string> item;
%type <::std::list<std::string>> list;
%%
result:
list { std::cout << $1 << std::endl; }
;
list:
/* nothing */ { /* Generates an empty string list */ }
| list item { std::swap ($$, $1); $$.push_back ($2); }
;
item:
TEXT { std::swap ($$, $1); }
| NUMBER { $$ = string_cast ($1); }
;
%%
variant.yy
Description: Binary data
- Re: %union with STL, (continued)
- Re: %union with STL, Tommy Nordgren, 2009/05/24
- Re: %union with STL, Luca, 2009/05/24
- Re: %union with STL, Tommy Nordgren, 2009/05/24
- Re: %union with STL, Hans Aberg, 2009/05/24
- Re: %union with STL, Luca, 2009/05/25
- Re: %union with STL, Hans Aberg, 2009/05/25
- Re: %union with STL, Luca, 2009/05/26
- Re: %union with STL, Hans Aberg, 2009/05/26
- Re: %union with STL, Vincent Zweije, 2009/05/27
- Re: %union with STL, Hans Aberg, 2009/05/27
- Re: %union with STL,
Akim Demaille <=
- Re: %union with STL, Hans Aberg, 2009/05/27
- Re: %union with STL, Hans Aberg, 2009/05/29
Re: %union with STL, Hans Aberg, 2009/05/24