help-bison
[Top][All Lists]
Advanced

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

Re: %destructor documentation not quite right...


From: Joel E. Denny
Subject: Re: %destructor documentation not quite right...
Date: Sat, 22 Apr 2006 21:20:17 -0400 (EDT)

On Sat, 22 Apr 2006, Steve Murphy wrote:

> BTW-- I got a segfault when I fed bison this nonsense:
> 
> %destructor { free($$);} else {printf("Cleanup destructor called for str
> \n");} } word word_list goto_word word3_list includedname

I've reproduced this in 2.1a, but it seems to be fixed in the latest CVS 
sources.  If this is a significant problem for you, you might try the CVS 
sources, or just wait for 2.2.  Paul, Akim, any idea on when 2.2 will be 
released?

> I missed the part about the start token, which was my downfall. So I
> removed it from the %destructor list.

Be careful: the start symbol is not a token.

There are two possibilities here:

1. The start symbol does not appear on the RHS of any other production.  
In this case, you can't access its semantic value later, so why set it at 
all?

2. The start symbol does appear on the RHS of another production, and so 
you can *sometimes* access its semantic value later.  If you remove its 
%destructor, you might have memory leaks.  One way to keep the %destructor 
but avoid destroying the value at the top of the tree is to create a new 
start symbol that produces the original start symbol.

> Just a thought, but if the error processing tosses
> the start token? I guess it won't matter much; won't be much left to
> throw away...

Sorry, I'm not quite sure what you're asking.

> It appears that "warning: unused value" and "warning: unset value"
> checks have been added to 2.1a (or I've been missing them
> previously!!!), which I REALLY LIKE! found & fixed some possible bugs in
> my grammar because of this, and I appreciate the help.

Yes, they're new.  Thanks for the positive feedback.  Glad to hear they 
help.

Joel




reply via email to

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