--- bison.simple.cvs Tue Jun 11 18:25:32 2002 +++ bison.simple Tue Jun 11 18:29:24 2002 @@ -1118,9 +1118,40 @@ /* Return failure if at end of input. */ if (yychar == YYEOF) - YYABORT; + { + +#ifdef YYERROR_POP + +/* YYERROR_POP can be defined as an operation to be called in the event + that the parser needs to pop state from the top of the stack, during + error recovery or at YYEOF. The argument has type YYSTYPE * It will + actually point to an object. The operation can access the variable by + casting it to the proper pointer type. + + YYERROR_POP and YYERROR_DISCARD can be used (for example) to free + storage allocated for semantic tokens by grammar rules or the lexer. */ + + YYPOPSTACK; + while (yyssp > yyss) { + YYERROR_POP(yyvsp); + YYPOPSTACK; + } + +#endif + YYABORT; + } + YYDPRINTF ((stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1])); + +#ifdef YYERROR_DISCARD +/* YYERROR_DISCARD can be defined as an operation to be called in the event + that error recovery needs to discard a lookahead token. The argument should + have type YYSTYPE. */ + + YYERROR_DISCARD(yylval); +#endif + yychar = YYEMPTY; } @@ -1145,6 +1176,11 @@ /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) +#ifdef YYERROR_POP + if (yystate>1) { /* don't call for the error token, or YYEOF */ + YYERROR_POP(yyvsp); + } +#endif YYABORT; #if YYDEBUG