Hi! > Le 15 févr. 2016 à 01:31, Gary L Peskin <ga...@firstech.com> a écrit : > > In the Bison 3.0.4 manual in section 3.7.6 on destructors, the example > shows: > > %union { char *string; } > %token <string> STRING1 STRING2 > %type <string> string1 string2 > %union { char character; } > %token <character> CHR > %type <character> chr > %token TAGLESS > > %destructor { } <character> > %destructor { free ($$); } <*> > %destructor { free ($$); printf ("%d", @$.first_line); } STRING1 string1 > %destructor { printf ("Discarding tagless symbol.\n"); } <> > > The text following the example says: > > However, when the parser discards a STRING1 or a string1, it also prints > its line number to stdout. It performs only the second %destructor in this > case, so it invokes free only once. > > Should the manual reference the third %destructor instead of the second? If > not, I'm confused. > > Thanks,
Actually thanks to you! For your report… and your patience :) I installed this. commit a5ef14596461104ba38f1434816a1e90eae03609 Author: Akim Demaille <akim.demai...@gmail.com> Date: Sat Aug 18 14:09:16 2018 +0200 doc: Clarify the destructor selection example Reported by Gary L Peskin. http://lists.gnu.org/archive/html/help-bison/2016-02/msg00000.html * doc/bison.texi (Destructor Decl): here. diff --git a/THANKS b/THANKS index ffea0f16..92c9a2cd 100644 --- a/THANKS +++ b/THANKS @@ -57,6 +57,7 @@ Florian Krohm flor...@edamail.fishkill.ibm.com Frank Heckenbach fr...@g-n-u.de Frans Englich frans.engl...@telia.com Gabriel Rassoul gabriel.rass...@epita.fr +Gary L Peskin ga...@firstech.com Georg Sauthoff gsaut...@techfak.uni-bielefeld.de George Neuner gneun...@comcast.net Gilles Espinasse g....@free.fr diff --git a/doc/bison.texi b/doc/bison.texi index deb7182a..28c5e2b3 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -5072,10 +5072,9 @@ For example: guarantees that, when the parser discards any user-defined symbol that has a semantic type tag other than @code{<character>}, it passes its semantic value to @code{free} by default. -However, when the parser discards a @code{STRING1} or a @code{string1}, it also -prints its line number to @code{stdout}. -It performs only the second @code{%destructor} in this case, so it invokes -@code{free} only once. +However, when the parser discards a @code{STRING1} or a @code{string1}, +it uses the third @code{%destructor}, which frees it and +prints its line number to @code{stdout} (@code{free} is invoked only once). Finally, the parser merely prints a message whenever it discards any symbol, such as @code{TAGLESS}, that has no semantic type tag. _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison