bison-patches
[Top][All Lists]
Advanced

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

Re: %destructor can leak the lookahead


From: Tim Van Holder
Subject: Re: %destructor can leak the lookahead
Date: Fri, 03 Sep 2004 08:22:16 +0200
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

Paul Eggert wrote:
Akim Demaille <address@hidden> writes:

- yydestruct can be called on EOF
 So what?  It should not be defined, and if the user meant to define
 it, there could be good reasons.

Sorry, I don't follow.  Why should yydestruct not be defined here?

I think Akim means that the EOF token would probably not be "defined" in
the sense of having a semantic value, and it would not have a
%destructor entry.

Sorry, I still don't follow.  Perhaps I'm misunderstanding the meaning
of destructors in general.  From the documentation, destructors are
called for all symbols that are "discarded by the parser".  But an
ordinary reduce operation discards symbols, right?  So shouldn't
destructors be invoked every time the stack shrinks, no matter why it
shrinks?

During an ordinary reduce, the user has the opportunity to do something
with the symbols in an action - the same does not go for symbols the
parser discards internally.
Using yydestruct during reduce would be disastrous to many applications;
for example, many tools create AST-style nodes in the lexer and build
a tree from them in the parser.  If bison suddenly started destroying
the nodes they just put in the tree, that would be a Bad Thing(tm).
In fact, you could say those symbols were given to the user, not
'discarded' as such.





reply via email to

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