Re: Question about token stack

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>

> Le 30 août 2020 à 16:36, Ervin Hegedüs <[email protected]> a écrit :
> 
> I just put:
> 
> %destructor { printf("free() called\n"); free ($$); } <*>
> 
> but it never called, and valgrind still shows that the block is
> still reachable.

You should add debug traces and study them.  Pay special attention
to the error recovery sequence.

> Btw I reviewed the generated code, but I'm afriad this destructor
> called only when the parser run into the error state.

Yes, that's what the doc says, and that is what I believed is
what you are trying to address.

> Now I thought what happens if the scanner found an unrecognized
> token after the previous was pushed into stack - that item is
> sill at there. So I'm still curious, how can I clear the whole
> stack.

Since you don't have error-recovery, your stack will be cleared.
Show us your debug traces (yydebug = 1).

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