Re: Not able to use %union?

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
> Le 18 févr. 2019 à 23:06, Hans Åberg <[email protected]> a écrit :
> 
> 
>> On 18 Feb 2019, at 04:37, Peng Yu <[email protected]> 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 allocated memory, I don't want to
>> call "rs_init(&yylval->str)" in any action.
> 
> That is probably not needed (Akim may clarify): Without a GC, just hand over the lexer allocated pointer to the parser marked with a type, and set %destructor for this type to handle error cleanup when the parser stack unwinds; otherwise deallocate in the rules.

I don't know enough of how this is supposed to work to answer.  Of course,
you have to not use the same memory space for returning two strings in a
row.

https://www.gnu.org/software/bison/manual/bison.html#Strings-are-Destroyed

Also, Peng writes:

>> 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.


_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.