/* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */
yypop_ (yylen);
- while (yystate_stack_.height () != 1)
+ while (1 < yystate_stack_.height ())
{
yydestruct_ ("Cleanup: popping",
yystos_[yystate_stack_[0]],
&yylloc);
}
- while (yystate_stack_.height () != 1)
+ while (1 < yystate_stack_.height ())
{
yydestruct_ ("Cleanup: popping",
yystos_[yystate_stack_[0]],
%code
{
#include <cassert>
+ #include <cstring> // strchr
#include <stdexcept>
int yylex (yy::parser::semantic_type *);
size_t Object::counter = 0;
Object* obj;
}
+%initial-action
+{
+ if (strchr (input, 'i'))
+ throw std::runtime_error ("initial-action");
+}
+
%destructor { delete $$; } <obj>;
%printer { yyo << "counter == " << $$->counter; } <obj>;
| 's'
{
std::swap ($$, $1);
- throw std::runtime_error ("invalid expression");
+ throw std::runtime_error ("reduction");
}
%%
int
yylex (yy::parser::semantic_type *lvalp)
{
- // 'l': lexical exception, 's': syntactic exception.
+ // 'a': no error.
+ // 'i': initial action throws.
+ // 'l': yylex throws.
+ // 's': reduction throws.
switch (int res = *input++)
{
case 'l':
- throw std::runtime_error ("invalid character");
+ throw std::runtime_error ("yylex");
default:
lvalp->obj = new Object;
// Fall through.
AT_COMPILE_CXX([[input]])
AT_PARSER_CHECK([[./input aaaas]], [[2]], [[]],
-[[exception caught: invalid expression
+[[exception caught: reduction
]])
AT_PARSER_CHECK([[./input aaaal]], [[2]], [[]],
-[[exception caught: invalid character
+[[exception caught: yylex
+]])
+
+AT_PARSER_CHECK([[./input i]], [[2]], [[]],
+[[exception caught: initial-action
]])
AT_BISON_OPTION_POPDEFS