help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about token stack


From: Ervin Hegedüs
Subject: Re: Question about token stack
Date: Sun, 30 Aug 2020 16:36:59 +0200
User-agent: NeoMutt/20171215

Hi Akim

many thanks for your answer.

On Sun, Aug 30, 2020 at 03:43:54PM +0200, Akim Demaille wrote:
> Hi Ervin,
> 
> > Le 30 août 2020 à 11:44, Ervin Hegedüs <airween@gmail.com> a écrit :
> > 
> > How can I avoid this situation? Is that any "best-practice"? How
> > can I access to pointers in stack to free them when error
> > occurred?
> 
> I have not read all in details, but I believe you need to read
> about %destructor.
> 
> https://www.gnu.org/software/bison/manual/html_node/Destructor-Decl.html

looks like that's what I need - but for some reason that didn't
triggered in any case of error.

I just put:

%destructor { printf("free() called\n"); free ($$); } <*>

but it never called, and valgrind still shows that the block is
still reachable.

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

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.


Thanks again,


a.
 



reply via email to

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