[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Destructor trouble
From: |
Hans Aberg |
Subject: |
Re: Destructor trouble |
Date: |
Sat, 24 May 2003 09:56:08 +0200 |
At 14:20 +0200 2003/05/14, Hans Yperman wrote:
>Thanks, but that's not really the problem. My problem is: how do
>%destructor and YYERROR interact: If you have a rule that reduces b,c and
>d to a, and the action of that rule calls YYERROR, are b,c and d already
>reduced (and should i clean them myself) or are they still on the stack
>(so the %destructor will take care of them for me). And if i should clean
>them myself, is there a way to call the bison destructor myself?
I do not know exactly how %destructor is working, as I use C++, relying on
cleanup provided by that language, so it is not needed for me. -- I was
hoping somebody else should reply. In the absence of that, here is an input:
When the action of a rule executes during a reduction, the stack cannot yet
have been popped, as then the $n values would not work. So the stack is
popped after the rule action has completed. You can check this by looking
into the parser C source file that Bison writes, at the switch statement
and after it.
Now, if an YYERROR is issued, you can see that it expands to
#define YYERROR goto yyerrlab1
At yyerrlab1, there is a section unwinding the stack. You can check there
that your %destructor code is properly entered (which I hope it does).
Alternatively, you may write some code where the actions and the
%destructor code make printouts, to exactly see what happens in the case of
an error.
Hans Aberg