Le 27 janv. 2013 à 00:45, Bernd Clausen <qwedsa...@gmx.net> a écrit :
> I have the following destructor specified for strings like IDENT. > > %destructor { printf ("free at line %d: %s\n",@$.first_line, $$->c_str()); > delete($$); } <str> > > Now I have the following input. The first line is valid, the second line > isn't (identifier is missing): > > ConfigParam p; > ConfigParam; > > Output: > > In input 2:12 - 2:12 : syntax error > free at line 2: p > free at line 1: statementlist > > > Because of an error in the second line, Bison complains, returns a syntax > error and calls the destructors of all objects on the parsing stack. > Now I don't understand why the destructor of identifier "p" from the first > line is called? It belongs to the first line and it was successfully parsed. Hi! Did you implement error _recovery_? If you do not use the error token, your parser, once it enters error mode, will clean up everything. Only once the error token is successfully "reduced" it will stop. See the documentation about error recovery. _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison