lalr1.cc: destroy $$ when YYERROR is called.

* data/lalr1.cc (yyreduce): Compute the resulting state before
	running the user action so that yylhs is a valid symbol.
	(yyerrorlab): Since yylhs is complete (it knows its type), we can
	simply call yy_destroy_ to destroy $$ on YYERROR invocations.
	* tests/c++.at (AT_CHECK_VARIANTS): Test YYERROR with variants.
This commit is contained in:
Akim Demaille
2009-08-12 18:00:40 +02:00
parent c67e466f9d
commit c4dc4c4671
3 changed files with 25 additions and 17 deletions

View File

@@ -105,11 +105,12 @@ result:
list:
/* nothing */ { /* Generates an empty string list */ }
| list item { std::swap($][$,$][1); $$.push_back($][2); }
| list error { std::swap($][$,$][1); }
;
item:
TEXT { std::swap($][$,$][1); }
| NUMBER { $][$ = string_cast($][1); }
| NUMBER { if ($][1 == 3) YYERROR; else $][$ = string_cast($][1); }
;
%%
@@ -188,7 +189,6 @@ AT_CHECK([./list], 0,
[0
1
2
3
4
])