In impure push mode, don't allow more than one yypstate to be allocated

since multiple impure parsers would corrupt yynerrs.
* data/push.c (yypstate_allocated): New static global variable
initialized to 0.
(yypull_parse): If yypstate_new returns 0, don't report it as memory
exhaustion if yypstate_allocated is 1, but still return 2.
(yypstate_new): Invoke yyerror and return 0 if yypstate_allocated is
already 1.  Otherwise, set it to 1.
(yypstate_delete): Set it to 0.
* tests/push.at (Push Parsing: Multiple impure instances): New test
case.
This commit is contained in:
Joel E. Denny
2007-08-18 00:45:52 +00:00
parent 9987d1b3cc
commit 1b17b01d0f
5 changed files with 231 additions and 131 deletions

View File

@@ -164,7 +164,7 @@
typedef union YYSTYPE
{
/* Line 22 of yacc.c */
/* Line 1535 of yacc.c */
#line 94 "parse-gram.y"
symbol *symbol;
@@ -178,7 +178,7 @@ typedef union YYSTYPE
/* Line 22 of yacc.c */
/* Line 1535 of yacc.c */
#line 183 "parse-gram.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1