Re: Not able to use %union?

2019-02-18 Thread Akim Demaille
Le 19 fA(c)vr. 2019 A 07:01, Peng Yu a A(c)crit : I don't want to call "rs_init(&yylval->str)" in any action. You don't have to do that in every action, just the ones returning strings. I don't get the point. Because I misread, sorry. I read "in every action"

Re: Not able to use %union?

2019-02-18 Thread Peng Yu
>>> I don't want to call "rs_init(&yylval->str)" in any action. > You don't have to do that in every action, just the ones returning strings. I don't get the point. Is there a problem to not call "rs_init(&yylval->str)" in any action (this include the actions that return strings)? -- Regards,

Re: Not able to use %union?

2019-02-18 Thread Akim Demaille
> Le 18 févr. 2019 à 23:06, Hans Åberg a écrit : > > >> On 18 Feb 2019, at 04:37, Peng Yu wrote: >> >> I use rapidstring to make the string operations use and use the Boehm >> garbage collector so that I don't have to always remember to release >> the memory. >> >> https://github.com/boyerjo

Re: Not able to use %union?

2019-02-18 Thread Hans Åberg
> On 18 Feb 2019, at 04:37, Peng Yu wrote: > > I use rapidstring to make the string operations use and use the Boehm > garbage collector so that I don't have to always remember to release > the memory. > > https://github.com/boyerjohn/rapidstring > > Because I want to use the previously alloc

Re: Not able to use %union?

2019-02-18 Thread Hans Åberg
> On 18 Feb 2019, at 04:37, Peng Yu wrote: > > I use rapidstring to make the string operations use and use the Boehm > garbage collector so that I don't have to always remember to release > the memory. > > https://github.com/boyerjohn/rapidstring > > Because I want to use the previously alloc

Re: Not able to use %union?

2019-02-18 Thread Akim Demaille
> Le 18 févr. 2019 à 04:37, Peng Yu a écrit : > > Since %union cannot be used in this case, how to deal with this > scenario in bison? Thanks. You want to read the documentation of api.value.type. For instance: ‘{TYPE}’ Use this TYPE as semantic value.

Re: Not able to use %union?

2019-02-18 Thread Peng Yu
> > C++ is too verbose, generate bloated binary and takes long time to compile. Any reason that you don't want to use C++ and e.g. std::string instead of > your > pure C and garbage collector solution? > -- Regards, Peng ___ help-bison@gnu.org https://l

Re: Not able to use %union?

2019-02-18 Thread Christian Schoenebeck
On Montag, 18. Februar 2019 12:22:27 CET Christian Schoenebeck wrote: > On Sonntag, 17. Februar 2019 21:37:26 CET Peng Yu wrote: > > Because I want to use the previously allocated memory, I don't want to > > call "rs_init(&yylval->str)" in any action. So YYSTYPE must be a > > struct instead of a un

Re: Not able to use %union?

2019-02-18 Thread Christian Schoenebeck
On Sonntag, 17. Februar 2019 21:37:26 CET Peng Yu wrote: > Because I want to use the previously allocated memory, I don't want to > call "rs_init(&yylval->str)" in any action. So YYSTYPE must be a > struct instead of a union. Is it a good practice to use struct instead > of union? Yes, it is. The

Not able to use %union?

2019-02-17 Thread Peng Yu
Hi, I have the following toy flex code to generate a lexer. I use rapidstring to make the string operations use and use the Boehm garbage collector so that I don't have to always remember to release the memory. https://github.com/boyerjohn/rapidstring Because I want to use the previously alloca